diff --git a/server/core/config.c b/server/core/config.c index d827c4502..b55fa5a8a 100644 --- a/server/core/config.c +++ b/server/core/config.c @@ -2069,6 +2069,7 @@ config_get_ifaddr(unsigned char *output) ifc.ifc_len = sizeof(buf); ifc.ifc_buf = buf; if (ioctl(sock, SIOCGIFCONF, &ifc) == -1) { + close(sock); return 0; } @@ -2085,6 +2086,7 @@ config_get_ifaddr(unsigned char *output) } } } else { + close(sock); return 0; } } diff --git a/server/core/session.c b/server/core/session.c index 5a546e2d8..8a34f9907 100644 --- a/server/core/session.c +++ b/server/core/session.c @@ -653,21 +653,27 @@ struct tm result; char buf[30]; int i; - double idle = (hkheartbeat - ptr->client->last_read); - idle = idle > 0 ? idle/10.f:0; + dcb_printf(dcb, "Session %d (%p)\n",ptr->ses_id, ptr); dcb_printf(dcb, "\tState: %s\n", session_state(ptr->state)); dcb_printf(dcb, "\tService: %s (%p)\n", ptr->service->name, ptr->service); dcb_printf(dcb, "\tClient DCB: %p\n", ptr->client); if (ptr->client && ptr->client->remote) - dcb_printf(dcb, "\tClient Address: %s%s%s\n", - ptr->client->user?ptr->client->user:"", - ptr->client->user?"@":"", - ptr->client->remote); - dcb_printf(dcb, "\tConnected: %s", - asctime_r(localtime_r(&ptr->stats.connect, &result), buf)); - if(ptr->client->state == DCB_STATE_POLLING) - dcb_printf(dcb, "\tIdle: %.0f seconds",idle); + { + double idle = (hkheartbeat - ptr->client->last_read); + idle = idle > 0 ? idle/10.f:0; + dcb_printf(dcb, "\tClient Address: %s%s%s\n", + ptr->client->user?ptr->client->user:"", + ptr->client->user?"@":"", + ptr->client->remote); + dcb_printf(dcb, "\tConnected: %s", + asctime_r(localtime_r(&ptr->stats.connect, &result), buf)); + if(ptr->client->state == DCB_STATE_POLLING) + { + dcb_printf(dcb, "\tIdle: %.0f seconds",idle); + } + + } if (ptr->n_filters) { for (i = 0; i < ptr->n_filters; i++) diff --git a/server/modules/filter/dbfwfilter.c b/server/modules/filter/dbfwfilter.c index b5b02ac03..9cdc2816f 100644 --- a/server/modules/filter/dbfwfilter.c +++ b/server/modules/filter/dbfwfilter.c @@ -973,12 +973,10 @@ bool parse_rule(char* rule, FW_INSTANCE* instance) tok = strtok_r(NULL, " ,",&saveptr); TIMERANGE *tr = NULL; - bool not_valid = false; while(tok){ if(!check_time(tok)) { - not_valid = true; skygw_log_write(LOGFILE_ERROR,"dbfwfilter: Rule parsing failed, malformed time definition: %s",tok); rval = false; goto retblock; @@ -1004,11 +1002,6 @@ bool parse_rule(char* rule, FW_INSTANCE* instance) } ruledef->active = tr; - if(not_valid) - { - continue; - } - } else if(strcmp(tok,"regex") == 0) { diff --git a/server/modules/filter/tee.c b/server/modules/filter/tee.c index e374b5543..10b9ee14b 100644 --- a/server/modules/filter/tee.c +++ b/server/modules/filter/tee.c @@ -1047,8 +1047,7 @@ clientReply (FILTER* instance, void *session, GWBUF *reply) } else { - if(complete) - gwbuf_free(complete); + gwbuf_free(complete); } my_session->replies[branch]++; @@ -1264,7 +1263,7 @@ int internal_route(DCB* dcb) GWBUF* clone_query(TEE_INSTANCE* my_instance, TEE_SESSION* my_session, GWBUF* buffer) { GWBUF* clone = NULL; - int length, residual; + int length, residual = 0; char* ptr; if (my_session->branch_session && diff --git a/server/modules/protocol/mysql_client.c b/server/modules/protocol/mysql_client.c index 6325016d6..abdb4422c 100644 --- a/server/modules/protocol/mysql_client.c +++ b/server/modules/protocol/mysql_client.c @@ -1015,6 +1015,9 @@ int gw_MySQLListener( int one = 1; int rc; + memset(&serv_addr,0,sizeof(serv_addr)); + memset(&local_addr,0,sizeof(local_addr)); + if (strchr(config_bind, '/')) { char *tmp = strrchr(config_bind, ':'); if (tmp) diff --git a/server/modules/protocol/mysql_common.c b/server/modules/protocol/mysql_common.c index ebc470d90..2dc77a7ac 100644 --- a/server/modules/protocol/mysql_common.c +++ b/server/modules/protocol/mysql_common.c @@ -1558,7 +1558,6 @@ int gw_find_mysql_user_password_sha1(char *username, uint8_t *gateway_password, break; } - break; } } diff --git a/server/modules/routing/schemarouter/schemarouter.c b/server/modules/routing/schemarouter/schemarouter.c index b874c2e68..3d0eecb55 100644 --- a/server/modules/routing/schemarouter/schemarouter.c +++ b/server/modules/routing/schemarouter/schemarouter.c @@ -854,7 +854,7 @@ static void* newSession( { protocol->client_capabilities &= ~GW_MYSQL_CAPABILITIES_CONNECT_WITH_DB; - strncpy(db,data->db,MYSQL_DATABASE_MAXLEN+1); + strncpy(db,data->db,MYSQL_DATABASE_MAXLEN); memset(data->db,0,MYSQL_DATABASE_MAXLEN+1); using_db = true; skygw_log_write(LOGFILE_TRACE,"schemarouter: Client logging in directly to a database '%s', " diff --git a/server/modules/routing/schemarouter/shardrouter.c b/server/modules/routing/schemarouter/shardrouter.c index 03aa02a57..a3c9da3c4 100644 --- a/server/modules/routing/schemarouter/shardrouter.c +++ b/server/modules/routing/schemarouter/shardrouter.c @@ -300,8 +300,8 @@ char* get_lenenc_str(void* data, int* len) break; case 0xfe: size = *ptr + ((*(ptr + 2) << 8)) + (*(ptr + 3) << 16) + - (*(ptr + 4) << 24) + (*(ptr + 5) << 32) + (*(ptr + 6) << 40) + - (*(ptr + 7) << 48) + (*(ptr + 8) << 56); + (*(ptr + 4) << 24) + ((long)*(ptr + 5) << 32) + ((long)*(ptr + 6) << 40) + + ((long)*(ptr + 7) << 48) + ((long)*(ptr + 8) << 56); offset = 8; break; default: @@ -972,6 +972,7 @@ createInstance(SERVICE *service, char **options) if((res_svc = calloc(sz, sizeof(SERVICE*))) == NULL) { free(router); + free(services); skygw_log_write(LOGFILE_ERROR,"Error: Memory allocation failed."); return NULL; } @@ -1296,11 +1297,10 @@ freeSession( void* router_client_session) { ROUTER_CLIENT_SES* router_cli_ses; - ROUTER_INSTANCE* router; int i; router_cli_ses = (ROUTER_CLIENT_SES *) router_client_session; - router = (ROUTER_INSTANCE *) router_instance; + /** * For each property type, walk through the list, finalize properties @@ -2072,11 +2072,9 @@ subsvc_set_state(SUBSERVICE* svc,subsvc_state_t state) { if(state & SUBSVC_WAITING_RESULT) { - int prev1; /** Increase waiter count */ - prev1 = atomic_add(&svc->n_res_waiting, 1); - ss_dassert(prev1 >= 0); + atomic_add(&svc->n_res_waiting, 1); } svc->state |= state; @@ -2089,11 +2087,8 @@ subsvc_clear_state(SUBSERVICE* svc,subsvc_state_t state) if(state & SUBSVC_WAITING_RESULT) { - int prev1; - /** Decrease waiter count */ - prev1 = atomic_add(&svc->n_res_waiting, -1); - ss_dassert(prev1 >= 0); + atomic_add(&svc->n_res_waiting, -1); } svc->state &= ~state; diff --git a/utils/skygw_utils.cc b/utils/skygw_utils.cc index 12e26ba98..78a37d43a 100644 --- a/utils/skygw_utils.cc +++ b/utils/skygw_utils.cc @@ -54,7 +54,7 @@ struct slist_st { skygw_chk_t slist_chk_top; slist_node_t* slist_head; slist_node_t* slist_tail; - size_t slist_nelems; + int slist_nelems; slist_t* slist_cursors_list; skygw_chk_t slist_chk_tail; }; @@ -1046,7 +1046,7 @@ void slcursor_add_data( } /** - * Remove the current node in the slist. This does not delete the data in the + * Remove the node currently pointed by the cursor from the slist. This does not delete the data in the * node but will delete the structure pointing to that data. This is useful when * the user wants to free the allocated memory. After node removal, the cursor * will point to the node before the removed node.