From 78eab19c62fe9663cfa73776147f25be378a1975 Mon Sep 17 00:00:00 2001 From: Markus Makela Date: Tue, 14 Jul 2015 17:13:09 +0300 Subject: [PATCH] Fixed compiler warnings. --- client/maxadmin.c | 3 +- server/core/config.c | 13 ---- server/core/memlog.c | 3 +- server/core/poll.c | 3 +- server/modules/filter/dbfwfilter.c | 4 +- server/modules/filter/tee.c | 3 +- server/modules/include/blr.h | 2 +- server/modules/protocol/httpd.c | 6 +- server/modules/protocol/maxscaled.c | 2 - server/modules/protocol/mysql_client.c | 4 +- server/modules/routing/binlog/blr.c | 21 +++--- server/modules/routing/binlog/blr_master.c | 9 +-- server/modules/routing/binlog/blr_slave.c | 14 ++-- server/modules/routing/readconnroute.c | 7 +- .../routing/readwritesplit/readwritesplit.c | 69 +++++++++++++------ .../routing/schemarouter/schemarouter.c | 46 ++++++++++--- utils/skygw_utils.cc | 19 ++--- 17 files changed, 125 insertions(+), 103 deletions(-) diff --git a/client/maxadmin.c b/client/maxadmin.c index 5f786ad51..6262bd34b 100644 --- a/client/maxadmin.c +++ b/client/maxadmin.c @@ -105,7 +105,6 @@ EditLine *el = NULL; Tokenizer *tok; History *hist; HistEvent ev; -const LineInfo *li; #else char buf[1024]; #endif @@ -266,7 +265,7 @@ char c; buf[i] = 0; #ifdef HISTORY - li = el_line(el); + el_line(el); history(hist, &ev, H_ENTER, buf); #endif diff --git a/server/core/config.c b/server/core/config.c index a3518893c..697b30542 100644 --- a/server/core/config.c +++ b/server/core/config.c @@ -1757,9 +1757,6 @@ SERVER *server; char *enable_root_user; char *connection_timeout; char *allow_localhost_match_wildcard_host; - char *auth_all_servers; - char *optimize_wildcard; - char *strip_db_esc; enable_root_user = config_get_value(obj->parameters, @@ -1767,16 +1764,6 @@ SERVER *server; connection_timeout = config_get_value(obj->parameters, "connection_timeout"); - - auth_all_servers = - config_get_value(obj->parameters, - "auth_all_servers"); - optimize_wildcard = - config_get_value(obj->parameters, - "optimize_wildcard"); - strip_db_esc = - config_get_value(obj->parameters, - "strip_db_esc"); allow_localhost_match_wildcard_host = config_get_value(obj->parameters, "localhost_match_wildcard_host"); diff --git a/server/core/memlog.c b/server/core/memlog.c index 8e44e2d5c..421a89ab9 100644 --- a/server/core/memlog.c +++ b/server/core/memlog.c @@ -31,6 +31,7 @@ #include #include #include +#include static MEMLOG *memlogs = NULL; static SPINLOCK memlock = SPINLOCK_INIT; @@ -133,7 +134,7 @@ memlog_log(MEMLOG *log, void *value) switch (log->type) { case ML_INT: - ((int *)(log->values))[log->offset] = (int)value; + ((int *)(log->values))[log->offset] = (intptr_t)value; break; case ML_LONG: ((long *)(log->values))[log->offset] = (long)value; diff --git a/server/core/poll.c b/server/core/poll.c index 0fb5e20e1..be8a84eb6 100644 --- a/server/core/poll.c +++ b/server/core/poll.c @@ -520,7 +520,6 @@ poll_waitevents(void *arg) struct epoll_event events[MAX_EVENTS]; int i, nfds, timeout_bias = 1; intptr_t thread_id = (intptr_t)arg; -DCB *zombies = NULL; int poll_spins = 0; /** Add this thread to the bitmask of running polling threads */ @@ -691,7 +690,7 @@ int poll_spins = 0; if (thread_data) thread_data[thread_id].state = THREAD_ZPROCESSING; - zombies = dcb_process_zombies(thread_id); + dcb_process_zombies(thread_id); if (thread_data) thread_data[thread_id].state = THREAD_IDLE; diff --git a/server/modules/filter/dbfwfilter.c b/server/modules/filter/dbfwfilter.c index 8391ab748..e3850f841 100644 --- a/server/modules/filter/dbfwfilter.c +++ b/server/modules/filter/dbfwfilter.c @@ -1661,7 +1661,7 @@ bool rule_matches(FW_INSTANCE* my_instance, FW_SESSION* my_session, GWBUF *queue { char *ptr,*where,*msg = NULL; char emsg[512]; - int qlen; + unsigned char* memptr = (unsigned char*)queue->start; bool is_sql, is_real, matches; skygw_query_op_t optype = QUERY_OP_UNDEFINED; @@ -1683,7 +1683,7 @@ bool rule_matches(FW_INSTANCE* my_instance, FW_SESSION* my_session, GWBUF *queue } optype = query_classifier_get_operation(queue); is_real = skygw_is_real_query(queue); - qlen = gw_mysql_get_byte3(memptr) - 1; + } if(rulelist->rule->on_queries == QUERY_OP_UNDEFINED || rulelist->rule->on_queries & optype){ diff --git a/server/modules/filter/tee.c b/server/modules/filter/tee.c index b13b3dacd..1557166f9 100644 --- a/server/modules/filter/tee.c +++ b/server/modules/filter/tee.c @@ -1263,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 = 0; + int residual = 0; char* ptr; if (my_session->branch_session && @@ -1291,7 +1291,6 @@ GWBUF* clone_query(TEE_INSTANCE* my_instance, TEE_SESSION* my_session, GWBUF* bu (my_instance->nomatch == NULL || regexec(&my_instance->nore,ptr,0,NULL, 0) != 0)) { - length = modutil_MySQL_query_len(buffer, &residual); clone = gwbuf_clone_all(buffer); my_session->residual = residual; } diff --git a/server/modules/include/blr.h b/server/modules/include/blr.h index 5c1270633..48d54f2ea 100644 --- a/server/modules/include/blr.h +++ b/server/modules/include/blr.h @@ -455,7 +455,7 @@ static char *blrs_states[] = { "Created", "Unregistered", "Registered", /* * Externals within the router */ -extern void blr_start_master(ROUTER_INSTANCE *); +extern void blr_start_master(void *); extern void blr_master_response(ROUTER_INSTANCE *, GWBUF *); extern void blr_master_reconnect(ROUTER_INSTANCE *); extern int blr_master_connected(ROUTER_INSTANCE *); diff --git a/server/modules/protocol/httpd.c b/server/modules/protocol/httpd.c index 0de934dec..0ebb4a72e 100644 --- a/server/modules/protocol/httpd.c +++ b/server/modules/protocol/httpd.c @@ -140,7 +140,6 @@ char buf[HTTPD_REQUESTLINE_MAXLEN-1] = ""; char *query_string = NULL; char method[HTTPD_METHOD_MAXLEN-1] = ""; char url[HTTPD_SMALL_BUFFER] = ""; -int cgi = 0; size_t i, j; int headers_read = 0; HTTPD_session *client_data = NULL; @@ -170,9 +169,6 @@ GWBUF *uri; return 0; } - if (strcasecmp(method, "POST") == 0) - cgi = 1; - i = 0; while ( (j < sizeof(buf)) && ISspace(buf[j])) { @@ -195,7 +191,7 @@ GWBUF *uri; while ((*query_string != '?') && (*query_string != '\0')) query_string++; if (*query_string == '?') { - cgi = 1; + *query_string = '\0'; query_string++; } diff --git a/server/modules/protocol/maxscaled.c b/server/modules/protocol/maxscaled.c index e1e44ea88..6b1b5e570 100644 --- a/server/modules/protocol/maxscaled.c +++ b/server/modules/protocol/maxscaled.c @@ -148,8 +148,6 @@ char *password; if (head) { - unsigned char *ptr = GWBUF_DATA(head); - ptr = GWBUF_DATA(head); if (GWBUF_LENGTH(head)) { switch (maxscaled->state) diff --git a/server/modules/protocol/mysql_client.c b/server/modules/protocol/mysql_client.c index 12dd51aae..9046c503d 100644 --- a/server/modules/protocol/mysql_client.c +++ b/server/modules/protocol/mysql_client.c @@ -641,10 +641,12 @@ gw_MySQLWrite_client(DCB *dcb, GWBUF *queue) int gw_MySQLWrite_client_SSL(DCB *dcb, GWBUF *queue) { - MySQLProtocol *protocol = NULL; CHK_DCB(dcb); +#ifdef SS_DEBUG + MySQLProtocol *protocol = NULL; protocol = DCB_PROTOCOL(dcb, MySQLProtocol); CHK_PROTOCOL(protocol); +#endif return dcb_write_SSL(dcb, queue); } diff --git a/server/modules/routing/binlog/blr.c b/server/modules/routing/binlog/blr.c index 7eac9e739..d989eeb05 100644 --- a/server/modules/routing/binlog/blr.c +++ b/server/modules/routing/binlog/blr.c @@ -108,7 +108,9 @@ static void stats_func(void *); static bool rses_begin_locked_router_action(ROUTER_SLAVE *); static void rses_end_locked_router_action(ROUTER_SLAVE *); - +void my_uuid_init(ulong seed1, ulong seed2); +void my_uuid(char *guid); +GWBUF *blr_cache_read_response(ROUTER_INSTANCE *router, char *response); static SPINLOCK instlock; static ROUTER_INSTANCE *instances; @@ -170,7 +172,7 @@ createInstance(SERVICE *service, char **options) ROUTER_INSTANCE *inst; char *value, *name; int i; -unsigned char *defuuid; +char *defuuid; if ((inst = calloc(1, sizeof(ROUTER_INSTANCE))) == NULL) { return NULL; @@ -832,7 +834,7 @@ struct tm tm; if (router_inst->lastEventTimestamp) { - localtime_r(&router_inst->lastEventTimestamp, &tm); + localtime_r((const time_t*)&router_inst->lastEventTimestamp, &tm); asctime_r(&tm, buf); dcb_printf(dcb, "\tLast binlog event timestamp: %ld (%s)\n", router_inst->lastEventTimestamp, buf); @@ -960,7 +962,7 @@ struct tm tm; if (session->lastEventTimestamp && router_inst->lastEventTimestamp) { - localtime_r(&session->lastEventTimestamp, &tm); + localtime_r((const time_t*)&session->lastEventTimestamp, &tm); asctime_r(&tm, buf); dcb_printf(dcb, "\t\tLast binlog event timestamp %u, %s", session->lastEventTimestamp, buf); dcb_printf(dcb, "\t\tSeconds behind master %u\n", router_inst->lastEventTimestamp - session->lastEventTimestamp); @@ -1058,7 +1060,8 @@ static void errorReply(ROUTER *instance, void *router_session, GWBUF *message, DCB *backend_dcb, error_action_t action, bool *succp) { ROUTER_INSTANCE *router = (ROUTER_INSTANCE *)instance; -int error, len; +int error; +socklen_t len; char msg[85], *errmsg; if (action == ERRACT_RESET) @@ -1211,10 +1214,10 @@ int len; snprintf(result, 1000, "Uptime: %u Threads: %u Events: %u Slaves: %u Master State: %s", - time(0) - router->connect_time, - config_threadcount(), - router->stats.n_binlogs_ses, - router->stats.n_slaves, + (unsigned int)(time(0) - router->connect_time), + (unsigned int)config_threadcount(), + (unsigned int)router->stats.n_binlogs_ses, + (unsigned int)router->stats.n_slaves, blrm_states[router->master_state]); if ((ret = gwbuf_alloc(4 + strlen(result))) == NULL) return 0; diff --git a/server/modules/routing/binlog/blr_master.c b/server/modules/routing/binlog/blr_master.c index 14e7e1838..dd81d21b0 100644 --- a/server/modules/routing/binlog/blr_master.c +++ b/server/modules/routing/binlog/blr_master.c @@ -81,7 +81,8 @@ inline uint32_t extract_field(uint8_t *src, int bits); static void blr_log_packet(logfile_id_t file, char *msg, uint8_t *ptr, int len); static void blr_master_close(ROUTER_INSTANCE *); static char *blr_extract_column(GWBUF *buf, int col); - +void blr_cache_response(ROUTER_INSTANCE *router, char *response, GWBUF *buf); +void poll_fake_write_event(DCB *dcb); static int keepalive = 1; /** @@ -92,8 +93,9 @@ static int keepalive = 1; * @param router The router instance */ void -blr_start_master(ROUTER_INSTANCE *router) +blr_start_master(void* data) { + ROUTER_INSTANCE *router = (ROUTER_INSTANCE*)data; DCB *client; GWBUF *buf; @@ -728,7 +730,6 @@ int no_residual = 1; int preslen = -1; int prev_length = -1; int n_bufs = -1, pn_bufs = -1; -static REP_HEADER phdr; /* * Prepend any residual buffer to the buffer chain we have @@ -914,7 +915,7 @@ static REP_HEADER phdr; } break; } - phdr = hdr; + if (hdr.ok == 0) { int event_limit; diff --git a/server/modules/routing/binlog/blr_slave.c b/server/modules/routing/binlog/blr_slave.c index 476a9d821..c788a2a6c 100644 --- a/server/modules/routing/binlog/blr_slave.c +++ b/server/modules/routing/binlog/blr_slave.c @@ -86,7 +86,7 @@ static int blr_slave_send_disconnected_server(ROUTER_INSTANCE *router, ROUTER_SL static int blr_slave_disconnect_all(ROUTER_INSTANCE *router, ROUTER_SLAVE *slave); static int blr_slave_disconnect_server(ROUTER_INSTANCE *router, ROUTER_SLAVE *slave, int server_id); static int blr_slave_send_ok(ROUTER_INSTANCE* router, ROUTER_SLAVE* slave); - +void poll_fake_write_event(DCB *dcb); extern int lm_enabled_logfiles_bitmask; extern size_t log_ses_count[]; extern __thread log_info_t tls_log_info; @@ -1122,10 +1122,9 @@ blr_slave_register(ROUTER_INSTANCE *router, ROUTER_SLAVE *slave, GWBUF *queue) { GWBUF *resp; uint8_t *ptr; -int len, slen; +int slen; ptr = GWBUF_DATA(queue); - len = extract_field(ptr, 24); ptr += 4; // Skip length and sequence number if (*ptr++ != COM_REGISTER_SLAVE) return 0; @@ -1194,7 +1193,7 @@ blr_slave_binlog_dump(ROUTER_INSTANCE *router, ROUTER_SLAVE *slave, GWBUF *queue { GWBUF *resp; uint8_t *ptr; -int len, flags, serverid, rval, binlognamelen; +int len, rval, binlognamelen; REP_HEADER hdr; uint32_t chksum; @@ -1222,9 +1221,7 @@ uint32_t chksum; slave->binlog_pos = extract_field(ptr, 32); ptr += 4; - flags = extract_field(ptr, 16); ptr += 2; - serverid = extract_field(ptr, 32); ptr += 4; strncpy(slave->binlogfile, (char *)ptr, binlognamelen); slave->binlogfile[binlognamelen] = 0; @@ -1689,7 +1686,7 @@ int len = EXTRACT24(ptr + 9); // Extract the event length len = BINLOG_FNAMELEN; ptr += 19; // Skip header slave->binlog_pos = extract_field(ptr, 32); - slave->binlog_pos += (extract_field(ptr+4, 32) << 32); + slave->binlog_pos += (((uint64_t)extract_field(ptr+4, 32)) << 32); memcpy(slave->binlogfile, ptr + 8, len); slave->binlogfile[len] = 0; } @@ -2055,7 +2052,6 @@ blr_slave_disconnect_all(ROUTER_INSTANCE *router, ROUTER_SLAVE *slave) uint8_t *ptr; int len, seqno; GWBUF *pkt; - int n = 1; /* preparing output result */ blr_slave_send_fieldcount(router, slave, 2); @@ -2105,7 +2101,7 @@ blr_slave_disconnect_all(ROUTER_INSTANCE *router, ROUTER_SLAVE *slave) strncpy((char *)ptr, state, strlen(state)); // Result string ptr += strlen(state); - n = slave->dcb->func.write(slave->dcb, pkt); + slave->dcb->func.write(slave->dcb, pkt); /* force session close*/ router_obj->closeSession(router->service->router_instance, sptr); diff --git a/server/modules/routing/readconnroute.c b/server/modules/routing/readconnroute.c index f862ea91a..ccb071e1a 100644 --- a/server/modules/routing/readconnroute.c +++ b/server/modules/routing/readconnroute.c @@ -827,12 +827,7 @@ clientReply( GWBUF *queue, DCB *backend_dcb) { - DCB *client ; - - client = backend_dcb->session->client; - - ss_dassert(client != NULL); - + ss_dassert(backend_dcb->session->client != NULL); SESSION_ROUTE_REPLY(backend_dcb->session, queue); } diff --git a/server/modules/routing/readwritesplit/readwritesplit.c b/server/modules/routing/readwritesplit/readwritesplit.c index 8defe4bb8..ba6bb10f9 100644 --- a/server/modules/routing/readwritesplit/readwritesplit.c +++ b/server/modules/routing/readwritesplit/readwritesplit.c @@ -2839,8 +2839,8 @@ static void clientReply ( /** There is one pending session command to be executed. */ if (sescmd_cursor_is_active(scur)) { - bool succp; - + bool succp; + LOGIF(LT, (skygw_log_write( LOGFILE_TRACE, "Backend %s:%d processed reply and starts to execute " @@ -2849,8 +2849,15 @@ static void clientReply ( bref->bref_backend->backend_server->port))); succp = execute_sescmd_in_backend(bref); - - ss_dassert(succp); + ss_dassert(succp); + if(!succp) + { + LOGIF(LT, (skygw_log_write( + LOGFILE_TRACE, + "Backend %s:%d failed to execute session command.", + bref->bref_backend->backend_server->name, + bref->bref_backend->backend_server->port))); + } } else if (bref->bref_pending_cmd != NULL) /*< non-sescmd is waiting to be routed */ { @@ -2944,7 +2951,7 @@ static void bref_clear_state( { if(bref == NULL) { - skygw_log_write(LE,"Error: NULL parameter passed to bref_clear_state. (%s:%d)",__FILE__,__LINE__); + skygw_log_write(LE,"[%s] Error: NULL parameter.",__FUNCTION__); return; } if (state != BREF_WAITING_RESULT) @@ -2968,6 +2975,13 @@ static void bref_clear_state( prev2 = atomic_add( &bref->bref_backend->backend_server->stats.n_current_ops, -1); ss_dassert(prev2 > 0); + if(prev2 <= 0) + { + skygw_log_write(LE,"[%s] Error: negative current operation count in backend %s:%u", + __FUNCTION__, + &bref->bref_backend->backend_server->name, + &bref->bref_backend->backend_server->port); + } } } } @@ -2978,7 +2992,7 @@ static void bref_set_state( { if(bref == NULL) { - skygw_log_write(LE,"Error: NULL parameter passed to bref_set_state. (%s:%d)",__FILE__,__LINE__); + skygw_log_write(LE,"[%s] Error: NULL parameter.",__FUNCTION__); return; } if (state != BREF_WAITING_RESULT) @@ -2993,11 +3007,24 @@ static void bref_set_state( /** Increase waiter count */ prev1 = atomic_add(&bref->bref_num_result_wait, 1); ss_dassert(prev1 >= 0); - + if(prev1 < 0) + { + skygw_log_write(LE,"[%s] Error: negative number of connections waiting for results in backend %s:%u", + __FUNCTION__, + &bref->bref_backend->backend_server->name, + &bref->bref_backend->backend_server->port); + } /** Increase global operation count */ prev2 = atomic_add( &bref->bref_backend->backend_server->stats.n_current_ops, 1); - ss_dassert(prev2 >= 0); + ss_dassert(prev2 >= 0); + if(prev2 < 0) + { + skygw_log_write(LE,"[%s] Error: negative current operation count in backend %s:%u", + __FUNCTION__, + &bref->bref_backend->backend_server->name, + &bref->bref_backend->backend_server->port); + } } } @@ -3565,7 +3592,7 @@ static void rses_property_done( { if(prop == NULL) { - skygw_log_write(LE,"Error: NULL parameter passed to rses_property_done. (%s:%d)",__FILE__,__LINE__); + skygw_log_write(LE,"[%s] Error: NULL parameter.",__FUNCTION__); return; } CHK_RSES_PROP(prop); @@ -3650,7 +3677,7 @@ static mysql_sescmd_t* rses_property_get_sescmd( if(prop == NULL) { - skygw_log_write(LE,"Error: NULL parameter passed to rses_property_get_sescmd. (%s:%d)",__FILE__,__LINE__); + skygw_log_write(LE,"[%s] Error: NULL parameter.",__FUNCTION__); return NULL; } @@ -3700,7 +3727,7 @@ static void mysql_sescmd_done( { if(sescmd == NULL) { - skygw_log_write(LE,"Error: NULL parameter passed to mysql_sescmd_done. (%s:%d)",__FILE__,__LINE__); + skygw_log_write(LE,"[%s] Error: NULL parameter.",__FUNCTION__); return; } CHK_RSES_PROP(sescmd->my_sescmd_prop); @@ -3878,7 +3905,7 @@ static bool sescmd_cursor_is_active( if(sescmd_cursor == NULL) { - skygw_log_write(LE,"Error: NULL parameter passed to sescmd_cursor_is_active. (%s:%d)",__FILE__,__LINE__); + skygw_log_write(LE,"[%s] Error: NULL parameter.",__FUNCTION__); return false; } ss_dassert(SPINLOCK_IS_LOCKED(&sescmd_cursor->scmd_cur_rses->rses_lock)); @@ -3908,7 +3935,7 @@ static GWBUF* sescmd_cursor_clone_querybuf( GWBUF* buf; if(scur == NULL) { - skygw_log_write(LE,"Error: NULL parameter passed to sescmd_cursor_clone_querybuf. (%s:%d)",__FILE__,__LINE__); + skygw_log_write(LE,"[%s] Error: NULL parameter.",__FUNCTION__); return NULL; } ss_dassert(scur->scmd_cur_cmd != NULL); @@ -3926,7 +3953,7 @@ static bool sescmd_cursor_history_empty( if(scur == NULL) { - skygw_log_write(LE,"Error: NULL parameter passed to sescmd_cursor_history_empty. (%s:%d)",__FILE__,__LINE__); + skygw_log_write(LE,"[%s] Error: NULL parameter.",__FUNCTION__); return true; } CHK_SESCMD_CUR(scur); @@ -3950,7 +3977,7 @@ static void sescmd_cursor_reset( ROUTER_CLIENT_SES* rses; if(scur == NULL) { - skygw_log_write(LE,"Error: NULL parameter passed to sescmd_cursor_reset. (%s:%d)",__FILE__,__LINE__); + skygw_log_write(LE,"[%s] Error: NULL parameter.",__FUNCTION__); return; } CHK_SESCMD_CUR(scur); @@ -3971,7 +3998,7 @@ static bool execute_sescmd_history( sescmd_cursor_t* scur; if(bref == NULL) { - skygw_log_write(LE,"Error: NULL parameter passed to execute_sescmd_history. (%s:%d)",__FILE__,__LINE__); + skygw_log_write(LE,"[%s] Error: NULL parameter.",__FUNCTION__); return false; } CHK_BACKEND_REF(bref); @@ -4012,7 +4039,7 @@ static bool execute_sescmd_in_backend( GWBUF* buf; if(backend_ref == NULL) { - skygw_log_write(LE,"Error: NULL parameter passed to execute_sescmd_in_backend. (%s:%d)",__FILE__,__LINE__); + skygw_log_write(LE,"[%s] Error: NULL parameter.",__FUNCTION__); return false; } if (BREF_IS_CLOSED(backend_ref)) @@ -4121,7 +4148,7 @@ static bool sescmd_cursor_next( if(scur == NULL) { - skygw_log_write(LE,"Error: NULL parameter passed to sescmd_cursor_next. (%s:%d)",__FILE__,__LINE__); + skygw_log_write(LE,"[%s] Error: NULL parameter.",__FUNCTION__); return false; } @@ -5163,10 +5190,8 @@ static int router_handle_state_switch( srv->name, srv->port, STRSRVSTATUS(srv)))); - ses = dcb->session; - CHK_SESSION(ses); - rses = (ROUTER_CLIENT_SES *)dcb->session->router_session; - CHK_CLIENT_RSES(rses); + CHK_SESSION(((SESSION*)dcb->session)); + CHK_CLIENT_RSES(((ROUTER_CLIENT_SES *)dcb->session->router_session)); switch (reason) { case DCB_REASON_NOT_RESPONDING: diff --git a/server/modules/routing/schemarouter/schemarouter.c b/server/modules/routing/schemarouter/schemarouter.c index c141ff2a2..ed6eeeb55 100644 --- a/server/modules/routing/schemarouter/schemarouter.c +++ b/server/modules/routing/schemarouter/schemarouter.c @@ -2853,11 +2853,16 @@ int bref_cmp_current_load( return ((1000 * s1->stats.n_current_ops) - b1->weight) - ((1000 * s2->stats.n_current_ops) - b2->weight); } - + static void bref_clear_state( backend_ref_t* bref, bref_state_t state) { + if(bref == NULL) + { + skygw_log_write(LE,"[%s] Error: NULL parameter.",__FUNCTION__); + return; + } if (state != BREF_WAITING_RESULT) { bref->bref_state &= ~state; @@ -2866,10 +2871,10 @@ static void bref_clear_state( { int prev1; int prev2; - + /** Decrease waiter count */ prev1 = atomic_add(&bref->bref_num_result_wait, -1); - + if (prev1 <= 0) { atomic_add(&bref->bref_num_result_wait, 1); } @@ -2879,14 +2884,26 @@ static void bref_clear_state( prev2 = atomic_add( &bref->bref_backend->backend_server->stats.n_current_ops, -1); ss_dassert(prev2 > 0); - } + if(prev2 <= 0) + { + skygw_log_write(LE,"[%s] Error: negative current operation count in backend %s:%u", + __FUNCTION__, + &bref->bref_backend->backend_server->name, + &bref->bref_backend->backend_server->port); + } + } } } -static void bref_set_state( +static void bref_set_state( backend_ref_t* bref, bref_state_t state) { + if(bref == NULL) + { + skygw_log_write(LE,"[%s] Error: NULL parameter.",__FUNCTION__); + return; + } if (state != BREF_WAITING_RESULT) { bref->bref_state |= state; @@ -2895,15 +2912,28 @@ static void bref_set_state( { int prev1; int prev2; - + /** Increase waiter count */ prev1 = atomic_add(&bref->bref_num_result_wait, 1); ss_dassert(prev1 >= 0); - + if(prev1 < 0) + { + skygw_log_write(LE,"[%s] Error: negative number of connections waiting for results in backend %s:%u", + __FUNCTION__, + &bref->bref_backend->backend_server->name, + &bref->bref_backend->backend_server->port); + } /** Increase global operation count */ prev2 = atomic_add( &bref->bref_backend->backend_server->stats.n_current_ops, 1); - ss_dassert(prev2 >= 0); + ss_dassert(prev2 >= 0); + if(prev2 < 0) + { + skygw_log_write(LE,"[%s] Error: negative current operation count in backend %s:%u", + __FUNCTION__, + &bref->bref_backend->backend_server->name, + &bref->bref_backend->backend_server->port); + } } } diff --git a/utils/skygw_utils.cc b/utils/skygw_utils.cc index 5748cd613..26a8e8b88 100644 --- a/utils/skygw_utils.cc +++ b/utils/skygw_utils.cc @@ -1825,21 +1825,12 @@ int skygw_file_write( bool flush) { int rc; -#if !defined(LAPTOP_TEST) - int err = 0; size_t nwritten; int fd; static int writecount; -#else - struct timespec ts1; - ts1.tv_sec = 0; - ts1.tv_nsec = DISKWRITE_LATENCY*1000000; -#endif - + CHK_FILE(file); -#if defined(LAPTOP_TEST) - nanosleep(&ts1, NULL); -#else + nwritten = fwrite(data, nbytes, 1, file->sf_file); if (nwritten != 1) { @@ -1857,11 +1848,11 @@ int skygw_file_write( if (flush || writecount == FSYNCLIMIT) { fd = fileno(file->sf_file); - err = fflush(file->sf_file); - err = fsync(fd); + fflush(file->sf_file); + fsync(fd); writecount = 0; } -#endif + rc = 0; CHK_FILE(file); return_rc: