From 7e477db0fc319ecaecc61aec2ab67ea731ca19cb Mon Sep 17 00:00:00 2001 From: Andrey Ovchinnikov Date: Mon, 5 Feb 2024 15:02:22 +0300 Subject: [PATCH 01/14] make some functions from mdb_iamproxy.c static --- sources/mdb_iamproxy.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sources/mdb_iamproxy.c b/sources/mdb_iamproxy.c index acbb1b7b7..64696bd3a 100644 --- a/sources/mdb_iamproxy.c +++ b/sources/mdb_iamproxy.c @@ -37,7 +37,7 @@ #define MDB_IAMPROXY_DEFAULT_SOCKET_FILE \ "/var/run/iam-auth-proxy/iam-auth-proxy.sock" // PAM SOCKET FILE place -void put_header(char dst[], uint64_t src) +static void put_header(char dst[], uint64_t src) { for (int i = 0; i < MDB_IAMPROXY_DEFAULT_HEADER_SIZE; ++i) { dst[i] = (src & 0xFF); @@ -45,7 +45,7 @@ void put_header(char dst[], uint64_t src) } } -void fetch_header(uint64_t *dst, char src[]) +static void fetch_header(uint64_t *dst, char src[]) { for (int i = 0; i < MDB_IAMPROXY_DEFAULT_HEADER_SIZE; ++i) { (*dst) |= (((uint64_t)src[i]) << (i * CHAR_BIT)); From 1935a7629d7e232e958eeec1634ece32ec4049df Mon Sep 17 00:00:00 2001 From: Andrey Ovchinnikov Date: Mon, 5 Feb 2024 15:03:51 +0300 Subject: [PATCH 02/14] fix new line symbol missing --- sources/frontend.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sources/frontend.c b/sources/frontend.c index a1f9432cd..18d38304a 100644 --- a/sources/frontend.c +++ b/sources/frontend.c @@ -2341,3 +2341,4 @@ void od_frontend(void *arg) /* close frontend connection */ od_frontend_close(client); } + From 162516157a8b0a7bc56f8eeb117d68fec788b399 Mon Sep 17 00:00:00 2001 From: Andrey Ovchinnikov Date: Mon, 5 Feb 2024 15:04:28 +0300 Subject: [PATCH 03/14] make apply_fmt --- sources/frontend.c | 1 - 1 file changed, 1 deletion(-) diff --git a/sources/frontend.c b/sources/frontend.c index 18d38304a..a1f9432cd 100644 --- a/sources/frontend.c +++ b/sources/frontend.c @@ -2341,4 +2341,3 @@ void od_frontend(void *arg) /* close frontend connection */ od_frontend_close(client); } - From 951450a1ad0d08afb132ab924353370587c7b31a Mon Sep 17 00:00:00 2001 From: Andrey Ovchinnikov Date: Mon, 5 Feb 2024 17:30:02 +0300 Subject: [PATCH 04/14] fix warnings during building --- sources/frontend.c | 4 ++-- sources/hashmap.c | 1 + sources/instance.c | 2 +- sources/logger.c | 5 +++++ sources/mdb_iamproxy.c | 4 +--- sources/mdb_iamproxy.h | 11 +++++------ sources/odyssey.h | 1 + sources/router.c | 5 ++++- sources/scram.c | 2 +- sources/stat.h | 2 +- 10 files changed, 22 insertions(+), 15 deletions(-) diff --git a/sources/frontend.c b/sources/frontend.c index a1f9432cd..01861e57f 100644 --- a/sources/frontend.c +++ b/sources/frontend.c @@ -1561,8 +1561,8 @@ static inline od_frontend_status_t od_frontend_poll_catchup(od_client_t *client, int absent_heartbeat_checks = 0; while (route->last_heartbeat == 0) { machine_sleep(ODYSSEY_CATCHUP_RECHECK_INTERVAL); - if (absent_heartbeat_checks++ > - (timeout * 1000 / ODYSSEY_CATCHUP_RECHECK_INTERVAL)) { + if ((int64_t)absent_heartbeat_checks++ > // add cast to int64_t for correct camparison (int64_t > int and ibt64_t > uint32_t) + (int64_t)(timeout * 1000 / ODYSSEY_CATCHUP_RECHECK_INTERVAL)) { od_debug(&instance->logger, "catchup", client, NULL, "No heartbeat for route detected\n"); return OD_ECATCHUP_TIMEOUT; diff --git a/sources/hashmap.c b/sources/hashmap.c index 9db6fbba9..679556ece 100644 --- a/sources/hashmap.c +++ b/sources/hashmap.c @@ -249,6 +249,7 @@ od_hashmap_elt_t *od_hashmap_lock_key(od_hashmap_t *hm, od_hash_t keyhash, int od_hashmap_unlock_key(od_hashmap_t *hm, od_hash_t keyhash, od_hashmap_elt_t *key) { + (void)key; size_t bucket_index = keyhash % hm->size; pthread_mutex_unlock(&hm->buckets[bucket_index]->mu); return 0 /* OK */; diff --git a/sources/instance.c b/sources/instance.c index 02c3355bc..62429faa1 100644 --- a/sources/instance.c +++ b/sources/instance.c @@ -90,7 +90,7 @@ void od_config_testing(od_instance_t *instance) error: od_router_free(&router); - return NOT_OK_RESPONSE; + //return NOT_OK_RESPONSE; // that function return-type is void } static inline void od_bind_version() diff --git a/sources/logger.c b/sources/logger.c index f4a1e2b51..9fd0ac5b1 100644 --- a/sources/logger.c +++ b/sources/logger.c @@ -225,6 +225,11 @@ od_logger_format(od_logger_t *logger, od_logger_level_t level, char *context, dst_pos += len; break; } + + // fall throught fix (if client is not defined will write 'none' to log file) + len = od_snprintf(dst_pos, dst_end - dst_pos, "none"); + dst_pos += len; + break; } /* unixtime */ case 'n': { diff --git a/sources/mdb_iamproxy.c b/sources/mdb_iamproxy.c index 64696bd3a..00ffafccd 100644 --- a/sources/mdb_iamproxy.c +++ b/sources/mdb_iamproxy.c @@ -58,7 +58,6 @@ machine_msg_t *mdb_iamproxy_io_read(machine_io_t *io) machine_msg_t *msg; uint64_t body_size = 0; - uint64_t received = 0; /* RECEIVE HEADER */ header = machine_read(io, MDB_IAMPROXY_DEFAULT_HEADER_SIZE, @@ -114,7 +113,7 @@ int mdb_iamproxy_io_write(machine_io_t *io, machine_msg_t *msg) return send_result; } -int mdb_iamproxy_authenticate_user(const char *username, const char *token, +int mdb_iamproxy_authenticate_user(char *username, char *token, // remove const because machine_msg_write use as buf - non constant values (but do nothing ith them....) od_instance_t *instance, od_client_t *client) { int32_t authentication_result = @@ -238,7 +237,6 @@ int mdb_iamproxy_authenticate_user(const char *username, const char *token, client->id.id, client->external_id); /*FREE RESOURCES*/ -free_external_user: machine_msg_free(external_user); free_auth_status: machine_msg_free(auth_status); diff --git a/sources/mdb_iamproxy.h b/sources/mdb_iamproxy.h index 00ca3f891..e667c6aad 100644 --- a/sources/mdb_iamproxy.h +++ b/sources/mdb_iamproxy.h @@ -1,13 +1,12 @@ #ifndef ODYSSEY_IAMPROXY_H #define ODYSSEY_IAMPROXY_H -/* - * Odyssey. - * - * Scalable PostgreSQL connection pooler. - */ +#include +#include +#include -int mdb_iamproxy_authenticate_user(const char *username, const char *token, + +int mdb_iamproxy_authenticate_user(char *username, char *token, od_instance_t *instance, od_client_t *client); diff --git a/sources/odyssey.h b/sources/odyssey.h index 4e3aaae2e..0d8c3c388 100644 --- a/sources/odyssey.h +++ b/sources/odyssey.h @@ -149,4 +149,5 @@ #include "sources/frontend.h" #include "sources/backend.h" +#include "sources/mdb_iamproxy.h" #endif /* ODYSSEY_H */ diff --git a/sources/router.c b/sources/router.c index e969c44be..f8b001dcd 100644 --- a/sources/router.c +++ b/sources/router.c @@ -27,6 +27,7 @@ void od_router_init(od_router_t *router, od_global_t *global) static inline int od_router_immed_close_server_cb(od_server_t *server, void **argv) { + (void)argv; od_route_t *route = server->route; /* remove server for server pool */ od_pg_server_pool_set(&route->server_pool, server, OD_SERVER_UNDEF); @@ -347,7 +348,7 @@ od_router_status_t od_router_route(od_router_t *router, od_client_t *client) od_router_lock(router); /* match latest version of route rule */ - od_rule_t *rule; + od_rule_t *rule = NULL; // initialize rule for (line 365) and flag '-Wmaybe-uninitialized' switch (client->type) { case OD_POOL_CLIENT_INTERNAL: rule = od_rules_forward(&router->rules, startup->database.value, @@ -357,6 +358,8 @@ od_router_status_t od_router_route(od_router_t *router, od_client_t *client) rule = od_rules_forward(&router->rules, startup->database.value, startup->user.value, 0); break; + case OD_POOL_CLIENT_UNDEF: // create that case for correct work of '-Wswitch' flag + break; } if (rule == NULL) { diff --git a/sources/scram.c b/sources/scram.c index f2f0129e4..dc9e3fa49 100644 --- a/sources/scram.c +++ b/sources/scram.c @@ -642,7 +642,7 @@ int od_scram_read_client_final_message(machine_io_t *io, /* Fetch hash data of server's SSL certificate */ scram_rc = - machine_tls_cert_hash(io, &cbind_data, &cbind_data_len); + machine_tls_cert_hash(io, &cbind_data, (uint32_t *)&cbind_data_len); // TODO: maybe rework of machinarium beacuse it's strange that we use size_t here and uint32_t in machinarium /* should not happen */ if (scram_rc != OK_RESPONSE) { diff --git a/sources/stat.h b/sources/stat.h index c9cb472ba..880686fde 100644 --- a/sources/stat.h +++ b/sources/stat.h @@ -149,7 +149,7 @@ static inline void od_stat_update_of(od_atomic_u64_t *prev, { /* todo: this could be made more optimal */ /* prev <= current */ - __atomic_store(prev, current, __ATOMIC_SEQ_CST); + __atomic_store((uint64_t *)prev, (uint64_t *)current, __ATOMIC_SEQ_CST); } static inline void od_stat_update(od_stat_t *dst, od_stat_t *stat) From c05140dff046557f8f7b56fcb24e84cd692634b2 Mon Sep 17 00:00:00 2001 From: Andrey Ovchinnikov Date: Mon, 5 Feb 2024 17:37:33 +0300 Subject: [PATCH 05/14] make apply_fmt --- sources/frontend.c | 3 ++- sources/hashmap.c | 2 +- sources/logger.c | 5 +++-- sources/mdb_iamproxy.c | 6 ++++-- sources/mdb_iamproxy.h | 1 - sources/router.c | 9 +++++---- sources/scram.c | 5 +++-- 7 files changed, 18 insertions(+), 13 deletions(-) diff --git a/sources/frontend.c b/sources/frontend.c index 01861e57f..72e113dc6 100644 --- a/sources/frontend.c +++ b/sources/frontend.c @@ -1562,7 +1562,8 @@ static inline od_frontend_status_t od_frontend_poll_catchup(od_client_t *client, while (route->last_heartbeat == 0) { machine_sleep(ODYSSEY_CATCHUP_RECHECK_INTERVAL); if ((int64_t)absent_heartbeat_checks++ > // add cast to int64_t for correct camparison (int64_t > int and ibt64_t > uint32_t) - (int64_t)(timeout * 1000 / ODYSSEY_CATCHUP_RECHECK_INTERVAL)) { + (int64_t)(timeout * 1000 / + ODYSSEY_CATCHUP_RECHECK_INTERVAL)) { od_debug(&instance->logger, "catchup", client, NULL, "No heartbeat for route detected\n"); return OD_ECATCHUP_TIMEOUT; diff --git a/sources/hashmap.c b/sources/hashmap.c index 679556ece..f250b1fee 100644 --- a/sources/hashmap.c +++ b/sources/hashmap.c @@ -249,7 +249,7 @@ od_hashmap_elt_t *od_hashmap_lock_key(od_hashmap_t *hm, od_hash_t keyhash, int od_hashmap_unlock_key(od_hashmap_t *hm, od_hash_t keyhash, od_hashmap_elt_t *key) { - (void)key; + (void)key; size_t bucket_index = keyhash % hm->size; pthread_mutex_unlock(&hm->buckets[bucket_index]->mu); return 0 /* OK */; diff --git a/sources/logger.c b/sources/logger.c index 9fd0ac5b1..77718ef78 100644 --- a/sources/logger.c +++ b/sources/logger.c @@ -226,8 +226,9 @@ od_logger_format(od_logger_t *logger, od_logger_level_t level, char *context, break; } - // fall throught fix (if client is not defined will write 'none' to log file) - len = od_snprintf(dst_pos, dst_end - dst_pos, "none"); + // fall throught fix (if client is not defined will write 'none' to log file) + len = od_snprintf(dst_pos, dst_end - dst_pos, + "none"); dst_pos += len; break; } diff --git a/sources/mdb_iamproxy.c b/sources/mdb_iamproxy.c index 00ffafccd..9551ee75a 100644 --- a/sources/mdb_iamproxy.c +++ b/sources/mdb_iamproxy.c @@ -113,8 +113,10 @@ int mdb_iamproxy_io_write(machine_io_t *io, machine_msg_t *msg) return send_result; } -int mdb_iamproxy_authenticate_user(char *username, char *token, // remove const because machine_msg_write use as buf - non constant values (but do nothing ith them....) - od_instance_t *instance, od_client_t *client) +int mdb_iamproxy_authenticate_user( + char *username, + char *token, // remove const because machine_msg_write use as buf - non constant values (but do nothing ith them....) + od_instance_t *instance, od_client_t *client) { int32_t authentication_result = MDB_IAMPROXY_CONN_DENIED; // stores authenticate status for user (default value: CONN_DENIED) diff --git a/sources/mdb_iamproxy.h b/sources/mdb_iamproxy.h index e667c6aad..5c069570c 100644 --- a/sources/mdb_iamproxy.h +++ b/sources/mdb_iamproxy.h @@ -5,7 +5,6 @@ #include #include - int mdb_iamproxy_authenticate_user(char *username, char *token, od_instance_t *instance, od_client_t *client); diff --git a/sources/router.c b/sources/router.c index f8b001dcd..0c0aa6f4a 100644 --- a/sources/router.c +++ b/sources/router.c @@ -27,7 +27,7 @@ void od_router_init(od_router_t *router, od_global_t *global) static inline int od_router_immed_close_server_cb(od_server_t *server, void **argv) { - (void)argv; + (void)argv; od_route_t *route = server->route; /* remove server for server pool */ od_pg_server_pool_set(&route->server_pool, server, OD_SERVER_UNDEF); @@ -348,7 +348,8 @@ od_router_status_t od_router_route(od_router_t *router, od_client_t *client) od_router_lock(router); /* match latest version of route rule */ - od_rule_t *rule = NULL; // initialize rule for (line 365) and flag '-Wmaybe-uninitialized' + od_rule_t *rule = + NULL; // initialize rule for (line 365) and flag '-Wmaybe-uninitialized' switch (client->type) { case OD_POOL_CLIENT_INTERNAL: rule = od_rules_forward(&router->rules, startup->database.value, @@ -358,8 +359,8 @@ od_router_status_t od_router_route(od_router_t *router, od_client_t *client) rule = od_rules_forward(&router->rules, startup->database.value, startup->user.value, 0); break; - case OD_POOL_CLIENT_UNDEF: // create that case for correct work of '-Wswitch' flag - break; + case OD_POOL_CLIENT_UNDEF: // create that case for correct work of '-Wswitch' flag + break; } if (rule == NULL) { diff --git a/sources/scram.c b/sources/scram.c index dc9e3fa49..361ab6755 100644 --- a/sources/scram.c +++ b/sources/scram.c @@ -641,8 +641,9 @@ int od_scram_read_client_final_message(machine_io_t *io, /*channel binding check*/ /* Fetch hash data of server's SSL certificate */ - scram_rc = - machine_tls_cert_hash(io, &cbind_data, (uint32_t *)&cbind_data_len); // TODO: maybe rework of machinarium beacuse it's strange that we use size_t here and uint32_t in machinarium + scram_rc = machine_tls_cert_hash( + io, &cbind_data, + (uint32_t *)&cbind_data_len); // TODO: maybe rework of machinarium beacuse it's strange that we use size_t here and uint32_t in machinarium /* should not happen */ if (scram_rc != OK_RESPONSE) { From b75343555da08f8215cfd916c17ef84fbb014e80 Mon Sep 17 00:00:00 2001 From: Andrey Ovchinnikov Date: Wed, 7 Feb 2024 11:05:37 +0300 Subject: [PATCH 06/14] fix issues --- sources/instance.c | 1 - sources/mdb_iamproxy.c | 3 ++- sources/mdb_iamproxy.h | 4 ---- 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/sources/instance.c b/sources/instance.c index 62429faa1..95cb6ae07 100644 --- a/sources/instance.c +++ b/sources/instance.c @@ -90,7 +90,6 @@ void od_config_testing(od_instance_t *instance) error: od_router_free(&router); - //return NOT_OK_RESPONSE; // that function return-type is void } static inline void od_bind_version() diff --git a/sources/mdb_iamproxy.c b/sources/mdb_iamproxy.c index 9551ee75a..28e946dab 100644 --- a/sources/mdb_iamproxy.c +++ b/sources/mdb_iamproxy.c @@ -5,8 +5,9 @@ * Scalable PostgreSQL connection pooler. */ -#include #include +#include +#include #include #include #include diff --git a/sources/mdb_iamproxy.h b/sources/mdb_iamproxy.h index 5c069570c..797fbde2f 100644 --- a/sources/mdb_iamproxy.h +++ b/sources/mdb_iamproxy.h @@ -1,10 +1,6 @@ #ifndef ODYSSEY_IAMPROXY_H #define ODYSSEY_IAMPROXY_H -#include -#include -#include - int mdb_iamproxy_authenticate_user(char *username, char *token, od_instance_t *instance, od_client_t *client); From 8664383e0ad270bd254c588a48fce79e18789be3 Mon Sep 17 00:00:00 2001 From: Andrey Ovchinnikov Date: Wed, 7 Feb 2024 23:03:44 +0300 Subject: [PATCH 07/14] fix some coverity issues --- sources/ldap.c | 13 +++++++------ sources/od_ldap.h | 2 +- sources/route.h | 2 ++ sources/router.c | 4 ++-- sources/rules.c | 4 ++-- 5 files changed, 14 insertions(+), 11 deletions(-) diff --git a/sources/ldap.c b/sources/ldap.c index 0129b0668..80f615565 100644 --- a/sources/ldap.c +++ b/sources/ldap.c @@ -358,7 +358,7 @@ od_ldap_server_t *od_ldap_server_pull(od_logger_t *logger, od_rule_t *rule, od_debug(logger, "auth_ldap", NULL, NULL, "pulling ldap_server from ldap_pool"); if (rule->ldap_pool_ttl > 0) { - if ((int)time(NULL) - + if (time(NULL) - ldap_server->idle_timestamp > rule->ldap_pool_ttl) { od_debug( @@ -418,7 +418,8 @@ od_ldap_server_t *od_ldap_server_pull(od_logger_t *logger, od_rule_t *rule, rc = od_ldap_endpoint_wait(le, timeout); if (rc == -1) { - od_ldap_endpoint_unlock(le); + // od_ldap_endpoint_unlock(le); // do we really need that line? + // unlock on line 413 and no locks in od_ldap_endpoint_wait return NULL; } @@ -476,7 +477,7 @@ static inline od_retcode_t od_ldap_server_attach(od_client_t *client) OD_SERVER_UNDEF); od_ldap_server_free(server); } else { - server->idle_timestamp = (int)time(NULL); + server->idle_timestamp = time(NULL); od_ldap_server_pool_set( client->rule->ldap_endpoint->ldap_search_pool, server, OD_SERVER_IDLE); @@ -523,7 +524,7 @@ od_retcode_t od_auth_ldap(od_client_t *cl, kiwi_password_t *tok) switch (ldap_rc) { case LDAP_SUCCESS: { - serv->idle_timestamp = (int)time(NULL); + serv->idle_timestamp = time(NULL); od_ldap_server_pool_set(cl->rule->ldap_endpoint->ldap_auth_pool, serv, OD_SERVER_IDLE); rc = OK_RESPONSE; @@ -532,7 +533,7 @@ od_retcode_t od_auth_ldap(od_client_t *cl, kiwi_password_t *tok) case LDAP_INVALID_SYNTAX: /* fallthrough */ case LDAP_INVALID_CREDENTIALS: { - serv->idle_timestamp = (int)time(NULL); + serv->idle_timestamp = time(NULL); od_ldap_server_pool_set(cl->rule->ldap_endpoint->ldap_auth_pool, serv, OD_SERVER_IDLE); rc = NOT_OK_RESPONSE; @@ -654,7 +655,7 @@ od_retcode_t od_ldap_endpoint_free(od_ldap_endpoint_t *le) } if (le->ldap_auth_pool) { - od_ldap_server_pool_free(le->ldap_search_pool); + od_ldap_server_pool_free(le->ldap_auth_pool); } pthread_mutex_destroy(&le->lock); diff --git a/sources/od_ldap.h b/sources/od_ldap.h index a339f49b6..4a90e9e68 100644 --- a/sources/od_ldap.h +++ b/sources/od_ldap.h @@ -13,7 +13,7 @@ typedef struct { od_global_t *global; void *route; - int idle_timestamp; + int64_t idle_timestamp; od_list_t link; } od_ldap_server_t; diff --git a/sources/route.h b/sources/route.h index fe029026a..a69f98bd3 100644 --- a/sources/route.h +++ b/sources/route.h @@ -168,12 +168,14 @@ static inline int od_route_reload_cb(od_server_t *server, void **argv) static inline void od_route_kill_client_pool(od_route_t *route) { + od_route_lock(route); od_client_pool_foreach(&route->client_pool, OD_CLIENT_ACTIVE, od_route_kill_cb, NULL); od_client_pool_foreach(&route->client_pool, OD_CLIENT_PENDING, od_route_kill_cb, NULL); od_client_pool_foreach(&route->client_pool, OD_CLIENT_QUEUE, od_route_kill_cb, NULL); + od_route_unlock(route); } static inline void od_route_grac_shutdown_pool(od_route_t *route) diff --git a/sources/router.c b/sources/router.c index 0c0aa6f4a..72c88cb75 100644 --- a/sources/router.c +++ b/sources/router.c @@ -420,7 +420,7 @@ od_router_status_t od_router_route(od_router_t *router, od_client_t *client) switch (ldap_rc) { case OK_RESPONSE: { od_ldap_endpoint_lock(rule->ldap_endpoint); - ldap_server->idle_timestamp = (int)time(NULL); + ldap_server->idle_timestamp = time(NULL); od_ldap_server_pool_set( rule->ldap_endpoint->ldap_search_pool, ldap_server, OD_SERVER_IDLE); @@ -439,7 +439,7 @@ od_router_status_t od_router_route(od_router_t *router, od_client_t *client) } case LDAP_INSUFFICIENT_ACCESS: { od_ldap_endpoint_lock(rule->ldap_endpoint); - ldap_server->idle_timestamp = (int)time(NULL); + ldap_server->idle_timestamp = time(NULL); od_ldap_server_pool_set( rule->ldap_endpoint->ldap_search_pool, ldap_server, OD_SERVER_IDLE); diff --git a/sources/rules.c b/sources/rules.c index 45090137a..e517ca0cd 100644 --- a/sources/rules.c +++ b/sources/rules.c @@ -1380,12 +1380,12 @@ void od_rules_print(od_rules_t *rules, od_logger_t *logger) od_log(logger, "rules", NULL, NULL, " storage_user %s", rule->storage_user); - if (rule->catchup_checks) + if (rule->catchup_timeout) od_log(logger, "rules", NULL, NULL, " catchup timeout %d", rule->catchup_timeout); if (rule->catchup_checks) od_log(logger, "rules", NULL, NULL, - " catchup timeout %d", rule->catchup_checks); + " catchup checks %d", rule->catchup_checks); od_log(logger, "rules", NULL, NULL, " log_debug %s", From 9092189cac5211f6ae9c4fc17e3a654180eedcf2 Mon Sep 17 00:00:00 2001 From: Andrey Ovchinnikov Date: Wed, 7 Feb 2024 23:08:02 +0300 Subject: [PATCH 08/14] make apply_fmt --- sources/ldap.c | 5 ++--- sources/route.h | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/sources/ldap.c b/sources/ldap.c index 80f615565..11d81dc03 100644 --- a/sources/ldap.c +++ b/sources/ldap.c @@ -358,8 +358,7 @@ od_ldap_server_t *od_ldap_server_pull(od_logger_t *logger, od_rule_t *rule, od_debug(logger, "auth_ldap", NULL, NULL, "pulling ldap_server from ldap_pool"); if (rule->ldap_pool_ttl > 0) { - if (time(NULL) - - ldap_server->idle_timestamp > + if (time(NULL) - ldap_server->idle_timestamp > rule->ldap_pool_ttl) { od_debug( logger, "auth_ldap", NULL, NULL, @@ -419,7 +418,7 @@ od_ldap_server_t *od_ldap_server_pull(od_logger_t *logger, od_rule_t *rule, if (rc == -1) { // od_ldap_endpoint_unlock(le); // do we really need that line? - // unlock on line 413 and no locks in od_ldap_endpoint_wait + // unlock on line 413 and no locks in od_ldap_endpoint_wait return NULL; } diff --git a/sources/route.h b/sources/route.h index a69f98bd3..68f1033fa 100644 --- a/sources/route.h +++ b/sources/route.h @@ -168,14 +168,14 @@ static inline int od_route_reload_cb(od_server_t *server, void **argv) static inline void od_route_kill_client_pool(od_route_t *route) { - od_route_lock(route); + od_route_lock(route); od_client_pool_foreach(&route->client_pool, OD_CLIENT_ACTIVE, od_route_kill_cb, NULL); od_client_pool_foreach(&route->client_pool, OD_CLIENT_PENDING, od_route_kill_cb, NULL); od_client_pool_foreach(&route->client_pool, OD_CLIENT_QUEUE, od_route_kill_cb, NULL); - od_route_unlock(route); + od_route_unlock(route); } static inline void od_route_grac_shutdown_pool(od_route_t *route) From f81f527acc64d7745b571f10c22340039d8eb1fa Mon Sep 17 00:00:00 2001 From: Andrey Ovchinnikov Date: Fri, 9 Feb 2024 10:06:51 +0300 Subject: [PATCH 09/14] fix memory leak --- sources/config_reader.c | 74 ++++++++++++++++++++++++++++++----------- 1 file changed, 55 insertions(+), 19 deletions(-) diff --git a/sources/config_reader.c b/sources/config_reader.c index f5066ac1c..0d0079e6c 100644 --- a/sources/config_reader.c +++ b/sources/config_reader.c @@ -768,19 +768,24 @@ static int od_config_reader_storage(od_config_reader_t *reader, return NOT_OK_RESPONSE; /* name */ - if (!od_config_reader_string(reader, &storage->name)) - return NOT_OK_RESPONSE; + if (!od_config_reader_string(reader, &storage->name)) { + od_rules_storage_free(storage); + return NOT_OK_RESPONSE; + } if (od_rules_storage_match(reader->rules, storage->name) != NULL) { od_config_reader_error(reader, NULL, "duplicate storage definition: %s", storage->name); + od_rules_storage_free(storage); return NOT_OK_RESPONSE; } od_rules_storage_add(reader->rules, storage); /* { */ - if (!od_config_reader_symbol(reader, '{')) - return NOT_OK_RESPONSE; + if (!od_config_reader_symbol(reader, '{')) { + od_rules_storage_free(storage); + return NOT_OK_RESPONSE; + } for (;;) { od_token_t token; @@ -789,50 +794,62 @@ static int od_config_reader_storage(od_config_reader_t *reader, switch (rc) { case OD_PARSER_KEYWORD: break; - case OD_PARSER_EOF: + case OD_PARSER_EOF: { od_config_reader_error(reader, &token, "unexpected end of config file"); + od_rules_storage_free(storage); return NOT_OK_RESPONSE; + } case OD_PARSER_SYMBOL: /* } */ if (token.value.num == '}') { return OK_RESPONSE; } /* fall through */ - default: + default: { od_config_reader_error( reader, &token, "incorrect or unexpected parameter"); + od_rules_storage_free(storage); return NOT_OK_RESPONSE; - } + } + } od_keyword_t *keyword; keyword = od_keyword_match(od_config_keywords, &token); if (keyword == NULL) { od_config_reader_error(reader, &token, "unknown parameter"); + od_rules_storage_free(storage); return NOT_OK_RESPONSE; } switch (keyword->id) { /* type */ case OD_LTYPE: - if (!od_config_reader_string(reader, &storage->type)) + if (!od_config_reader_string(reader, &storage->type)) { + od_rules_storage_free(storage); return NOT_OK_RESPONSE; + } continue; /* host */ case OD_LHOST: if (od_config_reader_storage_host(reader, storage) != - OK_RESPONSE) + OK_RESPONSE) { + od_rules_storage_free(storage); return NOT_OK_RESPONSE; + } continue; /* port */ case OD_LPORT: - if (!od_config_reader_number(reader, &storage->port)) + if (!od_config_reader_number(reader, &storage->port)) { + od_rules_storage_free(storage); return NOT_OK_RESPONSE; + } continue; /* target_session_attrs */ case OD_LTARGET_SESSION_ATTRS: if (!od_config_reader_string(reader, &tmp)) { + od_rules_storage_free(storage); return NOT_OK_RESPONSE; } @@ -846,6 +863,7 @@ static int od_config_reader_storage(od_config_reader_t *reader, storage->target_session_attrs = OD_TARGET_SESSION_ATTRS_RO; } else { + od_rules_storage_free(storage); return NOT_OK_RESPONSE; } @@ -856,58 +874,76 @@ static int od_config_reader_storage(od_config_reader_t *reader, /* tls */ case OD_LTLS: if (!od_config_reader_string(reader, - &storage->tls_opts->tls)) + &storage->tls_opts->tls)) { + od_rules_storage_free(storage); return NOT_OK_RESPONSE; + } continue; /* tls_ca_file */ case OD_LTLS_CA_FILE: if (!od_config_reader_string( - reader, &storage->tls_opts->tls_ca_file)) + reader, &storage->tls_opts->tls_ca_file)) { + od_rules_storage_free(storage); return NOT_OK_RESPONSE; + } continue; /* tls_key_file */ case OD_LTLS_KEY_FILE: if (!od_config_reader_string( - reader, &storage->tls_opts->tls_key_file)) + reader, &storage->tls_opts->tls_key_file)) { + od_rules_storage_free(storage); return NOT_OK_RESPONSE; + } continue; /* tls_cert_file */ case OD_LTLS_CERT_FILE: if (!od_config_reader_string( - reader, &storage->tls_opts->tls_cert_file)) + reader, &storage->tls_opts->tls_cert_file)) { + od_rules_storage_free(storage); return NOT_OK_RESPONSE; + } continue; /* tls_protocols */ case OD_LTLS_PROTOCOLS: if (!od_config_reader_string( - reader, &storage->tls_opts->tls_protocols)) + reader, &storage->tls_opts->tls_protocols)) { + od_rules_storage_free(storage); return NOT_OK_RESPONSE; + } continue; /* server_max_routing */ case OD_LSERVERS_MAX_ROUTING: if (!od_config_reader_number( - reader, &storage->server_max_routing)) + reader, &storage->server_max_routing)) { + od_rules_storage_free(storage); return NOT_OK_RESPONSE; + } continue; /* watchdog */ case OD_LWATCHDOG: storage->watchdog = od_storage_watchdog_allocate(reader->global); if (storage->watchdog == NULL) { + od_rules_storage_free(storage); return NOT_OK_RESPONSE; } if (od_config_reader_watchdog(reader, storage->watchdog, extentions) == - NOT_OK_RESPONSE) + NOT_OK_RESPONSE) { + od_rules_storage_free(storage); return NOT_OK_RESPONSE; + } continue; - default: + default: { od_config_reader_error(reader, &token, "unexpected parameter"); + od_rules_storage_free(storage); return NOT_OK_RESPONSE; } - } + } + } /* unreach */ + od_rules_storage_free(storage); return NOT_OK_RESPONSE; } From d5fe759a0a06073dfa9228438c6b8d385ed08331 Mon Sep 17 00:00:00 2001 From: Andrey Ovchinnikov Date: Fri, 9 Feb 2024 10:10:23 +0300 Subject: [PATCH 10/14] make apply_fmt --- sources/config_reader.c | 102 ++++++++++++++++++++-------------------- 1 file changed, 52 insertions(+), 50 deletions(-) diff --git a/sources/config_reader.c b/sources/config_reader.c index ac4070c3b..a08298d6c 100644 --- a/sources/config_reader.c +++ b/sources/config_reader.c @@ -769,23 +769,23 @@ static int od_config_reader_storage(od_config_reader_t *reader, /* name */ if (!od_config_reader_string(reader, &storage->name)) { - od_rules_storage_free(storage); - return NOT_OK_RESPONSE; - } + od_rules_storage_free(storage); + return NOT_OK_RESPONSE; + } if (od_rules_storage_match(reader->rules, storage->name) != NULL) { od_config_reader_error(reader, NULL, "duplicate storage definition: %s", storage->name); - od_rules_storage_free(storage); + od_rules_storage_free(storage); return NOT_OK_RESPONSE; } od_rules_storage_add(reader->rules, storage); /* { */ if (!od_config_reader_symbol(reader, '{')) { - od_rules_storage_free(storage); - return NOT_OK_RESPONSE; - } + od_rules_storage_free(storage); + return NOT_OK_RESPONSE; + } for (;;) { od_token_t token; @@ -797,9 +797,9 @@ static int od_config_reader_storage(od_config_reader_t *reader, case OD_PARSER_EOF: { od_config_reader_error(reader, &token, "unexpected end of config file"); - od_rules_storage_free(storage); + od_rules_storage_free(storage); return NOT_OK_RESPONSE; - } + } case OD_PARSER_SYMBOL: /* } */ if (token.value.num == '}') { @@ -810,46 +810,46 @@ static int od_config_reader_storage(od_config_reader_t *reader, od_config_reader_error( reader, &token, "incorrect or unexpected parameter"); - od_rules_storage_free(storage); + od_rules_storage_free(storage); return NOT_OK_RESPONSE; - } - } + } + } od_keyword_t *keyword; keyword = od_keyword_match(od_config_keywords, &token); if (keyword == NULL) { od_config_reader_error(reader, &token, "unknown parameter"); - od_rules_storage_free(storage); + od_rules_storage_free(storage); return NOT_OK_RESPONSE; } switch (keyword->id) { /* type */ case OD_LTYPE: - if (!od_config_reader_string(reader, &storage->type)) { - od_rules_storage_free(storage); + if (!od_config_reader_string(reader, &storage->type)) { + od_rules_storage_free(storage); return NOT_OK_RESPONSE; - } + } continue; /* host */ case OD_LHOST: if (od_config_reader_storage_host(reader, storage) != - OK_RESPONSE) { - od_rules_storage_free(storage); + OK_RESPONSE) { + od_rules_storage_free(storage); return NOT_OK_RESPONSE; - } + } continue; /* port */ case OD_LPORT: - if (!od_config_reader_number(reader, &storage->port)) { - od_rules_storage_free(storage); + if (!od_config_reader_number(reader, &storage->port)) { + od_rules_storage_free(storage); return NOT_OK_RESPONSE; - } + } continue; /* target_session_attrs */ case OD_LTARGET_SESSION_ATTRS: if (!od_config_reader_string(reader, &tmp)) { - od_rules_storage_free(storage); + od_rules_storage_free(storage); return NOT_OK_RESPONSE; } @@ -863,7 +863,7 @@ static int od_config_reader_storage(od_config_reader_t *reader, storage->target_session_attrs = OD_TARGET_SESSION_ATTRS_RO; } else { - od_rules_storage_free(storage); + od_rules_storage_free(storage); return NOT_OK_RESPONSE; } @@ -874,76 +874,78 @@ static int od_config_reader_storage(od_config_reader_t *reader, /* tls */ case OD_LTLS: if (!od_config_reader_string(reader, - &storage->tls_opts->tls)) { - od_rules_storage_free(storage); + &storage->tls_opts->tls)) { + od_rules_storage_free(storage); return NOT_OK_RESPONSE; - } + } continue; /* tls_ca_file */ case OD_LTLS_CA_FILE: if (!od_config_reader_string( - reader, &storage->tls_opts->tls_ca_file)) { - od_rules_storage_free(storage); + reader, &storage->tls_opts->tls_ca_file)) { + od_rules_storage_free(storage); return NOT_OK_RESPONSE; - } + } continue; /* tls_key_file */ case OD_LTLS_KEY_FILE: if (!od_config_reader_string( - reader, &storage->tls_opts->tls_key_file)) { - od_rules_storage_free(storage); + reader, &storage->tls_opts->tls_key_file)) { + od_rules_storage_free(storage); return NOT_OK_RESPONSE; - } + } continue; /* tls_cert_file */ case OD_LTLS_CERT_FILE: if (!od_config_reader_string( - reader, &storage->tls_opts->tls_cert_file)) { - od_rules_storage_free(storage); + reader, + &storage->tls_opts->tls_cert_file)) { + od_rules_storage_free(storage); return NOT_OK_RESPONSE; - } + } continue; /* tls_protocols */ case OD_LTLS_PROTOCOLS: if (!od_config_reader_string( - reader, &storage->tls_opts->tls_protocols)) { - od_rules_storage_free(storage); + reader, + &storage->tls_opts->tls_protocols)) { + od_rules_storage_free(storage); return NOT_OK_RESPONSE; - } + } continue; /* server_max_routing */ case OD_LSERVERS_MAX_ROUTING: if (!od_config_reader_number( - reader, &storage->server_max_routing)) { - od_rules_storage_free(storage); + reader, &storage->server_max_routing)) { + od_rules_storage_free(storage); return NOT_OK_RESPONSE; - } + } continue; /* watchdog */ case OD_LWATCHDOG: storage->watchdog = od_storage_watchdog_allocate(reader->global); if (storage->watchdog == NULL) { - od_rules_storage_free(storage); + od_rules_storage_free(storage); return NOT_OK_RESPONSE; } if (od_config_reader_watchdog(reader, storage->watchdog, extentions) == - NOT_OK_RESPONSE) { - od_rules_storage_free(storage); + NOT_OK_RESPONSE) { + od_rules_storage_free(storage); return NOT_OK_RESPONSE; - } + } continue; default: { od_config_reader_error(reader, &token, "unexpected parameter"); - od_rules_storage_free(storage); + od_rules_storage_free(storage); return NOT_OK_RESPONSE; } - } - } + } + } /* unreach */ - od_rules_storage_free(storage); + od_rules_storage_free(storage); return NOT_OK_RESPONSE; } From 708e95d0da1b0665d7571fc847b8b0982a6a963e Mon Sep 17 00:00:00 2001 From: Andrey Ovchinnikov Date: Fri, 9 Feb 2024 13:43:55 +0300 Subject: [PATCH 11/14] add label and add free of watchdog --- sources/config_reader.c | 103 +++++++++++++++------------------------- 1 file changed, 37 insertions(+), 66 deletions(-) diff --git a/sources/config_reader.c b/sources/config_reader.c index a08298d6c..8d9c0a625 100644 --- a/sources/config_reader.c +++ b/sources/config_reader.c @@ -768,24 +768,19 @@ static int od_config_reader_storage(od_config_reader_t *reader, return NOT_OK_RESPONSE; /* name */ - if (!od_config_reader_string(reader, &storage->name)) { - od_rules_storage_free(storage); - return NOT_OK_RESPONSE; - } + if (!od_config_reader_string(reader, &storage->name)) + goto error; if (od_rules_storage_match(reader->rules, storage->name) != NULL) { od_config_reader_error(reader, NULL, "duplicate storage definition: %s", storage->name); - od_rules_storage_free(storage); - return NOT_OK_RESPONSE; + goto error; } od_rules_storage_add(reader->rules, storage); /* { */ - if (!od_config_reader_symbol(reader, '{')) { - od_rules_storage_free(storage); - return NOT_OK_RESPONSE; - } + if (!od_config_reader_symbol(reader, '{')) + goto error; for (;;) { od_token_t token; @@ -797,8 +792,7 @@ static int od_config_reader_storage(od_config_reader_t *reader, case OD_PARSER_EOF: { od_config_reader_error(reader, &token, "unexpected end of config file"); - od_rules_storage_free(storage); - return NOT_OK_RESPONSE; + goto error; } case OD_PARSER_SYMBOL: /* } */ @@ -810,8 +804,7 @@ static int od_config_reader_storage(od_config_reader_t *reader, od_config_reader_error( reader, &token, "incorrect or unexpected parameter"); - od_rules_storage_free(storage); - return NOT_OK_RESPONSE; + goto error; } } od_keyword_t *keyword; @@ -819,38 +812,30 @@ static int od_config_reader_storage(od_config_reader_t *reader, if (keyword == NULL) { od_config_reader_error(reader, &token, "unknown parameter"); - od_rules_storage_free(storage); - return NOT_OK_RESPONSE; + goto error; } switch (keyword->id) { /* type */ case OD_LTYPE: - if (!od_config_reader_string(reader, &storage->type)) { - od_rules_storage_free(storage); - return NOT_OK_RESPONSE; - } + if (!od_config_reader_string(reader, &storage->type)) + goto error; continue; /* host */ case OD_LHOST: if (od_config_reader_storage_host(reader, storage) != - OK_RESPONSE) { - od_rules_storage_free(storage); - return NOT_OK_RESPONSE; - } + OK_RESPONSE) + goto error; continue; /* port */ case OD_LPORT: - if (!od_config_reader_number(reader, &storage->port)) { - od_rules_storage_free(storage); - return NOT_OK_RESPONSE; - } + if (!od_config_reader_number(reader, &storage->port)) + goto error; continue; /* target_session_attrs */ case OD_LTARGET_SESSION_ATTRS: if (!od_config_reader_string(reader, &tmp)) { - od_rules_storage_free(storage); - return NOT_OK_RESPONSE; + goto error; } if (strcmp(tmp, "read-write") == 0) { @@ -863,8 +848,7 @@ static int od_config_reader_storage(od_config_reader_t *reader, storage->target_session_attrs = OD_TARGET_SESSION_ATTRS_RO; } else { - od_rules_storage_free(storage); - return NOT_OK_RESPONSE; + goto error; } free(tmp); @@ -874,77 +858,64 @@ static int od_config_reader_storage(od_config_reader_t *reader, /* tls */ case OD_LTLS: if (!od_config_reader_string(reader, - &storage->tls_opts->tls)) { - od_rules_storage_free(storage); - return NOT_OK_RESPONSE; - } + &storage->tls_opts->tls)) + goto error; continue; /* tls_ca_file */ case OD_LTLS_CA_FILE: if (!od_config_reader_string( - reader, &storage->tls_opts->tls_ca_file)) { - od_rules_storage_free(storage); - return NOT_OK_RESPONSE; - } + reader, &storage->tls_opts->tls_ca_file)) + goto error; continue; /* tls_key_file */ case OD_LTLS_KEY_FILE: if (!od_config_reader_string( - reader, &storage->tls_opts->tls_key_file)) { - od_rules_storage_free(storage); - return NOT_OK_RESPONSE; - } + reader, &storage->tls_opts->tls_key_file)) + goto error; continue; /* tls_cert_file */ case OD_LTLS_CERT_FILE: if (!od_config_reader_string( reader, - &storage->tls_opts->tls_cert_file)) { - od_rules_storage_free(storage); - return NOT_OK_RESPONSE; - } + &storage->tls_opts->tls_cert_file)) + goto error; continue; /* tls_protocols */ case OD_LTLS_PROTOCOLS: if (!od_config_reader_string( reader, - &storage->tls_opts->tls_protocols)) { - od_rules_storage_free(storage); - return NOT_OK_RESPONSE; - } + &storage->tls_opts->tls_protocols)) + goto error; continue; /* server_max_routing */ case OD_LSERVERS_MAX_ROUTING: if (!od_config_reader_number( - reader, &storage->server_max_routing)) { - od_rules_storage_free(storage); - return NOT_OK_RESPONSE; - } + reader, &storage->server_max_routing)) + goto error; continue; /* watchdog */ case OD_LWATCHDOG: storage->watchdog = od_storage_watchdog_allocate(reader->global); - if (storage->watchdog == NULL) { - od_rules_storage_free(storage); - return NOT_OK_RESPONSE; - } + if (storage->watchdog == NULL) + goto error; if (od_config_reader_watchdog(reader, storage->watchdog, extentions) == - NOT_OK_RESPONSE) { - od_rules_storage_free(storage); - return NOT_OK_RESPONSE; - } + NOT_OK_RESPONSE) + goto error; continue; default: { od_config_reader_error(reader, &token, "unexpected parameter"); - od_rules_storage_free(storage); - return NOT_OK_RESPONSE; + goto error; } } } /* unreach */ +error: + if (storage->watchdog) { + od_storage_watchdog_free(storage->watchdog); + } od_rules_storage_free(storage); return NOT_OK_RESPONSE; } From 45cde964ec5538d55515b0602ca10dea30f1efe0 Mon Sep 17 00:00:00 2001 From: Andrey Ovchinnikov Date: Fri, 9 Feb 2024 13:45:50 +0300 Subject: [PATCH 12/14] make apply_fmt --- sources/config_reader.c | 52 ++++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 27 deletions(-) diff --git a/sources/config_reader.c b/sources/config_reader.c index 8d9c0a625..74d0fe1d4 100644 --- a/sources/config_reader.c +++ b/sources/config_reader.c @@ -769,18 +769,18 @@ static int od_config_reader_storage(od_config_reader_t *reader, /* name */ if (!od_config_reader_string(reader, &storage->name)) - goto error; + goto error; if (od_rules_storage_match(reader->rules, storage->name) != NULL) { od_config_reader_error(reader, NULL, "duplicate storage definition: %s", storage->name); - goto error; + goto error; } od_rules_storage_add(reader->rules, storage); /* { */ if (!od_config_reader_symbol(reader, '{')) - goto error; + goto error; for (;;) { od_token_t token; @@ -792,7 +792,7 @@ static int od_config_reader_storage(od_config_reader_t *reader, case OD_PARSER_EOF: { od_config_reader_error(reader, &token, "unexpected end of config file"); - goto error; + goto error; } case OD_PARSER_SYMBOL: /* } */ @@ -804,7 +804,7 @@ static int od_config_reader_storage(od_config_reader_t *reader, od_config_reader_error( reader, &token, "incorrect or unexpected parameter"); - goto error; + goto error; } } od_keyword_t *keyword; @@ -812,30 +812,30 @@ static int od_config_reader_storage(od_config_reader_t *reader, if (keyword == NULL) { od_config_reader_error(reader, &token, "unknown parameter"); - goto error; + goto error; } switch (keyword->id) { /* type */ case OD_LTYPE: if (!od_config_reader_string(reader, &storage->type)) - goto error; + goto error; continue; /* host */ case OD_LHOST: if (od_config_reader_storage_host(reader, storage) != OK_RESPONSE) - goto error; + goto error; continue; /* port */ case OD_LPORT: if (!od_config_reader_number(reader, &storage->port)) - goto error; + goto error; continue; /* target_session_attrs */ case OD_LTARGET_SESSION_ATTRS: if (!od_config_reader_string(reader, &tmp)) { - goto error; + goto error; } if (strcmp(tmp, "read-write") == 0) { @@ -848,7 +848,7 @@ static int od_config_reader_storage(od_config_reader_t *reader, storage->target_session_attrs = OD_TARGET_SESSION_ATTRS_RO; } else { - goto error; + goto error; } free(tmp); @@ -859,63 +859,61 @@ static int od_config_reader_storage(od_config_reader_t *reader, case OD_LTLS: if (!od_config_reader_string(reader, &storage->tls_opts->tls)) - goto error; + goto error; continue; /* tls_ca_file */ case OD_LTLS_CA_FILE: if (!od_config_reader_string( reader, &storage->tls_opts->tls_ca_file)) - goto error; + goto error; continue; /* tls_key_file */ case OD_LTLS_KEY_FILE: if (!od_config_reader_string( reader, &storage->tls_opts->tls_key_file)) - goto error; + goto error; continue; /* tls_cert_file */ case OD_LTLS_CERT_FILE: if (!od_config_reader_string( - reader, - &storage->tls_opts->tls_cert_file)) - goto error; + reader, &storage->tls_opts->tls_cert_file)) + goto error; continue; /* tls_protocols */ case OD_LTLS_PROTOCOLS: if (!od_config_reader_string( - reader, - &storage->tls_opts->tls_protocols)) - goto error; + reader, &storage->tls_opts->tls_protocols)) + goto error; continue; /* server_max_routing */ case OD_LSERVERS_MAX_ROUTING: if (!od_config_reader_number( reader, &storage->server_max_routing)) - goto error; + goto error; continue; /* watchdog */ case OD_LWATCHDOG: storage->watchdog = od_storage_watchdog_allocate(reader->global); if (storage->watchdog == NULL) - goto error; + goto error; if (od_config_reader_watchdog(reader, storage->watchdog, extentions) == NOT_OK_RESPONSE) - goto error; + goto error; continue; default: { od_config_reader_error(reader, &token, "unexpected parameter"); - goto error; + goto error; } } } /* unreach */ error: - if (storage->watchdog) { - od_storage_watchdog_free(storage->watchdog); - } + if (storage->watchdog) { + od_storage_watchdog_free(storage->watchdog); + } od_rules_storage_free(storage); return NOT_OK_RESPONSE; } From f37420c975f2f64c22a4defb19116745b7ce53d0 Mon Sep 17 00:00:00 2001 From: Andrey Ovchinnikov Date: Fri, 9 Feb 2024 17:21:16 +0300 Subject: [PATCH 13/14] remove commented line --- sources/ldap.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/sources/ldap.c b/sources/ldap.c index 11d81dc03..a71300849 100644 --- a/sources/ldap.c +++ b/sources/ldap.c @@ -417,8 +417,6 @@ od_ldap_server_t *od_ldap_server_pull(od_logger_t *logger, od_rule_t *rule, rc = od_ldap_endpoint_wait(le, timeout); if (rc == -1) { - // od_ldap_endpoint_unlock(le); // do we really need that line? - // unlock on line 413 and no locks in od_ldap_endpoint_wait return NULL; } From 617c4c8babde562914877ef8e1d5ed13d83dac8f Mon Sep 17 00:00:00 2001 From: Andrey Ovchinnikov Date: Fri, 9 Feb 2024 18:18:29 +0300 Subject: [PATCH 14/14] remove some mutex locks --- sources/route.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/sources/route.h b/sources/route.h index 68f1033fa..fe029026a 100644 --- a/sources/route.h +++ b/sources/route.h @@ -168,14 +168,12 @@ static inline int od_route_reload_cb(od_server_t *server, void **argv) static inline void od_route_kill_client_pool(od_route_t *route) { - od_route_lock(route); od_client_pool_foreach(&route->client_pool, OD_CLIENT_ACTIVE, od_route_kill_cb, NULL); od_client_pool_foreach(&route->client_pool, OD_CLIENT_PENDING, od_route_kill_cb, NULL); od_client_pool_foreach(&route->client_pool, OD_CLIENT_QUEUE, od_route_kill_cb, NULL); - od_route_unlock(route); } static inline void od_route_grac_shutdown_pool(od_route_t *route)