diff --git a/server/core/gateway.c b/server/core/gateway.c index 58a7153e5..18ceab7e5 100644 --- a/server/core/gateway.c +++ b/server/core/gateway.c @@ -541,6 +541,7 @@ static bool resolve_maxscale_homedir( { bool succp; char* tmp; + char* tmp2; char* log_context = NULL; ss_dassert(*p_home_dir == NULL); @@ -593,8 +594,9 @@ static bool resolve_maxscale_homedir( * isn't specified. Thus, try to access $PWD/MaxScale.cnf . */ tmp = strndup(getenv("PWD"), PATH_MAX); - get_expanded_pathname(p_home_dir, tmp, default_cnf_fname); - + tmp2 = get_expanded_pathname(p_home_dir, tmp, default_cnf_fname); + free(tmp2); /*< full path isn't needed so simply free it */ + if (*p_home_dir != NULL) { log_context = strdup("Current working directory"); @@ -646,7 +648,7 @@ check_home_dir: { succp = false; } - free (tmp); + free(tmp); if (log_context != NULL) { @@ -880,6 +882,13 @@ static char* get_expanded_pathname( if (cnf_file_buf == NULL) { + ss_dassert(cnf_file_buf != NULL); + + LOGIF(LE, (skygw_log_write_flush( + LOGFILE_ERROR, + "Error : Memory allocation failed due to %s.", + strerror(errno)))); + free(expanded_path); expanded_path = NULL; goto return_cnf_file_buf; diff --git a/server/modules/protocol/mysql_client.c b/server/modules/protocol/mysql_client.c index 781dc96ce..74472178b 100644 --- a/server/modules/protocol/mysql_client.c +++ b/server/modules/protocol/mysql_client.c @@ -1062,6 +1062,7 @@ int gw_MySQLListener( "\n* Failed to start listening MySQL due error %d, %s\n\n", eno, strerror(eno)); + close(l_so); return 0; } // assign l_so to dcb @@ -1191,8 +1192,8 @@ int gw_MySQLAccept(DCB *listener) strerror(eno)))); LOGIF(LE, (skygw_log_write_flush( LOGFILE_ERROR, - "Error %d, %s." - "Failed to accept new client connection.", + "Error : Failed to accept new client " + "connection due to %d, %s.", eno, strerror(eno)))); rc = 1; @@ -1223,9 +1224,9 @@ int gw_MySQLAccept(DCB *listener) if (client_dcb == NULL) { LOGIF(LE, (skygw_log_write_flush( LOGFILE_ERROR, - "%lu [gw_MySQLAccept] Failed to create " - "dcb object for client connection.", - pthread_self()))); + "Error : Failed to create " + "DCB object for client connection."))); + close(c_sock); rc = 1; goto return_rc; } @@ -1327,6 +1328,7 @@ int gw_MySQLAccept(DCB *listener) } #endif return_rc: + return rc; }