diff --git a/server/modules/protocol/httpd.c b/server/modules/protocol/httpd.c index daa73d538..5d4aaeb7f 100644 --- a/server/modules/protocol/httpd.c +++ b/server/modules/protocol/httpd.c @@ -411,9 +411,8 @@ int syseno = 0; if(syseno != 0){ char errbuf[STRERROR_BUFLEN]; - skygw_log_write_flush(LOGFILE_ERROR, - "Error: Failed to set socket options. Error %d: %s", - errno, strerror_r(errno, errbuf, sizeof(errbuf))); + MXS_ERROR("Failed to set socket options. Error %d: %s", + errno, strerror_r(errno, errbuf, sizeof(errbuf))); return 0; } /* set NONBLOCKING mode */ @@ -428,7 +427,7 @@ int syseno = 0; rc = listen(listener->fd, SOMAXCONN); if (rc == 0) { - LOGIF(LM, (skygw_log_write_flush(LOGFILE_MESSAGE,"Listening httpd connections at %s", config))); + MXS_NOTICE("Listening httpd connections at %s", config); } else { int eno = errno; errno = 0; diff --git a/server/modules/protocol/maxscaled.c b/server/modules/protocol/maxscaled.c index d18d99fb8..0c5fa6614 100644 --- a/server/modules/protocol/maxscaled.c +++ b/server/modules/protocol/maxscaled.c @@ -104,9 +104,7 @@ version() void ModuleInit() { - LOGIF(LT, (skygw_log_write( - LOGFILE_TRACE, - "Initialise MaxScaled Protocol module.\n"))); + MXS_INFO("Initialise MaxScaled Protocol module.");; } /** @@ -352,10 +350,7 @@ int rc; // socket options if (setsockopt(listener->fd, SOL_SOCKET, SO_REUSEADDR, (char *)&one, sizeof(one))) { - LOGIF(LE, (skygw_log_write( - LOGFILE_ERROR, - "Unable to set SO_REUSEADDR on maxscale listener." - ))); + MXS_ERROR("Unable to set SO_REUSEADDR on maxscale listener."); } // set NONBLOCKING mode setnonblocking(listener->fd); @@ -368,20 +363,14 @@ int rc; rc = listen(listener->fd, SOMAXCONN); if (rc == 0) { - LOGIF(LM, (skygw_log_write( - LOGFILE_MESSAGE, - "Listening maxscale connections at %s\n", - config))); + MXS_NOTICE("Listening maxscale connections at %s", config); } else { int eno = errno; errno = 0; char errbuf[STRERROR_BUFLEN]; - LOGIF(LE, (skygw_log_write( - LOGFILE_ERROR, - "Failed to start listening for maxscale admin connections " - "due error %d, %s\n\n", - eno, - strerror_r(eno, errbuf, sizeof(errbuf))))); + MXS_ERROR("Failed to start listening for maxscale admin connections " + "due error %d, %s", + eno, strerror_r(eno, errbuf, sizeof(errbuf))); return 0; } diff --git a/server/modules/protocol/mysql_backend.c b/server/modules/protocol/mysql_backend.c index e48c00f98..279a87981 100644 --- a/server/modules/protocol/mysql_backend.c +++ b/server/modules/protocol/mysql_backend.c @@ -140,12 +140,10 @@ static MYSQL_session* gw_get_shared_session_auth_info( if (dcb->session->state != SESSION_STATE_ALLOC && dcb->session->state != SESSION_STATE_DUMMY) { auth_info = dcb->session->data; } else { - LOGIF(LE, (skygw_log_write_flush( - LOGFILE_ERROR, - "%lu [gw_get_shared_session_auth_info] Couldn't get " - "session authentication info. Session in a wrong state %d.", - pthread_self(), - dcb->session->state))); + MXS_ERROR("%lu [gw_get_shared_session_auth_info] Couldn't get " + "session authentication info. Session in a wrong state %d.", + pthread_self(), + dcb->session->state); } spinlock_release(&dcb->session->ses_lock); @@ -184,15 +182,13 @@ static int gw_read_backend_event(DCB *dcb) { backend_protocol = (MySQLProtocol *) dcb->protocol; CHK_PROTOCOL(backend_protocol); - LOGIF(LD, (skygw_log_write( - LOGFILE_DEBUG, - "%lu [gw_read_backend_event] Read dcb %p fd %d protocol " - "state %d, %s.", - pthread_self(), - dcb, - dcb->fd, - backend_protocol->protocol_auth_state, - STRPROTOCOLSTATE(backend_protocol->protocol_auth_state)))); + MXS_DEBUG("%lu [gw_read_backend_event] Read dcb %p fd %d protocol " + "state %d, %s.", + pthread_self(), + dcb, + dcb->fd, + backend_protocol->protocol_auth_state, + STRPROTOCOLSTATE(backend_protocol->protocol_auth_state)); /* backend is connected: @@ -220,13 +216,11 @@ static int gw_read_backend_event(DCB *dcb) { { backend_protocol->protocol_auth_state = MYSQL_HANDSHAKE_FAILED; - LOGIF(LD, (skygw_log_write( - LOGFILE_DEBUG, - "%lu [gw_read_backend_event] after " - "gw_read_backend_handshake, fd %d, " - "state = MYSQL_HANDSHAKE_FAILED.", - pthread_self(), - backend_protocol->owner_dcb->fd))); + MXS_DEBUG("%lu [gw_read_backend_event] after " + "gw_read_backend_handshake, fd %d, " + "state = MYSQL_HANDSHAKE_FAILED.", + pthread_self(), + backend_protocol->owner_dcb->fd); } else { @@ -241,13 +235,11 @@ static int gw_read_backend_event(DCB *dcb) { backend_protocol) != 0) { backend_protocol->protocol_auth_state = MYSQL_AUTH_FAILED; - LOGIF(LD, (skygw_log_write( - LOGFILE_DEBUG, - "%lu [gw_read_backend_event] after " - "gw_send_authentication_to_backend " - "fd %d, state = MYSQL_AUTH_FAILED.", - pthread_self(), - backend_protocol->owner_dcb->fd))); + MXS_DEBUG("%lu [gw_read_backend_event] after " + "gw_send_authentication_to_backend " + "fd %d, state = MYSQL_AUTH_FAILED.", + pthread_self(), + backend_protocol->owner_dcb->fd); } else { @@ -303,46 +295,38 @@ static int gw_read_backend_event(DCB *dcb) { switch (receive_rc) { case -1: backend_protocol->protocol_auth_state = MYSQL_AUTH_FAILED; - LOGIF(LD, (skygw_log_write( - LOGFILE_DEBUG, - "%lu [gw_read_backend_event] after " - "gw_receive_backend_authentication " - "fd %d, state = MYSQL_AUTH_FAILED.", - pthread_self(), - backend_protocol->owner_dcb->fd))); + MXS_DEBUG("%lu [gw_read_backend_event] after " + "gw_receive_backend_authentication " + "fd %d, state = MYSQL_AUTH_FAILED.", + pthread_self(), + backend_protocol->owner_dcb->fd); - LOGIF(LE, (skygw_log_write_flush( - LOGFILE_ERROR, - "Error : Backend server didn't " - "accept authentication for user " - "%s.", - current_session->user))); + MXS_ERROR("Backend server didn't " + "accept authentication for user " + "%s.", + current_session->user); break; case 1: backend_protocol->protocol_auth_state = MYSQL_IDLE; - LOGIF(LD, (skygw_log_write_flush( - LOGFILE_DEBUG, - "%lu [gw_read_backend_event] " - "gw_receive_backend_auth succeed. " - "dcb %p fd %d, user %s.", - pthread_self(), - dcb, - dcb->fd, - current_session->user))); + MXS_DEBUG("%lu [gw_read_backend_event] " + "gw_receive_backend_auth succeed. " + "dcb %p fd %d, user %s.", + pthread_self(), + dcb, + dcb->fd, + current_session->user); break; default: ss_dassert(receive_rc == 0); - LOGIF(LD, (skygw_log_write_flush( - LOGFILE_DEBUG, - "%lu [gw_read_backend_event] " - "gw_receive_backend_auth read " - "successfully " - "nothing. dcb %p fd %d, user %s.", - pthread_self(), - dcb, - dcb->fd, - current_session->user))); + MXS_DEBUG("%lu [gw_read_backend_event] " + "gw_receive_backend_auth read " + "successfully " + "nothing. dcb %p fd %d, user %s.", + pthread_self(), + dcb, + dcb->fd, + current_session->user); rc = 0; goto return_with_lock; break; @@ -376,14 +360,12 @@ static int gw_read_backend_event(DCB *dcb) { service_refresh_users(dcb->session->service); } #if defined(SS_DEBUG) - LOGIF(LD, (skygw_log_write( - LOGFILE_DEBUG, - "%lu [gw_read_backend_event] " - "calling handleError. Backend " - "DCB %p, session %p", - pthread_self(), - dcb, - dcb->session))); + MXS_DEBUG("%lu [gw_read_backend_event] " + "calling handleError. Backend " + "DCB %p, session %p", + pthread_self(), + dcb, + dcb->session); #endif errbuf = mysql_create_custom_error( @@ -426,14 +408,12 @@ static int gw_read_backend_event(DCB *dcb) { else { ss_dassert(backend_protocol->protocol_auth_state == MYSQL_IDLE); - LOGIF(LD, (skygw_log_write_flush( - LOGFILE_DEBUG, - "%lu [gw_read_backend_event] " - "gw_receive_backend_auth succeed. Fd %d, " - "user %s.", - pthread_self(), - dcb->fd, - current_session->user))); + MXS_DEBUG("%lu [gw_read_backend_event] " + "gw_receive_backend_auth succeed. Fd %d, " + "user %s.", + pthread_self(), + dcb->fd, + current_session->user); /* check the delay queue and flush the data */ if (dcb->delayq) @@ -468,9 +448,7 @@ static int gw_read_backend_event(DCB *dcb) { GWBUF* errbuf; bool succp; #if defined(SS_DEBUG) - LOGIF(LE, (skygw_log_write_flush( - LOGFILE_ERROR, - "Backend read error handling #2."))); + MXS_ERROR("Backend read error handling #2."); #endif errbuf = mysql_create_custom_error( 1, @@ -555,13 +533,11 @@ static int gw_read_backend_event(DCB *dcb) { } if (!read_buffer) { - LOGIF(LM, (skygw_log_write_flush( - LOGFILE_MESSAGE, - "%lu [gw_read_backend_event] " - "Read buffer unexpectedly null, even though response " - "not marked as complete. User: %s", - pthread_self(), - current_session->user))); + MXS_NOTICE("%lu [gw_read_backend_event] " + "Read buffer unexpectedly null, even though response " + "not marked as complete. User: %s", + pthread_self(), + current_session->user); rc = 0; goto return_rc; } @@ -650,34 +626,28 @@ static int gw_write_backend_event(DCB *dcb) { 0, "Writing to backend failed due invalid Maxscale " "state."); - LOGIF(LD, (skygw_log_write( - LOGFILE_DEBUG, - "%lu [gw_write_backend_event] Write to backend " - "dcb %p fd %d " - "failed due invalid state %s.", - pthread_self(), - dcb, - dcb->fd, - STRDCBSTATE(dcb->state)))); + MXS_DEBUG("%lu [gw_write_backend_event] Write to backend " + "dcb %p fd %d " + "failed due invalid state %s.", + pthread_self(), + dcb, + dcb->fd, + STRDCBSTATE(dcb->state)); - LOGIF(LE, (skygw_log_write_flush( - LOGFILE_ERROR, - "Error : Attempt to write buffered data to backend " - "failed " - "due internal inconsistent state."))); + MXS_ERROR("Attempt to write buffered data to backend " + "failed " + "due internal inconsistent state."); rc = 0; } } else { - LOGIF(LD, (skygw_log_write( - LOGFILE_DEBUG, - "%lu [gw_write_backend_event] Dcb %p in state %s " - "but there's nothing to write either.", - pthread_self(), - dcb, - STRDCBSTATE(dcb->state)))); + MXS_DEBUG("%lu [gw_write_backend_event] Dcb %p in state %s " + "but there's nothing to write either.", + pthread_self(), + dcb, + STRDCBSTATE(dcb->state)); rc = 1; } goto return_rc; @@ -691,14 +661,12 @@ static int gw_write_backend_event(DCB *dcb) { dcb_drain_writeq(dcb); rc = 1; return_rc: - LOGIF(LD, (skygw_log_write( - LOGFILE_DEBUG, - "%lu [gw_write_backend_event] " - "wrote to dcb %p fd %d, return %d", - pthread_self(), - dcb, - dcb->fd, - rc))); + MXS_DEBUG("%lu [gw_write_backend_event] " + "wrote to dcb %p fd %d, return %d", + pthread_self(), + dcb, + dcb->fd, + rc); return rc; } @@ -726,12 +694,12 @@ gw_MySQLWrite_backend(DCB *dcb, GWBUF *queue) switch (backend_protocol->protocol_auth_state) { case MYSQL_HANDSHAKE_FAILED: case MYSQL_AUTH_FAILED: - LOGIF(LE, (skygw_log_write_flush(LOGFILE_ERROR, - "Error : Unable to write to backend '%s' due to " - "%s failure. Server in state %s.", - dcb->server->unique_name, - backend_protocol->protocol_auth_state == MYSQL_HANDSHAKE_FAILED ? "handshake" : "authentication", - STRSRVSTATUS(dcb->server)))); + MXS_ERROR("Unable to write to backend '%s' due to " + "%s failure. Server in state %s.", + dcb->server->unique_name, + backend_protocol->protocol_auth_state == MYSQL_HANDSHAKE_FAILED ? + "handshake" : "authentication", + STRSRVSTATUS(dcb->server)); /** Consume query buffer */ while ((queue = gwbuf_consume( queue, @@ -746,14 +714,12 @@ gw_MySQLWrite_backend(DCB *dcb, GWBUF *queue) uint8_t* ptr = GWBUF_DATA(queue); int cmd = MYSQL_GET_COMMAND(ptr); - LOGIF(LD, (skygw_log_write( - LOGFILE_DEBUG, - "%lu [gw_MySQLWrite_backend] write to dcb %p " - "fd %d protocol state %s.", - pthread_self(), - dcb, - dcb->fd, - STRPROTOCOLSTATE(backend_protocol->protocol_auth_state)))); + MXS_DEBUG("%lu [gw_MySQLWrite_backend] write to dcb %p " + "fd %d protocol state %s.", + pthread_self(), + dcb, + dcb->fd, + STRPROTOCOLSTATE(backend_protocol->protocol_auth_state)); spinlock_release(&dcb->authlock); /** @@ -777,14 +743,12 @@ gw_MySQLWrite_backend(DCB *dcb, GWBUF *queue) default: { - LOGIF(LD, (skygw_log_write( - LOGFILE_DEBUG, - "%lu [gw_MySQLWrite_backend] delayed write to " - "dcb %p fd %d protocol state %s.", - pthread_self(), - dcb, - dcb->fd, - STRPROTOCOLSTATE(backend_protocol->protocol_auth_state)))); + MXS_DEBUG("%lu [gw_MySQLWrite_backend] delayed write to " + "dcb %p fd %d protocol state %s.", + pthread_self(), + dcb, + dcb->fd, + STRPROTOCOLSTATE(backend_protocol->protocol_auth_state)); /** * In case of session commands, store command to DCB's * protocol struct. @@ -859,11 +823,9 @@ static int gw_error_backend_event(DCB *dcb) if (error != 0) { char errbuf[STRERROR_BUFLEN]; - LOGIF(LE, (skygw_log_write_flush( - LOGFILE_ERROR, - "DCB in state %s got error '%s'.", - STRDCBSTATE(dcb->state), - strerror_r(error, errbuf, sizeof(errbuf))))); + MXS_ERROR("DCB in state %s got error '%s'.", + STRDCBSTATE(dcb->state), + strerror_r(error, errbuf, sizeof(errbuf))); } } return 1; @@ -900,10 +862,8 @@ static int gw_error_backend_event(DCB *dcb) if (error != 0) { char errbuf[STRERROR_BUFLEN]; - LOGIF(LE, (skygw_log_write_flush( - LOGFILE_ERROR, - "Error '%s' in session that is not ready for routing.", - strerror_r(error, errbuf, sizeof(errbuf))))); + MXS_ERROR("Error '%s' in session that is not ready for routing.", + strerror_r(error, errbuf, sizeof(errbuf))); } } gwbuf_free(errbuf); @@ -911,9 +871,7 @@ static int gw_error_backend_event(DCB *dcb) } #if defined(SS_DEBUG) - LOGIF(LE, (skygw_log_write_flush( - LOGFILE_ERROR, - "Backend error event handling."))); + MXS_INFO("Backend error event handling."); #endif router->handleError(router_instance, rsession, @@ -965,16 +923,11 @@ static int gw_create_backend_connection( ss_dassert(protocol != NULL); if (protocol == NULL) { - LOGIF(LD, (skygw_log_write( - LOGFILE_DEBUG, - "%lu [gw_create_backend_connection] Failed to create " - "protocol object for backend connection.", - pthread_self()))); - LOGIF(LE, (skygw_log_write_flush( - LOGFILE_ERROR, - "Error: Failed to create " - "protocol object for backend connection."))); - goto return_fd; + MXS_DEBUG("%lu [gw_create_backend_connection] Failed to create " + "protocol object for backend connection.", + pthread_self()); + MXS_ERROR("Failed to create protocol object for backend connection."); + goto return_fd; } /** Copy client flags to backend protocol */ @@ -1004,45 +957,39 @@ static int gw_create_backend_connection( ss_dassert(fd > 0); protocol->fd = fd; protocol->protocol_auth_state = MYSQL_CONNECTED; - LOGIF(LD, (skygw_log_write( - LOGFILE_DEBUG, - "%lu [gw_create_backend_connection] Established " - "connection to %s:%i, protocol fd %d client " - "fd %d.", - pthread_self(), - server->name, - server->port, - protocol->fd, - session->client->fd))); + MXS_DEBUG("%lu [gw_create_backend_connection] Established " + "connection to %s:%i, protocol fd %d client " + "fd %d.", + pthread_self(), + server->name, + server->port, + protocol->fd, + session->client->fd); break; case 1: ss_dassert(fd > 0); protocol->protocol_auth_state = MYSQL_PENDING_CONNECT; protocol->fd = fd; - LOGIF(LD, (skygw_log_write( - LOGFILE_DEBUG, - "%lu [gw_create_backend_connection] Connection " - "pending to %s:%i, protocol fd %d client fd %d.", - pthread_self(), - server->name, - server->port, - protocol->fd, - session->client->fd))); + MXS_DEBUG("%lu [gw_create_backend_connection] Connection " + "pending to %s:%i, protocol fd %d client fd %d.", + pthread_self(), + server->name, + server->port, + protocol->fd, + session->client->fd); break; default: ss_dassert(fd == -1); ss_dassert(protocol->protocol_auth_state == MYSQL_ALLOC); - LOGIF(LD, (skygw_log_write( - LOGFILE_DEBUG, - "%lu [gw_create_backend_connection] Connection " - "failed to %s:%i, protocol fd %d client fd %d.", - pthread_self(), - server->name, - server->port, - protocol->fd, - session->client->fd))); + MXS_DEBUG("%lu [gw_create_backend_connection] Connection " + "failed to %s:%i, protocol fd %d client fd %d.", + pthread_self(), + server->name, + server->port, + protocol->fd, + session->client->fd); break; } /*< switch */ @@ -1123,11 +1070,9 @@ gw_backend_hangup(DCB *dcb) if (error != 0 && ses_state != SESSION_STATE_STOPPING) { char errbuf[STRERROR_BUFLEN]; - LOGIF(LE, (skygw_log_write_flush( - LOGFILE_ERROR, - "Hangup in session that is not ready for routing, " - "Error reported is '%s'.", - strerror_r(error, errbuf, sizeof(errbuf))))); + MXS_ERROR("Hangup in session that is not ready for routing, " + "Error reported is '%s'.", + strerror_r(error, errbuf, sizeof(errbuf))); } } gwbuf_free(errbuf); @@ -1142,9 +1087,7 @@ gw_backend_hangup(DCB *dcb) #if defined(SS_DEBUG) if(ses_state != SESSION_STATE_STOPPING) { - LOGIF(LE, (skygw_log_write_flush( - LOGFILE_ERROR, - "Backend hangup error handling."))); + MXS_ERROR("Backend hangup error handling."); } #endif @@ -1160,9 +1103,7 @@ gw_backend_hangup(DCB *dcb) if (!succp) { #if defined(SS_DEBUG) - LOGIF(LE, (skygw_log_write_flush( - LOGFILE_ERROR, - "Backend hangup -> closing session."))); + MXS_ERROR("Backend hangup -> closing session."); #endif spinlock_acquire(&session->ses_lock); session->state = SESSION_STATE_STOPPING; @@ -1188,9 +1129,8 @@ gw_backend_close(DCB *dcb) CHK_DCB(dcb); session = dcb->session; - LOGIF(LD, (skygw_log_write(LOGFILE_DEBUG, - "%lu [gw_backend_close]", - pthread_self()))); + MXS_DEBUG("%lu [gw_backend_close]", + pthread_self()); quitbuf = mysql_create_com_quit(NULL, 0); gwbuf_set_type(quitbuf, GWBUF_TYPE_MYSQL); @@ -1326,9 +1266,7 @@ static int backend_write_delayqueue(DCB *dcb) router_instance = session->service->router_instance; rsession = session->router_session; #if defined(SS_DEBUG) - LOGIF(LE, (skygw_log_write_flush( - LOGFILE_ERROR, - "Backend write delayqueue error handling."))); + MXS_INFO("Backend write delayqueue error handling."); #endif errbuf = mysql_create_custom_error( 1, @@ -1488,11 +1426,9 @@ static int gw_change_user( auth_ret); if (message == NULL) { - LOGIF(LE, (skygw_log_write_flush( - LOGFILE_ERROR, - "Error : Creating error message failed."))); - rv = 0; - goto retblock; + MXS_ERROR("Creating error message failed."); + rv = 0; + goto retblock; } /** * Add command to backend's protocol, create artificial reply @@ -1561,13 +1497,11 @@ static GWBUF* process_response_data ( srvcmd = protocol_get_srv_command(p, false); - LOGIF(LD, (skygw_log_write( - LOGFILE_DEBUG, - "%lu [process_response_data] Read command %s for DCB %p fd %d.", - pthread_self(), - STRPACKETTYPE(srvcmd), - dcb, - dcb->fd))); + MXS_DEBUG("%lu [process_response_data] Read command %s for DCB %p fd %d.", + pthread_self(), + STRPACKETTYPE(srvcmd), + dcb, + dcb->fd); /** * Read values from protocol structure, fails if values are * uninitialized. @@ -1667,9 +1601,11 @@ static GWBUF* process_response_data ( wait for more data from the backend server.*/ if(readbuf == NULL || GWBUF_LENGTH(readbuf) < 3) { - skygw_log_write(LD," %lu [%s] Read %d packets. Waiting for %d more packets for a total of %d packets.", - pthread_self(),__FUNCTION__,initial_packets - npackets_left, - npackets_left,initial_packets); + MXS_DEBUG("%lu [%s] Read %d packets. Waiting for %d more " + "packets for a total of %d packets.", + pthread_self(),__FUNCTION__, + initial_packets - npackets_left, + npackets_left,initial_packets); /** Store the already read data into the readqueue of the DCB * and restore the response status to the initial number of packets */ diff --git a/server/modules/protocol/mysql_client.c b/server/modules/protocol/mysql_client.c index d92b4fc91..8993fc802 100644 --- a/server/modules/protocol/mysql_client.c +++ b/server/modules/protocol/mysql_client.c @@ -480,16 +480,16 @@ static int gw_mysql_do_authentication(DCB *dcb, GWBUF **buf) { /** Client didn't requested SSL when SSL mode was required*/ if(!ssl && protocol->owner_dcb->service->ssl_mode == SSL_REQUIRED) { - LOGIF(LT,(skygw_log_write(LT,"User %s@%s connected to service '%s' without SSL when SSL was required.", - protocol->owner_dcb->user, - protocol->owner_dcb->remote, - protocol->owner_dcb->service->name))); + MXS_INFO("User %s@%s connected to service '%s' without SSL when SSL was required.", + protocol->owner_dcb->user, + protocol->owner_dcb->remote, + protocol->owner_dcb->service->name); return MYSQL_FAILED_AUTH_SSL; } if(LOG_IS_ENABLED(LT) && ssl) { - skygw_log_write(LT,"User %s@%s connected to service '%s' with SSL.", + MXS_INFO("User %s@%s connected to service '%s' with SSL.", protocol->owner_dcb->user, protocol->owner_dcb->remote, protocol->owner_dcb->service->name); @@ -521,7 +521,7 @@ static int gw_mysql_do_authentication(DCB *dcb, GWBUF **buf) { client_auth_packet = GWBUF_DATA(queue); client_auth_packet_size = gwbuf_length(queue); *buf = queue; - LOGIF(LD,(skygw_log_write(LD,"%lu Read %d bytes from fd %d",pthread_self(),bytes,dcb->fd))); + MXS_DEBUG("%lu Read %d bytes from fd %d",pthread_self(),bytes,dcb->fd); } } @@ -562,7 +562,7 @@ static int gw_mysql_do_authentication(DCB *dcb, GWBUF **buf) { * Decode the token and check the password * Note: if auth_token_len == 0 && auth_token == NULL, user is without password */ - skygw_log_write(LOGFILE_DEBUG,"Receiving connection from '%s' to database '%s'.",username,database); + MXS_DEBUG("Receiving connection from '%s' to database '%s'.",username,database); auth_ret = gw_check_mysql_scramble_data(dcb, auth_token, auth_token_len, @@ -599,15 +599,15 @@ static int gw_mysql_do_authentication(DCB *dcb, GWBUF **buf) { } else if (dcb->service->log_auth_warnings) { - skygw_log_write(LM, "%s: login attempt for user '%s', authentication failed.", - dcb->service->name, username); + MXS_NOTICE("%s: login attempt for user '%s', authentication failed.", + dcb->service->name, username); if (dcb->ipv4.sin_addr.s_addr == 0x0100007F && !dcb->service->localhost_match_wildcard_host) { - skygw_log_write_flush(LM, "If you have a wildcard grant that covers" - " this address, try adding " - "'localhost_match_wildcard_host=true' for " - "service '%s'. ", dcb->service->name); + MXS_NOTICE("If you have a wildcard grant that covers" + " this address, try adding " + "'localhost_match_wildcard_host=true' for " + "service '%s'. ", dcb->service->name); } } @@ -676,8 +676,8 @@ int gw_read_client_event( CHK_PROTOCOL(protocol); #ifdef SS_DEBUG - skygw_log_write(LD,"[gw_read_client_event] Protocol state: %s", - gw_mysql_protocol_state2string(protocol->protocol_auth_state)); + MXS_DEBUG("[gw_read_client_event] Protocol state: %s", + gw_mysql_protocol_state2string(protocol->protocol_auth_state)); #endif @@ -698,8 +698,7 @@ int gw_read_client_event( ioctl(dcb->fd,FIONREAD,&b); if(b == 0) { - skygw_log_write(LD, - "[gw_read_client_event] No data in socket after SSL auth"); + MXS_DEBUG("[gw_read_client_event] No data in socket after SSL auth"); return 0; } break; @@ -883,13 +882,11 @@ int gw_read_client_event( else { protocol->protocol_auth_state = MYSQL_AUTH_FAILED; - LOGIF(LD, (skygw_log_write( - LOGFILE_DEBUG, - "%lu [gw_read_client_event] session " - "creation failed. fd %d, " - "state = MYSQL_AUTH_FAILED.", - pthread_self(), - protocol->owner_dcb->fd))); + MXS_DEBUG("%lu [gw_read_client_event] session " + "creation failed. fd %d, " + "state = MYSQL_AUTH_FAILED.", + pthread_self(), + protocol->owner_dcb->fd); /** Send ERR 1045 to client */ mysql_send_auth_error( @@ -927,13 +924,11 @@ int gw_read_client_event( if (fail_str) free(fail_str); - LOGIF(LD, (skygw_log_write( - LOGFILE_DEBUG, - "%lu [gw_read_client_event] after " - "gw_mysql_do_authentication, fd %d, " - "state = MYSQL_AUTH_FAILED.", - pthread_self(), - protocol->owner_dcb->fd))); + MXS_DEBUG("%lu [gw_read_client_event] after " + "gw_mysql_do_authentication, fd %d, " + "state = MYSQL_AUTH_FAILED.", + pthread_self(), + protocol->owner_dcb->fd); /** * Release MYSQL_session since it is not used anymore. */ @@ -983,13 +978,11 @@ int gw_read_client_event( else { protocol->protocol_auth_state = MYSQL_AUTH_FAILED; - LOGIF(LD, (skygw_log_write( - LOGFILE_DEBUG, - "%lu [gw_read_client_event] session " - "creation failed. fd %d, " - "state = MYSQL_AUTH_FAILED.", - pthread_self(), - protocol->owner_dcb->fd))); + MXS_DEBUG("%lu [gw_read_client_event] session " + "creation failed. fd %d, " + "state = MYSQL_AUTH_FAILED.", + pthread_self(), + protocol->owner_dcb->fd); /** Send ERR 1045 to client */ mysql_send_auth_error( @@ -1027,13 +1020,11 @@ int gw_read_client_event( if (fail_str) free(fail_str); - LOGIF(LD, (skygw_log_write( - LOGFILE_DEBUG, - "%lu [gw_read_client_event] after " - "gw_mysql_do_authentication, fd %d, " - "state = MYSQL_AUTH_FAILED.", - pthread_self(), - protocol->owner_dcb->fd))); + MXS_DEBUG("%lu [gw_read_client_event] after " + "gw_mysql_do_authentication, fd %d, " + "state = MYSQL_AUTH_FAILED.", + pthread_self(), + protocol->owner_dcb->fd); /** * Release MYSQL_session since it is not used anymore. */ @@ -1153,10 +1144,8 @@ int gw_read_client_event( */ if (!succp) { - LOGIF(LE, (skygw_log_write_flush( - LOGFILE_ERROR, - "Error : Routing the query failed. " - "Session will be closed."))); + MXS_ERROR("Routing the query failed. " + "Session will be closed."); } while (read_buffer) @@ -1168,8 +1157,8 @@ int gw_read_client_event( } else { - skygw_log_write_flush(LT,"Session received a query in state %s", - STRSESSIONSTATE(ses_state)); + MXS_INFO("Session received a query in state %s", + STRSESSIONSTATE(ses_state)); while((read_buffer = GWBUF_CONSUME_ALL(read_buffer)) != NULL); goto return_rc; } @@ -1328,10 +1317,9 @@ int gw_MySQLListener(DCB *listen_dcb, if ((l_so = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) { char errbuf[STRERROR_BUFLEN]; - skygw_log_write(LE, - "Error: Can't create UNIX socket: %i, %s", - errno, - strerror_r(errno, errbuf, sizeof(errbuf))); + MXS_ERROR("Can't create UNIX socket: %i, %s", + errno, + strerror_r(errno, errbuf, sizeof(errbuf))); return 0; } memset(&local_addr, 0, sizeof(local_addr)); @@ -1348,7 +1336,7 @@ int gw_MySQLListener(DCB *listen_dcb, */ if (!parse_bindconfig(config_bind, 4406, &serv_addr)) { - skygw_log_write(LE, "Error in parse_bindconfig for [%s]", config_bind); + MXS_ERROR("Error in parse_bindconfig for [%s]", config_bind); return 0; } @@ -1356,10 +1344,9 @@ int gw_MySQLListener(DCB *listen_dcb, if ((l_so = socket(AF_INET, SOCK_STREAM, 0)) < 0) { char errbuf[STRERROR_BUFLEN]; - skygw_log_write(LE, - "Error: Can't create socket: %i, %s", - errno, - strerror_r(errno, errbuf, sizeof(errbuf))); + MXS_ERROR("Can't create socket: %i, %s", + errno, + strerror_r(errno, errbuf, sizeof(errbuf))); return 0; } @@ -1373,10 +1360,9 @@ int gw_MySQLListener(DCB *listen_dcb, if (setsockopt(l_so, SOL_SOCKET, SO_REUSEADDR, (char *) &one, sizeof(one)) != 0) { char errbuf[STRERROR_BUFLEN]; - LOGIF(LE, (skygw_log_write_flush(LOGFILE_ERROR, - "Error: Failed to set socket options. Error %d: %s", - errno, - strerror_r(errno, errbuf, sizeof(errbuf))))); + MXS_ERROR("Failed to set socket options. Error %d: %s", + errno, + strerror_r(errno, errbuf, sizeof(errbuf))); } if (is_tcp) @@ -1384,16 +1370,15 @@ int gw_MySQLListener(DCB *listen_dcb, char errbuf[STRERROR_BUFLEN]; if (setsockopt(l_so, IPPROTO_TCP, TCP_NODELAY, (char *) &one, sizeof(one)) != 0) { - LOGIF(LE, (skygw_log_write_flush(LOGFILE_ERROR, - "Error: Failed to set socket options. Error %d: %s", - errno, - strerror_r(errno, errbuf, sizeof(errbuf))))); + MXS_ERROR("Failed to set socket options. Error %d: %s", + errno, + strerror_r(errno, errbuf, sizeof(errbuf))); } } // set NONBLOCKING mode if (setnonblocking(l_so) != 0) { - skygw_log_write(LE, "Error: Failed to set socket to non-blocking mode."); + MXS_ERROR("Failed to set socket to non-blocking mode."); close(l_so); return 0; } @@ -1406,18 +1391,17 @@ int gw_MySQLListener(DCB *listen_dcb, if ((rc == -1) && (errno != ENOENT)) { char errbuf[STRERROR_BUFLEN]; - skygw_log_write(LE, "Error: Failed to unlink Unix Socket %s: %d %s", - config_bind, errno, strerror_r(errno, errbuf, sizeof(errbuf))); + MXS_ERROR("Failed to unlink Unix Socket %s: %d %s", + config_bind, errno, strerror_r(errno, errbuf, sizeof(errbuf))); } if (bind(l_so, (struct sockaddr *) &local_addr, sizeof(local_addr)) < 0) { char errbuf[STRERROR_BUFLEN]; - skygw_log_write(LE, - "Error: Failed to bind to UNIX Domain socket '%s': %i, %s", - config_bind, - errno, - strerror_r(errno, errbuf, sizeof(errbuf))); + MXS_ERROR("Failed to bind to UNIX Domain socket '%s': %i, %s", + config_bind, + errno, + strerror_r(errno, errbuf, sizeof(errbuf))); close(l_so); return 0; } @@ -1426,31 +1410,28 @@ int gw_MySQLListener(DCB *listen_dcb, if (chmod(config_bind, 0777) < 0) { char errbuf[STRERROR_BUFLEN]; - skygw_log_write(LE, - "Error: Failed to change permissions on UNIX Domain socket '%s': %i, %s", - config_bind, - errno, - strerror_r(errno, errbuf, sizeof(errbuf))); + MXS_ERROR("Failed to change permissions on UNIX Domain socket '%s': %i, %s", + config_bind, + errno, + strerror_r(errno, errbuf, sizeof(errbuf))); } - break; case AF_INET: if (bind(l_so, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0) { char errbuf[STRERROR_BUFLEN]; - skygw_log_write(LE, - "Error: Failed to bind on '%s': %i, %s", - config_bind, - errno, - strerror_r(errno, errbuf, sizeof(errbuf))); + MXS_ERROR("Failed to bind on '%s': %i, %s", + config_bind, + errno, + strerror_r(errno, errbuf, sizeof(errbuf))); close(l_so); return 0; } break; default: - skygw_log_write(LE, "Error: Socket Family %i not supported\n", current_addr->sa_family); + MXS_ERROR("Socket Family %i not supported\n", current_addr->sa_family); close(l_so); return 0; } @@ -1458,16 +1439,15 @@ int gw_MySQLListener(DCB *listen_dcb, if (listen(l_so, 10 * SOMAXCONN) != 0) { char errbuf[STRERROR_BUFLEN]; - skygw_log_write(LE, - "Failed to start listening on '%s': %d, %s", - config_bind, - errno, - strerror_r(errno, errbuf, sizeof(errbuf))); + MXS_ERROR("Failed to start listening on '%s': %d, %s", + config_bind, + errno, + strerror_r(errno, errbuf, sizeof(errbuf))); close(l_so); return 0; } - LOGIF(LM, (skygw_log_write_flush(LOGFILE_MESSAGE, "Listening MySQL connections at %s", config_bind))); + MXS_NOTICE("Listening MySQL connections at %s", config_bind); // assign l_so to dcb listen_dcb->fd = l_so; @@ -1475,9 +1455,8 @@ int gw_MySQLListener(DCB *listen_dcb, // add listening socket to poll structure if (poll_add_dcb(listen_dcb) != 0) { - skygw_log_write(LE, - "MaxScale encountered system limit while " - "attempting to register on an epoll instance."); + MXS_ERROR("MaxScale encountered system limit while " + "attempting to register on an epoll instance."); return 0; } #if defined(FAKE_CODE) @@ -1560,23 +1539,19 @@ int gw_MySQLAccept(DCB *listener) * (EMFILE) max. number of files limit. */ char errbuf[STRERROR_BUFLEN]; - LOGIF(LD, (skygw_log_write( - LOGFILE_DEBUG, - "%lu [gw_MySQLAccept] Error %d, %s. ", - pthread_self(), - eno, - strerror_r(eno, errbuf, sizeof(errbuf))))); + MXS_DEBUG("%lu [gw_MySQLAccept] Error %d, %s. ", + pthread_self(), + eno, + strerror_r(eno, errbuf, sizeof(errbuf))); if (i == 0) { char errbuf[STRERROR_BUFLEN]; - LOGIF(LE, (skygw_log_write_flush( - LOGFILE_ERROR, - "Error %d, %s. " - "Failed to accept new client " - "connection.", - eno, - strerror_r(eno, errbuf, sizeof(errbuf))))); + MXS_ERROR("Error %d, %s. " + "Failed to accept new client " + "connection.", + eno, + strerror_r(eno, errbuf, sizeof(errbuf))); } i++; ts1.tv_nsec = 100*i*i*1000000; @@ -1594,18 +1569,14 @@ int gw_MySQLAccept(DCB *listener) * Other error. */ char errbuf[STRERROR_BUFLEN]; - LOGIF(LD, (skygw_log_write( - LOGFILE_DEBUG, - "%lu [gw_MySQLAccept] Error %d, %s.", - pthread_self(), - eno, - strerror_r(eno, errbuf, sizeof(errbuf))))); - LOGIF(LE, (skygw_log_write_flush( - LOGFILE_ERROR, - "Error : Failed to accept new client " - "connection due to %d, %s.", - eno, - strerror_r(eno, errbuf, sizeof(errbuf))))); + MXS_DEBUG("%lu [gw_MySQLAccept] Error %d, %s.", + pthread_self(), + eno, + strerror_r(eno, errbuf, sizeof(errbuf))); + MXS_ERROR("Failed to accept new client " + "connection due to %d, %s.", + eno, + strerror_r(eno, errbuf, sizeof(errbuf))); rc = 1; goto return_rc; } /* if (eno == ..) */ @@ -1615,11 +1586,9 @@ int gw_MySQLAccept(DCB *listener) listener->stats.n_accepts++; #if defined(SS_DEBUG) - LOGIF(LD, (skygw_log_write_flush( - LOGFILE_DEBUG, - "%lu [gw_MySQLAccept] Accepted fd %d.", - pthread_self(), - c_sock))); + MXS_DEBUG("%lu [gw_MySQLAccept] Accepted fd %d.", + pthread_self(), + c_sock); #endif /* SS_DEBUG */ #if defined(FAKE_CODE) conn_open[c_sock] = true; @@ -1629,26 +1598,25 @@ int gw_MySQLAccept(DCB *listener) char errbuf[STRERROR_BUFLEN]; if((syseno = setsockopt(c_sock, SOL_SOCKET, SO_SNDBUF, &sendbuf, optlen)) != 0){ - LOGIF(LE, (skygw_log_write_flush(LOGFILE_ERROR,"Error: Failed to set socket options. Error %d: %s", errno, strerror_r(errno, errbuf, sizeof(errbuf))))); + MXS_ERROR("Failed to set socket options. Error %d: %s", + errno, strerror_r(errno, errbuf, sizeof(errbuf))); } sendbuf = GW_CLIENT_SO_RCVBUF; if((syseno = setsockopt(c_sock, SOL_SOCKET, SO_RCVBUF, &sendbuf, optlen)) != 0){ - LOGIF(LE, (skygw_log_write_flush(LOGFILE_ERROR,"Error: Failed to set socket options. Error %d: %s", errno, strerror_r(errno, errbuf, sizeof(errbuf))))); + MXS_ERROR("Failed to set socket options. Error %d: %s", + errno, strerror_r(errno, errbuf, sizeof(errbuf))); } setnonblocking(c_sock); client_dcb = dcb_alloc(DCB_ROLE_REQUEST_HANDLER); if (client_dcb == NULL) { - LOGIF(LE, (skygw_log_write_flush( - LOGFILE_ERROR, - "Error : Failed to create " - "DCB object for client connection."))); - close(c_sock); - rc = 1; - goto return_rc; + MXS_ERROR("Failed to create DCB object for client connection."); + close(c_sock); + rc = 1; + goto return_rc; } client_dcb->service = listener->session->service; @@ -1686,11 +1654,9 @@ int gw_MySQLAccept(DCB *listener) if (protocol == NULL) { /** delete client_dcb */ dcb_close(client_dcb); - LOGIF(LE, (skygw_log_write_flush( - LOGFILE_ERROR, - "%lu [gw_MySQLAccept] Failed to create " - "protocol object for client connection.", - pthread_self()))); + MXS_ERROR("%lu [gw_MySQLAccept] Failed to create " + "protocol object for client connection.", + pthread_self()); rc = 1; goto return_rc; } @@ -1722,25 +1688,21 @@ int gw_MySQLAccept(DCB *listener) dcb_close(client_dcb); /** Previous state is recovered in poll_add_dcb. */ - LOGIF(LE, (skygw_log_write_flush( - LOGFILE_ERROR, - "%lu [gw_MySQLAccept] Failed to add dcb %p for " - "fd %d to epoll set.", - pthread_self(), - client_dcb, - client_dcb->fd))); + MXS_ERROR("%lu [gw_MySQLAccept] Failed to add dcb %p for " + "fd %d to epoll set.", + pthread_self(), + client_dcb, + client_dcb->fd); rc = 1; goto return_rc; } else { - LOGIF(LD, (skygw_log_write( - LOGFILE_DEBUG, - "%lu [gw_MySQLAccept] Added dcb %p for fd " - "%d to epoll set.", - pthread_self(), - client_dcb, - client_dcb->fd))); + MXS_DEBUG("%lu [gw_MySQLAccept] Added dcb %p for fd " + "%d to epoll set.", + pthread_self(), + client_dcb, + client_dcb->fd); } } /**< while 1 */ #if defined(SS_DEBUG) @@ -1763,14 +1725,12 @@ static int gw_error_client_event( session = dcb->session; - LOGIF(LD, (skygw_log_write( - LOGFILE_DEBUG, - "%lu [gw_error_client_event] Error event handling for DCB %p " - "in state %s, session %p.", - pthread_self(), - dcb, - STRDCBSTATE(dcb->state), - (session != NULL ? session : NULL)))); + MXS_DEBUG("%lu [gw_error_client_event] Error event handling for DCB %p " + "in state %s, session %p.", + pthread_self(), + dcb, + STRDCBSTATE(dcb->state), + (session != NULL ? session : NULL)); if (session != NULL && session->state == SESSION_STATE_STOPPING) { @@ -1778,9 +1738,7 @@ static int gw_error_client_event( } #if defined(SS_DEBUG) - LOGIF(LD, (skygw_log_write_flush( - LOGFILE_DEBUG, - "Client error event handling."))); + MXS_DEBUG("Client error event handling."); #endif dcb_close(dcb); @@ -1803,9 +1761,7 @@ gw_client_close(DCB *dcb) if (!DCB_IS_CLONE(dcb)) CHK_PROTOCOL(protocol); } #endif - LOGIF(LD, (skygw_log_write(LOGFILE_DEBUG, - "%lu [gw_client_close]", - pthread_self()))); + MXS_DEBUG("%lu [gw_client_close]", pthread_self()); mysql_protocol_done(dcb); session = dcb->session; /** @@ -1975,9 +1931,9 @@ int do_ssl_accept(MySQLProtocol* protocol) queue and wait for more.*/ rval = 0; - skygw_log_write_flush(LT,"SSL_accept ongoing for %s@%s", - protocol->owner_dcb->user, - protocol->owner_dcb->remote); + MXS_INFO("SSL_accept ongoing for %s@%s", + protocol->owner_dcb->user, + protocol->owner_dcb->remote); return 0; break; case 1: @@ -1993,9 +1949,9 @@ int do_ssl_accept(MySQLProtocol* protocol) rval = 1; - skygw_log_write_flush(LT,"SSL_accept done for %s@%s", - protocol->owner_dcb->user, - protocol->owner_dcb->remote); + MXS_INFO("SSL_accept done for %s@%s", + protocol->owner_dcb->user, + protocol->owner_dcb->remote); break; case -1: @@ -2004,20 +1960,17 @@ int do_ssl_accept(MySQLProtocol* protocol) protocol->protocol_auth_state = MYSQL_AUTH_SSL_HANDSHAKE_FAILED; spinlock_release(&protocol->protocol_lock); rval = -1; - skygw_log_write_flush(LE, - "Error: Fatal error in SSL_accept for %s", - protocol->owner_dcb->remote); + MXS_ERROR("Fatal error in SSL_accept for %s", + protocol->owner_dcb->remote); break; default: - skygw_log_write_flush(LE, - "Error: Fatal error in SSL_accept, returned value was %d.", - rval); + MXS_ERROR("Fatal error in SSL_accept, returned value was %d.", rval); break; } #ifdef SS_DEBUG - skygw_log_write(LD,"[do_ssl_accept] Protocol state: %s", - gw_mysql_protocol_state2string(protocol->protocol_auth_state)); + MXS_DEBUG("[do_ssl_accept] Protocol state: %s", + gw_mysql_protocol_state2string(protocol->protocol_auth_state)); #endif return rval; diff --git a/server/modules/protocol/mysql_common.c b/server/modules/protocol/mysql_common.c index 519191a4b..5ed0d5b24 100644 --- a/server/modules/protocol/mysql_common.c +++ b/server/modules/protocol/mysql_common.c @@ -86,13 +86,11 @@ MySQLProtocol* mysql_protocol_init( int eno = errno; errno = 0; char errbuf[STRERROR_BUFLEN]; - LOGIF(LE, (skygw_log_write_flush( - LOGFILE_ERROR, - "%lu [mysql_init_protocol] MySQL protocol init failed : " - "memory allocation due error %d, %s.", - pthread_self(), - eno, - strerror_r(eno, errbuf, sizeof(errbuf))))); + MXS_ERROR("%lu [mysql_init_protocol] MySQL protocol init failed : " + "memory allocation due error %d, %s.", + pthread_self(), + eno, + strerror_r(eno, errbuf, sizeof(errbuf))); goto return_p; } p->protocol_state = MYSQL_PROTOCOL_ALLOC; @@ -187,13 +185,11 @@ int gw_read_backend_handshake( if (h_len <= 4) { /* log error this exit point */ conn->protocol_auth_state = MYSQL_HANDSHAKE_FAILED; - LOGIF(LD, (skygw_log_write( - LOGFILE_DEBUG, - "%lu [gw_read_backend_handshake] after " - "dcb_read, fd %d, " - "state = MYSQL_HANDSHAKE_FAILED.", - pthread_self(), - dcb->fd))); + MXS_DEBUG("%lu [gw_read_backend_handshake] after " + "dcb_read, fd %d, " + "state = MYSQL_HANDSHAKE_FAILED.", + pthread_self(), + dcb->fd); return 1; } @@ -206,24 +202,20 @@ int gw_read_backend_handshake( conn->protocol_auth_state = MYSQL_HANDSHAKE_FAILED; - LOGIF(LD, (skygw_log_write( - LOGFILE_DEBUG, - "%lu [gw_receive_backend_auth] Invalid " - "authentication message from backend dcb %p " - "fd %d, ptr[4] = %d, error code %d, msg %s.", - pthread_self(), - dcb, - dcb->fd, - payload[4], - errcode, - bufstr))); + MXS_DEBUG("%lu [gw_receive_backend_auth] Invalid " + "authentication message from backend dcb %p " + "fd %d, ptr[4] = %d, error code %d, msg %s.", + pthread_self(), + dcb, + dcb->fd, + payload[4], + errcode, + bufstr); - LOGIF(LE, (skygw_log_write_flush( - LOGFILE_ERROR, - "Error : Invalid authentication message " - "from backend. Error code: %d, Msg : %s", - errcode, - bufstr))); + MXS_ERROR("Invalid authentication message " + "from backend. Error code: %d, Msg : %s", + errcode, + bufstr); /** * If ER_HOST_IS_BLOCKED is found @@ -232,12 +224,14 @@ int gw_read_backend_handshake( */ if (errcode == 1129) { - LOGIF(LE, (skygw_log_write_flush( - LOGFILE_ERROR, - "Server %s has been put into maintenance mode due to the server blocking connections from MaxScale. Run 'mysqladmin -h %s -P %d flush-hosts' on this server before taking this server out of maintenance mode.", - dcb->server->unique_name, - dcb->server->name, - dcb->server->port))); + MXS_ERROR("Server %s has been put into maintenance mode due " + "to the server blocking connections from MaxScale. " + "Run 'mysqladmin -h %s -P %d flush-hosts' on this " + "server before taking this server out of maintenance " + "mode.", + dcb->server->unique_name, + dcb->server->name, + dcb->server->port); server_set_status(dcb->server, SERVER_MAINT); } @@ -255,13 +249,11 @@ int gw_read_backend_handshake( conn->protocol_auth_state = MYSQL_HANDSHAKE_FAILED; - LOGIF(LD, (skygw_log_write( - LOGFILE_DEBUG, - "%lu [gw_read_backend_handshake] after " - "gw_mysql_get_byte3, fd %d, " - "state = MYSQL_HANDSHAKE_FAILED.", - pthread_self(), - dcb->fd))); + MXS_DEBUG("%lu [gw_read_backend_handshake] after " + "gw_mysql_get_byte3, fd %d, " + "state = MYSQL_HANDSHAKE_FAILED.", + pthread_self(), + dcb->fd); return 1; } @@ -279,13 +271,11 @@ int gw_read_backend_handshake( */ conn->protocol_auth_state = MYSQL_HANDSHAKE_FAILED; - LOGIF(LD, (skygw_log_write( - LOGFILE_DEBUG, - "%lu [gw_read_backend_handshake] after " - "gw_decode_mysql_server_handshake, fd %d, " - "state = MYSQL_HANDSHAKE_FAILED.", - pthread_self(), - conn->owner_dcb->fd))); + MXS_DEBUG("%lu [gw_read_backend_handshake] after " + "gw_decode_mysql_server_handshake, fd %d, " + "state = MYSQL_HANDSHAKE_FAILED.", + pthread_self(), + conn->owner_dcb->fd); while((head = gwbuf_consume(head, GWBUF_LENGTH(head)))); return 1; } @@ -445,24 +435,20 @@ int gw_receive_backend_auth( char* err = strndup(&((char *)ptr)[8], 5); char* bufstr = strndup(&((char *)ptr)[13], len-4-5); - LOGIF(LD, (skygw_log_write( - LOGFILE_DEBUG, - "%lu [gw_receive_backend_auth] Invalid " - "authentication message from backend dcb %p " - "fd %d, ptr[4] = %d, error %s, msg %s.", - pthread_self(), - dcb, - dcb->fd, - ptr[4], - err, - bufstr))); + MXS_DEBUG("%lu [gw_receive_backend_auth] Invalid " + "authentication message from backend dcb %p " + "fd %d, ptr[4] = %d, error %s, msg %s.", + pthread_self(), + dcb, + dcb->fd, + ptr[4], + err, + bufstr); - LOGIF(LE, (skygw_log_write_flush( - LOGFILE_ERROR, - "Error : Invalid authentication message " - "from backend. Error : %s, Msg : %s", - err, - bufstr))); + MXS_ERROR("Invalid authentication message " + "from backend. Error : %s, Msg : %s", + err, + bufstr); free(bufstr); free(err); @@ -470,21 +456,17 @@ int gw_receive_backend_auth( } else { - LOGIF(LD, (skygw_log_write( - LOGFILE_DEBUG, - "%lu [gw_receive_backend_auth] Invalid " - "authentication message from backend dcb %p " - "fd %d, ptr[4] = %d", - pthread_self(), - dcb, - dcb->fd, - ptr[4]))); + MXS_DEBUG("%lu [gw_receive_backend_auth] Invalid " + "authentication message from backend dcb %p " + "fd %d, ptr[4] = %d", + pthread_self(), + dcb, + dcb->fd, + ptr[4]); - LOGIF(LE, (skygw_log_write_flush( - LOGFILE_ERROR, - "Error : Invalid authentication message " - "from backend. Packet type : %d", - ptr[4]))); + MXS_ERROR("Invalid authentication message " + "from backend. Packet type : %d", + ptr[4]); } /*< * Remove data from buffer. @@ -498,33 +480,29 @@ int gw_receive_backend_auth( * although no bytes was read. */ rc = 0; - LOGIF(LD, (skygw_log_write( - LOGFILE_DEBUG, - "%lu [gw_receive_backend_auth] Read zero bytes from " - "backend dcb %p fd %d in state %s. n %d, head %p, len %ld", - pthread_self(), - dcb, - dcb->fd, - STRDCBSTATE(dcb->state), - n, - head, - (head == NULL) ? 0 : GWBUF_LENGTH(head)))); + MXS_DEBUG("%lu [gw_receive_backend_auth] Read zero bytes from " + "backend dcb %p fd %d in state %s. n %d, head %p, len %ld", + pthread_self(), + dcb, + dcb->fd, + STRDCBSTATE(dcb->state), + n, + head, + (head == NULL) ? 0 : GWBUF_LENGTH(head)); } else { ss_dassert(n < 0 && head == NULL); rc = -1; - LOGIF(LD, (skygw_log_write_flush( - LOGFILE_DEBUG, - "%lu [gw_receive_backend_auth] Reading from backend dcb %p " - "fd %d in state %s failed. n %d, head %p, len %ld", - pthread_self(), - dcb, - dcb->fd, - STRDCBSTATE(dcb->state), - n, - head, - (head == NULL) ? 0 : GWBUF_LENGTH(head)))); + MXS_DEBUG("%lu [gw_receive_backend_auth] Reading from backend dcb %p " + "fd %d in state %s failed. n %d, head %p, len %ld", + pthread_self(), + dcb, + dcb->fd, + STRDCBSTATE(dcb->state), + n, + head, + (head == NULL) ? 0 : GWBUF_LENGTH(head)); } return rc; @@ -762,15 +740,13 @@ int gw_do_connect_to_backend( if (so < 0) { char errbuf[STRERROR_BUFLEN]; - LOGIF(LE, (skygw_log_write_flush( - LOGFILE_ERROR, - "Error: Establishing connection to backend server " - "%s:%d failed.\n\t\t Socket creation failed " - "due %d, %s.", - host, - port, - errno, - strerror_r(errno, errbuf, sizeof(errbuf))))); + MXS_ERROR("Establishing connection to backend server " + "%s:%d failed.\n\t\t Socket creation failed " + "due %d, %s.", + host, + port, + errno, + strerror_r(errno, errbuf, sizeof(errbuf))); rv = -1; goto return_rv; } @@ -782,15 +758,13 @@ int gw_do_connect_to_backend( if(setsockopt(so, SOL_SOCKET, SO_SNDBUF, &bufsize, sizeof(bufsize)) != 0) { char errbuf[STRERROR_BUFLEN]; - LOGIF(LE, (skygw_log_write_flush( - LOGFILE_ERROR, - "Error: Failed to set socket options " - "%s:%d failed.\n\t\t Socket configuration failed " - "due %d, %s.", - host, - port, - errno, - strerror_r(errno, errbuf, sizeof(errbuf))))); + MXS_ERROR("Failed to set socket options " + "%s:%d failed.\n\t\t Socket configuration failed " + "due %d, %s.", + host, + port, + errno, + strerror_r(errno, errbuf, sizeof(errbuf))); rv = -1; /** Close socket */ goto close_so; @@ -800,15 +774,13 @@ int gw_do_connect_to_backend( if(setsockopt(so, SOL_SOCKET, SO_RCVBUF, &bufsize, sizeof(bufsize)) != 0) { char errbuf[STRERROR_BUFLEN]; - LOGIF(LE, (skygw_log_write_flush( - LOGFILE_ERROR, - "Error: Failed to set socket options " - "%s:%d failed.\n\t\t Socket configuration failed " - "due %d, %s.", - host, - port, - errno, - strerror_r(errno, errbuf, sizeof(errbuf))))); + MXS_ERROR("Failed to set socket options " + "%s:%d failed.\n\t\t Socket configuration failed " + "due %d, %s.", + host, + port, + errno, + strerror_r(errno, errbuf, sizeof(errbuf))); rv = -1; /** Close socket */ goto close_so; @@ -818,15 +790,13 @@ int gw_do_connect_to_backend( if(setsockopt(so, IPPROTO_TCP, TCP_NODELAY, &one, sizeof(one)) != 0) { char errbuf[STRERROR_BUFLEN]; - LOGIF(LE, (skygw_log_write_flush( - LOGFILE_ERROR, - "Error: Failed to set socket options " - "%s:%d failed.\n\t\t Socket configuration failed " - "due %d, %s.", - host, - port, - errno, - strerror_r(errno, errbuf, sizeof(errbuf))))); + MXS_ERROR("Failed to set socket options " + "%s:%d failed.\n\t\t Socket configuration failed " + "due %d, %s.", + host, + port, + errno, + strerror_r(errno, errbuf, sizeof(errbuf))); rv = -1; /** Close socket */ goto close_so; @@ -845,27 +815,20 @@ int gw_do_connect_to_backend( else { char errbuf[STRERROR_BUFLEN]; - LOGIF(LE, (skygw_log_write_flush( - LOGFILE_ERROR, - "Error: Failed to connect backend server %s:%d, " - "due %d, %s.", - host, - port, - errno, - strerror_r(errno, errbuf, sizeof(errbuf))))); + MXS_ERROR("Failed to connect backend server %s:%d, " + "due %d, %s.", + host, + port, + errno, + strerror_r(errno, errbuf, sizeof(errbuf))); /** Close socket */ goto close_so; } } *fd = so; - LOGIF(LD, (skygw_log_write_flush( - LOGFILE_DEBUG, - "%lu [gw_do_connect_to_backend] Connected to backend server " - "%s:%d, fd %d.", - pthread_self(), - host, - port, - so))); + MXS_DEBUG("%lu [gw_do_connect_to_backend] Connected to backend server " + "%s:%d, fd %d.", + pthread_self(), host, port, so); #if defined(FAKE_CODE) conn_open[so] = true; #endif /* FAKE_CODE */ @@ -878,13 +841,10 @@ close_so: if (close(so) != 0) { char errbuf[STRERROR_BUFLEN]; - LOGIF(LE, (skygw_log_write_flush( - LOGFILE_ERROR, - "Error: Failed to " - "close socket %d due %d, %s.", - so, - errno, - strerror_r(errno, errbuf, sizeof(errbuf))))); + MXS_ERROR("Failed to close socket %d due %d, %s.", + so, + errno, + strerror_r(errno, errbuf, sizeof(errbuf))); } goto return_rv; } @@ -1461,15 +1421,12 @@ int gw_find_mysql_user_password_sha1(char *username, uint8_t *gateway_password, strcpy(key.hostname, dcb->remote); } - LOGIF(LD, - (skygw_log_write_flush( - LOGFILE_DEBUG, - "%lu [MySQL Client Auth], checking user [%s@%s]%s%s", - pthread_self(), - key.user, - dcb->remote, - key.resource != NULL ?" db: " :"", - key.resource != NULL ?key.resource :""))); + MXS_DEBUG("%lu [MySQL Client Auth], checking user [%s@%s]%s%s", + pthread_self(), + key.user, + dcb->remote, + key.resource != NULL ?" db: " :"", + key.resource != NULL ?key.resource :""); /* look for user@current_ipv4 now */ user_password = mysql_users_fetch(service->users, &key); @@ -1530,13 +1487,11 @@ int gw_find_mysql_user_password_sha1(char *username, uint8_t *gateway_password, memset(&key.ipv4, 0, sizeof(struct sockaddr_in)); key.netmask = 0; - LOGIF(LD, - (skygw_log_write_flush( - LOGFILE_DEBUG, - "%lu [MySQL Client Auth], checking user [%s@%s] with wildcard host [%%]", - pthread_self(), - key.user, - dcb->remote))); + MXS_DEBUG("%lu [MySQL Client Auth], checking user [%s@%s] with " + "wildcard host [%%]", + pthread_self(), + key.user, + dcb->remote); user_password = mysql_users_fetch(service->users, &key); @@ -1550,19 +1505,14 @@ int gw_find_mysql_user_password_sha1(char *username, uint8_t *gateway_password, * user@% not found. */ - LOGIF(LD, - (skygw_log_write_flush( - LOGFILE_DEBUG, - "%lu [MySQL Client Auth], user [%s@%s] not existent", - pthread_self(), - key.user, - dcb->remote))); + MXS_DEBUG("%lu [MySQL Client Auth], user [%s@%s] not existent", + pthread_self(), + key.user, + dcb->remote); - LOGIF(LT,skygw_log_write_flush( - LOGFILE_ERROR, - "Authentication Failed: user [%s@%s] not found.", - key.user, - dcb->remote)); + MXS_INFO("Authentication Failed: user [%s@%s] not found.", + key.user, + dcb->remote); break; } @@ -1622,14 +1572,12 @@ mysql_send_auth_error ( if (dcb->state != DCB_STATE_POLLING) { - LOGIF(LD, (skygw_log_write( - LOGFILE_DEBUG, - "%lu [mysql_send_auth_error] dcb %p is in a state %s, " - "and it is not in epoll set anymore. Skip error sending.", - pthread_self(), - dcb, - STRDCBSTATE(dcb->state)))); - return 0; + MXS_DEBUG("%lu [mysql_send_auth_error] dcb %p is in a state %s, " + "and it is not in epoll set anymore. Skip error sending.", + pthread_self(), + dcb, + STRDCBSTATE(dcb->state)); + return 0; } mysql_errno = 1045; mysql_error_msg = "Access denied!"; @@ -1830,11 +1778,9 @@ void protocol_archive_srv_command( s1 = &p->protocol_command; #if defined(EXTRA_SS_DEBUG) - LOGIF(LT, (skygw_log_write( - LOGFILE_TRACE, - "Move command %s from fd %d to command history.", - STRPACKETTYPE(s1->scom_cmd), - p->owner_dcb->fd))); + MXS_INFO("Move command %s from fd %d to command history.", + STRPACKETTYPE(s1->scom_cmd), + p->owner_dcb->fd); #endif /** Copy to history list */ if ((h1 = p->protocol_cmd_history) == NULL) @@ -1907,23 +1853,19 @@ void protocol_add_srv_command( p->protocol_command.scom_next = server_command_init(NULL, cmd); } #if defined(EXTRA_SS_DEBUG) - LOGIF(LT, (skygw_log_write( - LOGFILE_TRACE, - "Added command %s to fd %d.", - STRPACKETTYPE(cmd), - p->owner_dcb->fd))); + MXS_INFO("Added command %s to fd %d.", + STRPACKETTYPE(cmd), + p->owner_dcb->fd); c = &p->protocol_command; while (c != NULL && c->scom_cmd != MYSQL_COM_UNDEFINED) { - LOGIF(LT, (skygw_log_write( - LOGFILE_TRACE, - "fd %d : %d %s", - p->owner_dcb->fd, - c->scom_cmd, - STRPACKETTYPE(c->scom_cmd)))); - c = c->scom_next; + MXS_INFO("fd %d : %d %s", + p->owner_dcb->fd, + c->scom_cmd, + STRPACKETTYPE(c->scom_cmd)); + c = c->scom_next; } #endif retblock: @@ -1944,11 +1886,9 @@ void protocol_remove_srv_command( spinlock_acquire(&p->protocol_lock); s = &p->protocol_command; #if defined(EXTRA_SS_DEBUG) - LOGIF(LT, (skygw_log_write( - LOGFILE_TRACE, - "Removed command %s from fd %d.", - STRPACKETTYPE(s->scom_cmd), - p->owner_dcb->fd))); + MXS_INFO("Removed command %s from fd %d.", + STRPACKETTYPE(s->scom_cmd), + p->owner_dcb->fd); #endif if (s->scom_next == NULL) { @@ -1975,12 +1915,10 @@ mysql_server_cmd_t protocol_get_srv_command( { protocol_remove_srv_command(p); } - LOGIF(LD, (skygw_log_write( - LOGFILE_DEBUG, - "%lu [protocol_get_srv_command] Read command %s for fd %d.", - pthread_self(), - STRPACKETTYPE(cmd), - p->owner_dcb->fd))); + MXS_DEBUG("%lu [protocol_get_srv_command] Read command %s for fd %d.", + pthread_self(), + STRPACKETTYPE(cmd), + p->owner_dcb->fd); return cmd; } @@ -2235,10 +2173,8 @@ char *create_auth_fail_str( if (errstr == NULL) { char errbuf[STRERROR_BUFLEN]; - LOGIF(LE, (skygw_log_write_flush( - LOGFILE_ERROR, - "Error : Memory allocation failed due to %s.", - strerror_r(errno, errbuf, sizeof(errbuf))))); + MXS_ERROR("Memory allocation failed due to %s.", + strerror_r(errno, errbuf, sizeof(errbuf))); goto retblock; } diff --git a/server/modules/protocol/telnetd.c b/server/modules/protocol/telnetd.c index 943154c18..324c66524 100644 --- a/server/modules/protocol/telnetd.c +++ b/server/modules/protocol/telnetd.c @@ -116,9 +116,7 @@ version() void ModuleInit() { - LOGIF(LT, (skygw_log_write( - LOGFILE_TRACE, - "Initialise Telnetd Protocol module.\n"))); + MXS_INFO("Initialise Telnetd Protocol module."); } /** @@ -382,7 +380,8 @@ int syseno = 0; if(syseno != 0){ char errbuf[STRERROR_BUFLEN]; - LOGIF(LE, (skygw_log_write_flush(LOGFILE_ERROR,"Error: Failed to set socket options. Error %d: %s", errno, strerror_r(errno, errbuf, sizeof(errbuf))))); + MXS_ERROR("Failed to set socket options. Error %d: %s", + errno, strerror_r(errno, errbuf, sizeof(errbuf))); return 0; } // set NONBLOCKING mode @@ -396,7 +395,7 @@ int syseno = 0; rc = listen(listener->fd, SOMAXCONN); if (rc == 0) { - LOGIF(LM, (skygw_log_write_flush(LOGFILE_MESSAGE,"Listening telnet connections at %s", config))); + MXS_NOTICE("Listening telnet connections at %s", config); } else { int eno = errno; errno = 0;