server/modules/protocol: All LOGIFs and skygw_log_writes replaced.

LOGIFs and skygw_log_writes replaced with the equivalent
MXS_[ERROR|WARNING|NOTICE|INFO|DEBUG] macros.
This commit is contained in:
Johan Wikman
2015-11-16 21:39:34 +02:00
parent 6641c42ef9
commit 453055a6c0
6 changed files with 472 additions and 660 deletions

View File

@ -411,9 +411,8 @@ int syseno = 0;
if(syseno != 0){ if(syseno != 0){
char errbuf[STRERROR_BUFLEN]; char errbuf[STRERROR_BUFLEN];
skygw_log_write_flush(LOGFILE_ERROR, MXS_ERROR("Failed to set socket options. Error %d: %s",
"Error: Failed to set socket options. Error %d: %s", errno, strerror_r(errno, errbuf, sizeof(errbuf)));
errno, strerror_r(errno, errbuf, sizeof(errbuf)));
return 0; return 0;
} }
/* set NONBLOCKING mode */ /* set NONBLOCKING mode */
@ -428,7 +427,7 @@ int syseno = 0;
rc = listen(listener->fd, SOMAXCONN); rc = listen(listener->fd, SOMAXCONN);
if (rc == 0) { 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 { } else {
int eno = errno; int eno = errno;
errno = 0; errno = 0;

View File

@ -104,9 +104,7 @@ version()
void void
ModuleInit() ModuleInit()
{ {
LOGIF(LT, (skygw_log_write( MXS_INFO("Initialise MaxScaled Protocol module.");;
LOGFILE_TRACE,
"Initialise MaxScaled Protocol module.\n")));
} }
/** /**
@ -352,10 +350,7 @@ int rc;
// socket options // socket options
if (setsockopt(listener->fd, SOL_SOCKET, SO_REUSEADDR, (char *)&one, sizeof(one))) if (setsockopt(listener->fd, SOL_SOCKET, SO_REUSEADDR, (char *)&one, sizeof(one)))
{ {
LOGIF(LE, (skygw_log_write( MXS_ERROR("Unable to set SO_REUSEADDR on maxscale listener.");
LOGFILE_ERROR,
"Unable to set SO_REUSEADDR on maxscale listener."
)));
} }
// set NONBLOCKING mode // set NONBLOCKING mode
setnonblocking(listener->fd); setnonblocking(listener->fd);
@ -368,20 +363,14 @@ int rc;
rc = listen(listener->fd, SOMAXCONN); rc = listen(listener->fd, SOMAXCONN);
if (rc == 0) { if (rc == 0) {
LOGIF(LM, (skygw_log_write( MXS_NOTICE("Listening maxscale connections at %s", config);
LOGFILE_MESSAGE,
"Listening maxscale connections at %s\n",
config)));
} else { } else {
int eno = errno; int eno = errno;
errno = 0; errno = 0;
char errbuf[STRERROR_BUFLEN]; char errbuf[STRERROR_BUFLEN];
LOGIF(LE, (skygw_log_write( MXS_ERROR("Failed to start listening for maxscale admin connections "
LOGFILE_ERROR, "due error %d, %s",
"Failed to start listening for maxscale admin connections " eno, strerror_r(eno, errbuf, sizeof(errbuf)));
"due error %d, %s\n\n",
eno,
strerror_r(eno, errbuf, sizeof(errbuf)))));
return 0; return 0;
} }

View File

@ -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) { if (dcb->session->state != SESSION_STATE_ALLOC && dcb->session->state != SESSION_STATE_DUMMY) {
auth_info = dcb->session->data; auth_info = dcb->session->data;
} else { } else {
LOGIF(LE, (skygw_log_write_flush( MXS_ERROR("%lu [gw_get_shared_session_auth_info] Couldn't get "
LOGFILE_ERROR, "session authentication info. Session in a wrong state %d.",
"%lu [gw_get_shared_session_auth_info] Couldn't get " pthread_self(),
"session authentication info. Session in a wrong state %d.", dcb->session->state);
pthread_self(),
dcb->session->state)));
} }
spinlock_release(&dcb->session->ses_lock); spinlock_release(&dcb->session->ses_lock);
@ -184,15 +182,13 @@ static int gw_read_backend_event(DCB *dcb) {
backend_protocol = (MySQLProtocol *) dcb->protocol; backend_protocol = (MySQLProtocol *) dcb->protocol;
CHK_PROTOCOL(backend_protocol); CHK_PROTOCOL(backend_protocol);
LOGIF(LD, (skygw_log_write( MXS_DEBUG("%lu [gw_read_backend_event] Read dcb %p fd %d protocol "
LOGFILE_DEBUG, "state %d, %s.",
"%lu [gw_read_backend_event] Read dcb %p fd %d protocol " pthread_self(),
"state %d, %s.", dcb,
pthread_self(), dcb->fd,
dcb, backend_protocol->protocol_auth_state,
dcb->fd, STRPROTOCOLSTATE(backend_protocol->protocol_auth_state));
backend_protocol->protocol_auth_state,
STRPROTOCOLSTATE(backend_protocol->protocol_auth_state))));
/* backend is connected: /* backend is connected:
@ -220,13 +216,11 @@ static int gw_read_backend_event(DCB *dcb) {
{ {
backend_protocol->protocol_auth_state = MYSQL_HANDSHAKE_FAILED; backend_protocol->protocol_auth_state = MYSQL_HANDSHAKE_FAILED;
LOGIF(LD, (skygw_log_write( MXS_DEBUG("%lu [gw_read_backend_event] after "
LOGFILE_DEBUG, "gw_read_backend_handshake, fd %d, "
"%lu [gw_read_backend_event] after " "state = MYSQL_HANDSHAKE_FAILED.",
"gw_read_backend_handshake, fd %d, " pthread_self(),
"state = MYSQL_HANDSHAKE_FAILED.", backend_protocol->owner_dcb->fd);
pthread_self(),
backend_protocol->owner_dcb->fd)));
} }
else else
{ {
@ -241,13 +235,11 @@ static int gw_read_backend_event(DCB *dcb) {
backend_protocol) != 0) backend_protocol) != 0)
{ {
backend_protocol->protocol_auth_state = MYSQL_AUTH_FAILED; backend_protocol->protocol_auth_state = MYSQL_AUTH_FAILED;
LOGIF(LD, (skygw_log_write( MXS_DEBUG("%lu [gw_read_backend_event] after "
LOGFILE_DEBUG, "gw_send_authentication_to_backend "
"%lu [gw_read_backend_event] after " "fd %d, state = MYSQL_AUTH_FAILED.",
"gw_send_authentication_to_backend " pthread_self(),
"fd %d, state = MYSQL_AUTH_FAILED.", backend_protocol->owner_dcb->fd);
pthread_self(),
backend_protocol->owner_dcb->fd)));
} }
else else
{ {
@ -303,46 +295,38 @@ static int gw_read_backend_event(DCB *dcb) {
switch (receive_rc) { switch (receive_rc) {
case -1: case -1:
backend_protocol->protocol_auth_state = MYSQL_AUTH_FAILED; backend_protocol->protocol_auth_state = MYSQL_AUTH_FAILED;
LOGIF(LD, (skygw_log_write( MXS_DEBUG("%lu [gw_read_backend_event] after "
LOGFILE_DEBUG, "gw_receive_backend_authentication "
"%lu [gw_read_backend_event] after " "fd %d, state = MYSQL_AUTH_FAILED.",
"gw_receive_backend_authentication " pthread_self(),
"fd %d, state = MYSQL_AUTH_FAILED.", backend_protocol->owner_dcb->fd);
pthread_self(),
backend_protocol->owner_dcb->fd)));
LOGIF(LE, (skygw_log_write_flush( MXS_ERROR("Backend server didn't "
LOGFILE_ERROR, "accept authentication for user "
"Error : Backend server didn't " "%s.",
"accept authentication for user " current_session->user);
"%s.",
current_session->user)));
break; break;
case 1: case 1:
backend_protocol->protocol_auth_state = MYSQL_IDLE; backend_protocol->protocol_auth_state = MYSQL_IDLE;
LOGIF(LD, (skygw_log_write_flush( MXS_DEBUG("%lu [gw_read_backend_event] "
LOGFILE_DEBUG, "gw_receive_backend_auth succeed. "
"%lu [gw_read_backend_event] " "dcb %p fd %d, user %s.",
"gw_receive_backend_auth succeed. " pthread_self(),
"dcb %p fd %d, user %s.", dcb,
pthread_self(), dcb->fd,
dcb, current_session->user);
dcb->fd,
current_session->user)));
break; break;
default: default:
ss_dassert(receive_rc == 0); ss_dassert(receive_rc == 0);
LOGIF(LD, (skygw_log_write_flush( MXS_DEBUG("%lu [gw_read_backend_event] "
LOGFILE_DEBUG, "gw_receive_backend_auth read "
"%lu [gw_read_backend_event] " "successfully "
"gw_receive_backend_auth read " "nothing. dcb %p fd %d, user %s.",
"successfully " pthread_self(),
"nothing. dcb %p fd %d, user %s.", dcb,
pthread_self(), dcb->fd,
dcb, current_session->user);
dcb->fd,
current_session->user)));
rc = 0; rc = 0;
goto return_with_lock; goto return_with_lock;
break; break;
@ -376,14 +360,12 @@ static int gw_read_backend_event(DCB *dcb) {
service_refresh_users(dcb->session->service); service_refresh_users(dcb->session->service);
} }
#if defined(SS_DEBUG) #if defined(SS_DEBUG)
LOGIF(LD, (skygw_log_write( MXS_DEBUG("%lu [gw_read_backend_event] "
LOGFILE_DEBUG, "calling handleError. Backend "
"%lu [gw_read_backend_event] " "DCB %p, session %p",
"calling handleError. Backend " pthread_self(),
"DCB %p, session %p", dcb,
pthread_self(), dcb->session);
dcb,
dcb->session)));
#endif #endif
errbuf = mysql_create_custom_error( errbuf = mysql_create_custom_error(
@ -426,14 +408,12 @@ static int gw_read_backend_event(DCB *dcb) {
else else
{ {
ss_dassert(backend_protocol->protocol_auth_state == MYSQL_IDLE); ss_dassert(backend_protocol->protocol_auth_state == MYSQL_IDLE);
LOGIF(LD, (skygw_log_write_flush( MXS_DEBUG("%lu [gw_read_backend_event] "
LOGFILE_DEBUG, "gw_receive_backend_auth succeed. Fd %d, "
"%lu [gw_read_backend_event] " "user %s.",
"gw_receive_backend_auth succeed. Fd %d, " pthread_self(),
"user %s.", dcb->fd,
pthread_self(), current_session->user);
dcb->fd,
current_session->user)));
/* check the delay queue and flush the data */ /* check the delay queue and flush the data */
if (dcb->delayq) if (dcb->delayq)
@ -468,9 +448,7 @@ static int gw_read_backend_event(DCB *dcb) {
GWBUF* errbuf; GWBUF* errbuf;
bool succp; bool succp;
#if defined(SS_DEBUG) #if defined(SS_DEBUG)
LOGIF(LE, (skygw_log_write_flush( MXS_ERROR("Backend read error handling #2.");
LOGFILE_ERROR,
"Backend read error handling #2.")));
#endif #endif
errbuf = mysql_create_custom_error( errbuf = mysql_create_custom_error(
1, 1,
@ -555,13 +533,11 @@ static int gw_read_backend_event(DCB *dcb) {
} }
if (!read_buffer) { if (!read_buffer) {
LOGIF(LM, (skygw_log_write_flush( MXS_NOTICE("%lu [gw_read_backend_event] "
LOGFILE_MESSAGE, "Read buffer unexpectedly null, even though response "
"%lu [gw_read_backend_event] " "not marked as complete. User: %s",
"Read buffer unexpectedly null, even though response " pthread_self(),
"not marked as complete. User: %s", current_session->user);
pthread_self(),
current_session->user)));
rc = 0; rc = 0;
goto return_rc; goto return_rc;
} }
@ -650,34 +626,28 @@ static int gw_write_backend_event(DCB *dcb) {
0, 0,
"Writing to backend failed due invalid Maxscale " "Writing to backend failed due invalid Maxscale "
"state."); "state.");
LOGIF(LD, (skygw_log_write( MXS_DEBUG("%lu [gw_write_backend_event] Write to backend "
LOGFILE_DEBUG, "dcb %p fd %d "
"%lu [gw_write_backend_event] Write to backend " "failed due invalid state %s.",
"dcb %p fd %d " pthread_self(),
"failed due invalid state %s.", dcb,
pthread_self(), dcb->fd,
dcb, STRDCBSTATE(dcb->state));
dcb->fd,
STRDCBSTATE(dcb->state))));
LOGIF(LE, (skygw_log_write_flush( MXS_ERROR("Attempt to write buffered data to backend "
LOGFILE_ERROR, "failed "
"Error : Attempt to write buffered data to backend " "due internal inconsistent state.");
"failed "
"due internal inconsistent state.")));
rc = 0; rc = 0;
} }
} }
else else
{ {
LOGIF(LD, (skygw_log_write( MXS_DEBUG("%lu [gw_write_backend_event] Dcb %p in state %s "
LOGFILE_DEBUG, "but there's nothing to write either.",
"%lu [gw_write_backend_event] Dcb %p in state %s " pthread_self(),
"but there's nothing to write either.", dcb,
pthread_self(), STRDCBSTATE(dcb->state));
dcb,
STRDCBSTATE(dcb->state))));
rc = 1; rc = 1;
} }
goto return_rc; goto return_rc;
@ -691,14 +661,12 @@ static int gw_write_backend_event(DCB *dcb) {
dcb_drain_writeq(dcb); dcb_drain_writeq(dcb);
rc = 1; rc = 1;
return_rc: return_rc:
LOGIF(LD, (skygw_log_write( MXS_DEBUG("%lu [gw_write_backend_event] "
LOGFILE_DEBUG, "wrote to dcb %p fd %d, return %d",
"%lu [gw_write_backend_event] " pthread_self(),
"wrote to dcb %p fd %d, return %d", dcb,
pthread_self(), dcb->fd,
dcb, rc);
dcb->fd,
rc)));
return rc; return rc;
} }
@ -726,12 +694,12 @@ gw_MySQLWrite_backend(DCB *dcb, GWBUF *queue)
switch (backend_protocol->protocol_auth_state) { switch (backend_protocol->protocol_auth_state) {
case MYSQL_HANDSHAKE_FAILED: case MYSQL_HANDSHAKE_FAILED:
case MYSQL_AUTH_FAILED: case MYSQL_AUTH_FAILED:
LOGIF(LE, (skygw_log_write_flush(LOGFILE_ERROR, MXS_ERROR("Unable to write to backend '%s' due to "
"Error : Unable to write to backend '%s' due to " "%s failure. Server in state %s.",
"%s failure. Server in state %s.", dcb->server->unique_name,
dcb->server->unique_name, backend_protocol->protocol_auth_state == MYSQL_HANDSHAKE_FAILED ?
backend_protocol->protocol_auth_state == MYSQL_HANDSHAKE_FAILED ? "handshake" : "authentication", "handshake" : "authentication",
STRSRVSTATUS(dcb->server)))); STRSRVSTATUS(dcb->server));
/** Consume query buffer */ /** Consume query buffer */
while ((queue = gwbuf_consume( while ((queue = gwbuf_consume(
queue, queue,
@ -746,14 +714,12 @@ gw_MySQLWrite_backend(DCB *dcb, GWBUF *queue)
uint8_t* ptr = GWBUF_DATA(queue); uint8_t* ptr = GWBUF_DATA(queue);
int cmd = MYSQL_GET_COMMAND(ptr); int cmd = MYSQL_GET_COMMAND(ptr);
LOGIF(LD, (skygw_log_write( MXS_DEBUG("%lu [gw_MySQLWrite_backend] write to dcb %p "
LOGFILE_DEBUG, "fd %d protocol state %s.",
"%lu [gw_MySQLWrite_backend] write to dcb %p " pthread_self(),
"fd %d protocol state %s.", dcb,
pthread_self(), dcb->fd,
dcb, STRPROTOCOLSTATE(backend_protocol->protocol_auth_state));
dcb->fd,
STRPROTOCOLSTATE(backend_protocol->protocol_auth_state))));
spinlock_release(&dcb->authlock); spinlock_release(&dcb->authlock);
/** /**
@ -777,14 +743,12 @@ gw_MySQLWrite_backend(DCB *dcb, GWBUF *queue)
default: default:
{ {
LOGIF(LD, (skygw_log_write( MXS_DEBUG("%lu [gw_MySQLWrite_backend] delayed write to "
LOGFILE_DEBUG, "dcb %p fd %d protocol state %s.",
"%lu [gw_MySQLWrite_backend] delayed write to " pthread_self(),
"dcb %p fd %d protocol state %s.", dcb,
pthread_self(), dcb->fd,
dcb, STRPROTOCOLSTATE(backend_protocol->protocol_auth_state));
dcb->fd,
STRPROTOCOLSTATE(backend_protocol->protocol_auth_state))));
/** /**
* In case of session commands, store command to DCB's * In case of session commands, store command to DCB's
* protocol struct. * protocol struct.
@ -859,11 +823,9 @@ static int gw_error_backend_event(DCB *dcb)
if (error != 0) if (error != 0)
{ {
char errbuf[STRERROR_BUFLEN]; char errbuf[STRERROR_BUFLEN];
LOGIF(LE, (skygw_log_write_flush( MXS_ERROR("DCB in state %s got error '%s'.",
LOGFILE_ERROR, STRDCBSTATE(dcb->state),
"DCB in state %s got error '%s'.", strerror_r(error, errbuf, sizeof(errbuf)));
STRDCBSTATE(dcb->state),
strerror_r(error, errbuf, sizeof(errbuf)))));
} }
} }
return 1; return 1;
@ -900,10 +862,8 @@ static int gw_error_backend_event(DCB *dcb)
if (error != 0) if (error != 0)
{ {
char errbuf[STRERROR_BUFLEN]; char errbuf[STRERROR_BUFLEN];
LOGIF(LE, (skygw_log_write_flush( MXS_ERROR("Error '%s' in session that is not ready for routing.",
LOGFILE_ERROR, strerror_r(error, errbuf, sizeof(errbuf)));
"Error '%s' in session that is not ready for routing.",
strerror_r(error, errbuf, sizeof(errbuf)))));
} }
} }
gwbuf_free(errbuf); gwbuf_free(errbuf);
@ -911,9 +871,7 @@ static int gw_error_backend_event(DCB *dcb)
} }
#if defined(SS_DEBUG) #if defined(SS_DEBUG)
LOGIF(LE, (skygw_log_write_flush( MXS_INFO("Backend error event handling.");
LOGFILE_ERROR,
"Backend error event handling.")));
#endif #endif
router->handleError(router_instance, router->handleError(router_instance,
rsession, rsession,
@ -965,16 +923,11 @@ static int gw_create_backend_connection(
ss_dassert(protocol != NULL); ss_dassert(protocol != NULL);
if (protocol == NULL) { if (protocol == NULL) {
LOGIF(LD, (skygw_log_write( MXS_DEBUG("%lu [gw_create_backend_connection] Failed to create "
LOGFILE_DEBUG, "protocol object for backend connection.",
"%lu [gw_create_backend_connection] Failed to create " pthread_self());
"protocol object for backend connection.", MXS_ERROR("Failed to create protocol object for backend connection.");
pthread_self()))); goto return_fd;
LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR,
"Error: Failed to create "
"protocol object for backend connection.")));
goto return_fd;
} }
/** Copy client flags to backend protocol */ /** Copy client flags to backend protocol */
@ -1004,45 +957,39 @@ static int gw_create_backend_connection(
ss_dassert(fd > 0); ss_dassert(fd > 0);
protocol->fd = fd; protocol->fd = fd;
protocol->protocol_auth_state = MYSQL_CONNECTED; protocol->protocol_auth_state = MYSQL_CONNECTED;
LOGIF(LD, (skygw_log_write( MXS_DEBUG("%lu [gw_create_backend_connection] Established "
LOGFILE_DEBUG, "connection to %s:%i, protocol fd %d client "
"%lu [gw_create_backend_connection] Established " "fd %d.",
"connection to %s:%i, protocol fd %d client " pthread_self(),
"fd %d.", server->name,
pthread_self(), server->port,
server->name, protocol->fd,
server->port, session->client->fd);
protocol->fd,
session->client->fd)));
break; break;
case 1: case 1:
ss_dassert(fd > 0); ss_dassert(fd > 0);
protocol->protocol_auth_state = MYSQL_PENDING_CONNECT; protocol->protocol_auth_state = MYSQL_PENDING_CONNECT;
protocol->fd = fd; protocol->fd = fd;
LOGIF(LD, (skygw_log_write( MXS_DEBUG("%lu [gw_create_backend_connection] Connection "
LOGFILE_DEBUG, "pending to %s:%i, protocol fd %d client fd %d.",
"%lu [gw_create_backend_connection] Connection " pthread_self(),
"pending to %s:%i, protocol fd %d client fd %d.", server->name,
pthread_self(), server->port,
server->name, protocol->fd,
server->port, session->client->fd);
protocol->fd,
session->client->fd)));
break; break;
default: default:
ss_dassert(fd == -1); ss_dassert(fd == -1);
ss_dassert(protocol->protocol_auth_state == MYSQL_ALLOC); ss_dassert(protocol->protocol_auth_state == MYSQL_ALLOC);
LOGIF(LD, (skygw_log_write( MXS_DEBUG("%lu [gw_create_backend_connection] Connection "
LOGFILE_DEBUG, "failed to %s:%i, protocol fd %d client fd %d.",
"%lu [gw_create_backend_connection] Connection " pthread_self(),
"failed to %s:%i, protocol fd %d client fd %d.", server->name,
pthread_self(), server->port,
server->name, protocol->fd,
server->port, session->client->fd);
protocol->fd,
session->client->fd)));
break; break;
} /*< switch */ } /*< switch */
@ -1123,11 +1070,9 @@ gw_backend_hangup(DCB *dcb)
if (error != 0 && ses_state != SESSION_STATE_STOPPING) if (error != 0 && ses_state != SESSION_STATE_STOPPING)
{ {
char errbuf[STRERROR_BUFLEN]; char errbuf[STRERROR_BUFLEN];
LOGIF(LE, (skygw_log_write_flush( MXS_ERROR("Hangup in session that is not ready for routing, "
LOGFILE_ERROR, "Error reported is '%s'.",
"Hangup in session that is not ready for routing, " strerror_r(error, errbuf, sizeof(errbuf)));
"Error reported is '%s'.",
strerror_r(error, errbuf, sizeof(errbuf)))));
} }
} }
gwbuf_free(errbuf); gwbuf_free(errbuf);
@ -1142,9 +1087,7 @@ gw_backend_hangup(DCB *dcb)
#if defined(SS_DEBUG) #if defined(SS_DEBUG)
if(ses_state != SESSION_STATE_STOPPING) if(ses_state != SESSION_STATE_STOPPING)
{ {
LOGIF(LE, (skygw_log_write_flush( MXS_ERROR("Backend hangup error handling.");
LOGFILE_ERROR,
"Backend hangup error handling.")));
} }
#endif #endif
@ -1160,9 +1103,7 @@ gw_backend_hangup(DCB *dcb)
if (!succp) if (!succp)
{ {
#if defined(SS_DEBUG) #if defined(SS_DEBUG)
LOGIF(LE, (skygw_log_write_flush( MXS_ERROR("Backend hangup -> closing session.");
LOGFILE_ERROR,
"Backend hangup -> closing session.")));
#endif #endif
spinlock_acquire(&session->ses_lock); spinlock_acquire(&session->ses_lock);
session->state = SESSION_STATE_STOPPING; session->state = SESSION_STATE_STOPPING;
@ -1188,9 +1129,8 @@ gw_backend_close(DCB *dcb)
CHK_DCB(dcb); CHK_DCB(dcb);
session = dcb->session; session = dcb->session;
LOGIF(LD, (skygw_log_write(LOGFILE_DEBUG, MXS_DEBUG("%lu [gw_backend_close]",
"%lu [gw_backend_close]", pthread_self());
pthread_self())));
quitbuf = mysql_create_com_quit(NULL, 0); quitbuf = mysql_create_com_quit(NULL, 0);
gwbuf_set_type(quitbuf, GWBUF_TYPE_MYSQL); gwbuf_set_type(quitbuf, GWBUF_TYPE_MYSQL);
@ -1326,9 +1266,7 @@ static int backend_write_delayqueue(DCB *dcb)
router_instance = session->service->router_instance; router_instance = session->service->router_instance;
rsession = session->router_session; rsession = session->router_session;
#if defined(SS_DEBUG) #if defined(SS_DEBUG)
LOGIF(LE, (skygw_log_write_flush( MXS_INFO("Backend write delayqueue error handling.");
LOGFILE_ERROR,
"Backend write delayqueue error handling.")));
#endif #endif
errbuf = mysql_create_custom_error( errbuf = mysql_create_custom_error(
1, 1,
@ -1488,11 +1426,9 @@ static int gw_change_user(
auth_ret); auth_ret);
if (message == NULL) if (message == NULL)
{ {
LOGIF(LE, (skygw_log_write_flush( MXS_ERROR("Creating error message failed.");
LOGFILE_ERROR, rv = 0;
"Error : Creating error message failed."))); goto retblock;
rv = 0;
goto retblock;
} }
/** /**
* Add command to backend's protocol, create artificial reply * 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); srvcmd = protocol_get_srv_command(p, false);
LOGIF(LD, (skygw_log_write( MXS_DEBUG("%lu [process_response_data] Read command %s for DCB %p fd %d.",
LOGFILE_DEBUG, pthread_self(),
"%lu [process_response_data] Read command %s for DCB %p fd %d.", STRPACKETTYPE(srvcmd),
pthread_self(), dcb,
STRPACKETTYPE(srvcmd), dcb->fd);
dcb,
dcb->fd)));
/** /**
* Read values from protocol structure, fails if values are * Read values from protocol structure, fails if values are
* uninitialized. * uninitialized.
@ -1667,9 +1601,11 @@ static GWBUF* process_response_data (
wait for more data from the backend server.*/ wait for more data from the backend server.*/
if(readbuf == NULL || GWBUF_LENGTH(readbuf) < 3) 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.", MXS_DEBUG("%lu [%s] Read %d packets. Waiting for %d more "
pthread_self(),__FUNCTION__,initial_packets - npackets_left, "packets for a total of %d packets.",
npackets_left,initial_packets); pthread_self(),__FUNCTION__,
initial_packets - npackets_left,
npackets_left,initial_packets);
/** Store the already read data into the readqueue of the DCB /** Store the already read data into the readqueue of the DCB
* and restore the response status to the initial number of packets */ * and restore the response status to the initial number of packets */

View File

@ -480,16 +480,16 @@ static int gw_mysql_do_authentication(DCB *dcb, GWBUF **buf) {
/** Client didn't requested SSL when SSL mode was required*/ /** Client didn't requested SSL when SSL mode was required*/
if(!ssl && protocol->owner_dcb->service->ssl_mode == SSL_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.", MXS_INFO("User %s@%s connected to service '%s' without SSL when SSL was required.",
protocol->owner_dcb->user, protocol->owner_dcb->user,
protocol->owner_dcb->remote, protocol->owner_dcb->remote,
protocol->owner_dcb->service->name))); protocol->owner_dcb->service->name);
return MYSQL_FAILED_AUTH_SSL; return MYSQL_FAILED_AUTH_SSL;
} }
if(LOG_IS_ENABLED(LT) && 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->user,
protocol->owner_dcb->remote, protocol->owner_dcb->remote,
protocol->owner_dcb->service->name); 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 = GWBUF_DATA(queue);
client_auth_packet_size = gwbuf_length(queue); client_auth_packet_size = gwbuf_length(queue);
*buf = 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 * Decode the token and check the password
* Note: if auth_token_len == 0 && auth_token == NULL, user is without 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_ret = gw_check_mysql_scramble_data(dcb,
auth_token, auth_token,
auth_token_len, auth_token_len,
@ -599,15 +599,15 @@ static int gw_mysql_do_authentication(DCB *dcb, GWBUF **buf) {
} }
else if (dcb->service->log_auth_warnings) else if (dcb->service->log_auth_warnings)
{ {
skygw_log_write(LM, "%s: login attempt for user '%s', authentication failed.", MXS_NOTICE("%s: login attempt for user '%s', authentication failed.",
dcb->service->name, username); dcb->service->name, username);
if (dcb->ipv4.sin_addr.s_addr == 0x0100007F && if (dcb->ipv4.sin_addr.s_addr == 0x0100007F &&
!dcb->service->localhost_match_wildcard_host) !dcb->service->localhost_match_wildcard_host)
{ {
skygw_log_write_flush(LM, "If you have a wildcard grant that covers" MXS_NOTICE("If you have a wildcard grant that covers"
" this address, try adding " " this address, try adding "
"'localhost_match_wildcard_host=true' for " "'localhost_match_wildcard_host=true' for "
"service '%s'. ", dcb->service->name); "service '%s'. ", dcb->service->name);
} }
} }
@ -676,8 +676,8 @@ int gw_read_client_event(
CHK_PROTOCOL(protocol); CHK_PROTOCOL(protocol);
#ifdef SS_DEBUG #ifdef SS_DEBUG
skygw_log_write(LD,"[gw_read_client_event] Protocol state: %s", MXS_DEBUG("[gw_read_client_event] Protocol state: %s",
gw_mysql_protocol_state2string(protocol->protocol_auth_state)); gw_mysql_protocol_state2string(protocol->protocol_auth_state));
#endif #endif
@ -698,8 +698,7 @@ int gw_read_client_event(
ioctl(dcb->fd,FIONREAD,&b); ioctl(dcb->fd,FIONREAD,&b);
if(b == 0) if(b == 0)
{ {
skygw_log_write(LD, MXS_DEBUG("[gw_read_client_event] No data in socket after SSL auth");
"[gw_read_client_event] No data in socket after SSL auth");
return 0; return 0;
} }
break; break;
@ -883,13 +882,11 @@ int gw_read_client_event(
else else
{ {
protocol->protocol_auth_state = MYSQL_AUTH_FAILED; protocol->protocol_auth_state = MYSQL_AUTH_FAILED;
LOGIF(LD, (skygw_log_write( MXS_DEBUG("%lu [gw_read_client_event] session "
LOGFILE_DEBUG, "creation failed. fd %d, "
"%lu [gw_read_client_event] session " "state = MYSQL_AUTH_FAILED.",
"creation failed. fd %d, " pthread_self(),
"state = MYSQL_AUTH_FAILED.", protocol->owner_dcb->fd);
pthread_self(),
protocol->owner_dcb->fd)));
/** Send ERR 1045 to client */ /** Send ERR 1045 to client */
mysql_send_auth_error( mysql_send_auth_error(
@ -927,13 +924,11 @@ int gw_read_client_event(
if (fail_str) if (fail_str)
free(fail_str); free(fail_str);
LOGIF(LD, (skygw_log_write( MXS_DEBUG("%lu [gw_read_client_event] after "
LOGFILE_DEBUG, "gw_mysql_do_authentication, fd %d, "
"%lu [gw_read_client_event] after " "state = MYSQL_AUTH_FAILED.",
"gw_mysql_do_authentication, fd %d, " pthread_self(),
"state = MYSQL_AUTH_FAILED.", protocol->owner_dcb->fd);
pthread_self(),
protocol->owner_dcb->fd)));
/** /**
* Release MYSQL_session since it is not used anymore. * Release MYSQL_session since it is not used anymore.
*/ */
@ -983,13 +978,11 @@ int gw_read_client_event(
else else
{ {
protocol->protocol_auth_state = MYSQL_AUTH_FAILED; protocol->protocol_auth_state = MYSQL_AUTH_FAILED;
LOGIF(LD, (skygw_log_write( MXS_DEBUG("%lu [gw_read_client_event] session "
LOGFILE_DEBUG, "creation failed. fd %d, "
"%lu [gw_read_client_event] session " "state = MYSQL_AUTH_FAILED.",
"creation failed. fd %d, " pthread_self(),
"state = MYSQL_AUTH_FAILED.", protocol->owner_dcb->fd);
pthread_self(),
protocol->owner_dcb->fd)));
/** Send ERR 1045 to client */ /** Send ERR 1045 to client */
mysql_send_auth_error( mysql_send_auth_error(
@ -1027,13 +1020,11 @@ int gw_read_client_event(
if (fail_str) if (fail_str)
free(fail_str); free(fail_str);
LOGIF(LD, (skygw_log_write( MXS_DEBUG("%lu [gw_read_client_event] after "
LOGFILE_DEBUG, "gw_mysql_do_authentication, fd %d, "
"%lu [gw_read_client_event] after " "state = MYSQL_AUTH_FAILED.",
"gw_mysql_do_authentication, fd %d, " pthread_self(),
"state = MYSQL_AUTH_FAILED.", protocol->owner_dcb->fd);
pthread_self(),
protocol->owner_dcb->fd)));
/** /**
* Release MYSQL_session since it is not used anymore. * Release MYSQL_session since it is not used anymore.
*/ */
@ -1153,10 +1144,8 @@ int gw_read_client_event(
*/ */
if (!succp) if (!succp)
{ {
LOGIF(LE, (skygw_log_write_flush( MXS_ERROR("Routing the query failed. "
LOGFILE_ERROR, "Session will be closed.");
"Error : Routing the query failed. "
"Session will be closed.")));
} }
while (read_buffer) while (read_buffer)
@ -1168,8 +1157,8 @@ int gw_read_client_event(
} }
else else
{ {
skygw_log_write_flush(LT,"Session received a query in state %s", MXS_INFO("Session received a query in state %s",
STRSESSIONSTATE(ses_state)); STRSESSIONSTATE(ses_state));
while((read_buffer = GWBUF_CONSUME_ALL(read_buffer)) != NULL); while((read_buffer = GWBUF_CONSUME_ALL(read_buffer)) != NULL);
goto return_rc; goto return_rc;
} }
@ -1328,10 +1317,9 @@ int gw_MySQLListener(DCB *listen_dcb,
if ((l_so = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) if ((l_so = socket(AF_UNIX, SOCK_STREAM, 0)) < 0)
{ {
char errbuf[STRERROR_BUFLEN]; char errbuf[STRERROR_BUFLEN];
skygw_log_write(LE, MXS_ERROR("Can't create UNIX socket: %i, %s",
"Error: Can't create UNIX socket: %i, %s", errno,
errno, strerror_r(errno, errbuf, sizeof(errbuf)));
strerror_r(errno, errbuf, sizeof(errbuf)));
return 0; return 0;
} }
memset(&local_addr, 0, sizeof(local_addr)); 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)) 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; return 0;
} }
@ -1356,10 +1344,9 @@ int gw_MySQLListener(DCB *listen_dcb,
if ((l_so = socket(AF_INET, SOCK_STREAM, 0)) < 0) if ((l_so = socket(AF_INET, SOCK_STREAM, 0)) < 0)
{ {
char errbuf[STRERROR_BUFLEN]; char errbuf[STRERROR_BUFLEN];
skygw_log_write(LE, MXS_ERROR("Can't create socket: %i, %s",
"Error: Can't create socket: %i, %s", errno,
errno, strerror_r(errno, errbuf, sizeof(errbuf)));
strerror_r(errno, errbuf, sizeof(errbuf)));
return 0; 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) if (setsockopt(l_so, SOL_SOCKET, SO_REUSEADDR, (char *) &one, sizeof(one)) != 0)
{ {
char errbuf[STRERROR_BUFLEN]; char errbuf[STRERROR_BUFLEN];
LOGIF(LE, (skygw_log_write_flush(LOGFILE_ERROR, MXS_ERROR("Failed to set socket options. Error %d: %s",
"Error: Failed to set socket options. Error %d: %s", errno,
errno, strerror_r(errno, errbuf, sizeof(errbuf)));
strerror_r(errno, errbuf, sizeof(errbuf)))));
} }
if (is_tcp) if (is_tcp)
@ -1384,16 +1370,15 @@ int gw_MySQLListener(DCB *listen_dcb,
char errbuf[STRERROR_BUFLEN]; char errbuf[STRERROR_BUFLEN];
if (setsockopt(l_so, IPPROTO_TCP, TCP_NODELAY, (char *) &one, sizeof(one)) != 0) if (setsockopt(l_so, IPPROTO_TCP, TCP_NODELAY, (char *) &one, sizeof(one)) != 0)
{ {
LOGIF(LE, (skygw_log_write_flush(LOGFILE_ERROR, MXS_ERROR("Failed to set socket options. Error %d: %s",
"Error: Failed to set socket options. Error %d: %s", errno,
errno, strerror_r(errno, errbuf, sizeof(errbuf)));
strerror_r(errno, errbuf, sizeof(errbuf)))));
} }
} }
// set NONBLOCKING mode // set NONBLOCKING mode
if (setnonblocking(l_so) != 0) 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); close(l_so);
return 0; return 0;
} }
@ -1406,18 +1391,17 @@ int gw_MySQLListener(DCB *listen_dcb,
if ((rc == -1) && (errno != ENOENT)) if ((rc == -1) && (errno != ENOENT))
{ {
char errbuf[STRERROR_BUFLEN]; char errbuf[STRERROR_BUFLEN];
skygw_log_write(LE, "Error: Failed to unlink Unix Socket %s: %d %s", MXS_ERROR("Failed to unlink Unix Socket %s: %d %s",
config_bind, errno, strerror_r(errno, errbuf, sizeof(errbuf))); config_bind, errno, strerror_r(errno, errbuf, sizeof(errbuf)));
} }
if (bind(l_so, (struct sockaddr *) &local_addr, sizeof(local_addr)) < 0) if (bind(l_so, (struct sockaddr *) &local_addr, sizeof(local_addr)) < 0)
{ {
char errbuf[STRERROR_BUFLEN]; char errbuf[STRERROR_BUFLEN];
skygw_log_write(LE, MXS_ERROR("Failed to bind to UNIX Domain socket '%s': %i, %s",
"Error: Failed to bind to UNIX Domain socket '%s': %i, %s", config_bind,
config_bind, errno,
errno, strerror_r(errno, errbuf, sizeof(errbuf)));
strerror_r(errno, errbuf, sizeof(errbuf)));
close(l_so); close(l_so);
return 0; return 0;
} }
@ -1426,31 +1410,28 @@ int gw_MySQLListener(DCB *listen_dcb,
if (chmod(config_bind, 0777) < 0) if (chmod(config_bind, 0777) < 0)
{ {
char errbuf[STRERROR_BUFLEN]; char errbuf[STRERROR_BUFLEN];
skygw_log_write(LE, MXS_ERROR("Failed to change permissions on UNIX Domain socket '%s': %i, %s",
"Error: Failed to change permissions on UNIX Domain socket '%s': %i, %s", config_bind,
config_bind, errno,
errno, strerror_r(errno, errbuf, sizeof(errbuf)));
strerror_r(errno, errbuf, sizeof(errbuf)));
} }
break; break;
case AF_INET: case AF_INET:
if (bind(l_so, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0) if (bind(l_so, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0)
{ {
char errbuf[STRERROR_BUFLEN]; char errbuf[STRERROR_BUFLEN];
skygw_log_write(LE, MXS_ERROR("Failed to bind on '%s': %i, %s",
"Error: Failed to bind on '%s': %i, %s", config_bind,
config_bind, errno,
errno, strerror_r(errno, errbuf, sizeof(errbuf)));
strerror_r(errno, errbuf, sizeof(errbuf)));
close(l_so); close(l_so);
return 0; return 0;
} }
break; break;
default: 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); close(l_so);
return 0; return 0;
} }
@ -1458,16 +1439,15 @@ int gw_MySQLListener(DCB *listen_dcb,
if (listen(l_so, 10 * SOMAXCONN) != 0) if (listen(l_so, 10 * SOMAXCONN) != 0)
{ {
char errbuf[STRERROR_BUFLEN]; char errbuf[STRERROR_BUFLEN];
skygw_log_write(LE, MXS_ERROR("Failed to start listening on '%s': %d, %s",
"Failed to start listening on '%s': %d, %s", config_bind,
config_bind, errno,
errno, strerror_r(errno, errbuf, sizeof(errbuf)));
strerror_r(errno, errbuf, sizeof(errbuf)));
close(l_so); close(l_so);
return 0; 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 // assign l_so to dcb
listen_dcb->fd = l_so; listen_dcb->fd = l_so;
@ -1475,9 +1455,8 @@ int gw_MySQLListener(DCB *listen_dcb,
// add listening socket to poll structure // add listening socket to poll structure
if (poll_add_dcb(listen_dcb) != 0) if (poll_add_dcb(listen_dcb) != 0)
{ {
skygw_log_write(LE, MXS_ERROR("MaxScale encountered system limit while "
"MaxScale encountered system limit while " "attempting to register on an epoll instance.");
"attempting to register on an epoll instance.");
return 0; return 0;
} }
#if defined(FAKE_CODE) #if defined(FAKE_CODE)
@ -1560,23 +1539,19 @@ int gw_MySQLAccept(DCB *listener)
* (EMFILE) max. number of files limit. * (EMFILE) max. number of files limit.
*/ */
char errbuf[STRERROR_BUFLEN]; char errbuf[STRERROR_BUFLEN];
LOGIF(LD, (skygw_log_write( MXS_DEBUG("%lu [gw_MySQLAccept] Error %d, %s. ",
LOGFILE_DEBUG, pthread_self(),
"%lu [gw_MySQLAccept] Error %d, %s. ", eno,
pthread_self(), strerror_r(eno, errbuf, sizeof(errbuf)));
eno,
strerror_r(eno, errbuf, sizeof(errbuf)))));
if (i == 0) if (i == 0)
{ {
char errbuf[STRERROR_BUFLEN]; char errbuf[STRERROR_BUFLEN];
LOGIF(LE, (skygw_log_write_flush( MXS_ERROR("Error %d, %s. "
LOGFILE_ERROR, "Failed to accept new client "
"Error %d, %s. " "connection.",
"Failed to accept new client " eno,
"connection.", strerror_r(eno, errbuf, sizeof(errbuf)));
eno,
strerror_r(eno, errbuf, sizeof(errbuf)))));
} }
i++; i++;
ts1.tv_nsec = 100*i*i*1000000; ts1.tv_nsec = 100*i*i*1000000;
@ -1594,18 +1569,14 @@ int gw_MySQLAccept(DCB *listener)
* Other error. * Other error.
*/ */
char errbuf[STRERROR_BUFLEN]; char errbuf[STRERROR_BUFLEN];
LOGIF(LD, (skygw_log_write( MXS_DEBUG("%lu [gw_MySQLAccept] Error %d, %s.",
LOGFILE_DEBUG, pthread_self(),
"%lu [gw_MySQLAccept] Error %d, %s.", eno,
pthread_self(), strerror_r(eno, errbuf, sizeof(errbuf)));
eno, MXS_ERROR("Failed to accept new client "
strerror_r(eno, errbuf, sizeof(errbuf))))); "connection due to %d, %s.",
LOGIF(LE, (skygw_log_write_flush( eno,
LOGFILE_ERROR, strerror_r(eno, errbuf, sizeof(errbuf)));
"Error : Failed to accept new client "
"connection due to %d, %s.",
eno,
strerror_r(eno, errbuf, sizeof(errbuf)))));
rc = 1; rc = 1;
goto return_rc; goto return_rc;
} /* if (eno == ..) */ } /* if (eno == ..) */
@ -1615,11 +1586,9 @@ int gw_MySQLAccept(DCB *listener)
listener->stats.n_accepts++; listener->stats.n_accepts++;
#if defined(SS_DEBUG) #if defined(SS_DEBUG)
LOGIF(LD, (skygw_log_write_flush( MXS_DEBUG("%lu [gw_MySQLAccept] Accepted fd %d.",
LOGFILE_DEBUG, pthread_self(),
"%lu [gw_MySQLAccept] Accepted fd %d.", c_sock);
pthread_self(),
c_sock)));
#endif /* SS_DEBUG */ #endif /* SS_DEBUG */
#if defined(FAKE_CODE) #if defined(FAKE_CODE)
conn_open[c_sock] = true; conn_open[c_sock] = true;
@ -1629,26 +1598,25 @@ int gw_MySQLAccept(DCB *listener)
char errbuf[STRERROR_BUFLEN]; char errbuf[STRERROR_BUFLEN];
if((syseno = setsockopt(c_sock, SOL_SOCKET, SO_SNDBUF, &sendbuf, optlen)) != 0){ 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; sendbuf = GW_CLIENT_SO_RCVBUF;
if((syseno = setsockopt(c_sock, SOL_SOCKET, SO_RCVBUF, &sendbuf, optlen)) != 0){ 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); setnonblocking(c_sock);
client_dcb = dcb_alloc(DCB_ROLE_REQUEST_HANDLER); client_dcb = dcb_alloc(DCB_ROLE_REQUEST_HANDLER);
if (client_dcb == NULL) { if (client_dcb == NULL) {
LOGIF(LE, (skygw_log_write_flush( MXS_ERROR("Failed to create DCB object for client connection.");
LOGFILE_ERROR, close(c_sock);
"Error : Failed to create " rc = 1;
"DCB object for client connection."))); goto return_rc;
close(c_sock);
rc = 1;
goto return_rc;
} }
client_dcb->service = listener->session->service; client_dcb->service = listener->session->service;
@ -1686,11 +1654,9 @@ int gw_MySQLAccept(DCB *listener)
if (protocol == NULL) { if (protocol == NULL) {
/** delete client_dcb */ /** delete client_dcb */
dcb_close(client_dcb); dcb_close(client_dcb);
LOGIF(LE, (skygw_log_write_flush( MXS_ERROR("%lu [gw_MySQLAccept] Failed to create "
LOGFILE_ERROR, "protocol object for client connection.",
"%lu [gw_MySQLAccept] Failed to create " pthread_self());
"protocol object for client connection.",
pthread_self())));
rc = 1; rc = 1;
goto return_rc; goto return_rc;
} }
@ -1722,25 +1688,21 @@ int gw_MySQLAccept(DCB *listener)
dcb_close(client_dcb); dcb_close(client_dcb);
/** Previous state is recovered in poll_add_dcb. */ /** Previous state is recovered in poll_add_dcb. */
LOGIF(LE, (skygw_log_write_flush( MXS_ERROR("%lu [gw_MySQLAccept] Failed to add dcb %p for "
LOGFILE_ERROR, "fd %d to epoll set.",
"%lu [gw_MySQLAccept] Failed to add dcb %p for " pthread_self(),
"fd %d to epoll set.", client_dcb,
pthread_self(), client_dcb->fd);
client_dcb,
client_dcb->fd)));
rc = 1; rc = 1;
goto return_rc; goto return_rc;
} }
else else
{ {
LOGIF(LD, (skygw_log_write( MXS_DEBUG("%lu [gw_MySQLAccept] Added dcb %p for fd "
LOGFILE_DEBUG, "%d to epoll set.",
"%lu [gw_MySQLAccept] Added dcb %p for fd " pthread_self(),
"%d to epoll set.", client_dcb,
pthread_self(), client_dcb->fd);
client_dcb,
client_dcb->fd)));
} }
} /**< while 1 */ } /**< while 1 */
#if defined(SS_DEBUG) #if defined(SS_DEBUG)
@ -1763,14 +1725,12 @@ static int gw_error_client_event(
session = dcb->session; session = dcb->session;
LOGIF(LD, (skygw_log_write( MXS_DEBUG("%lu [gw_error_client_event] Error event handling for DCB %p "
LOGFILE_DEBUG, "in state %s, session %p.",
"%lu [gw_error_client_event] Error event handling for DCB %p " pthread_self(),
"in state %s, session %p.", dcb,
pthread_self(), STRDCBSTATE(dcb->state),
dcb, (session != NULL ? session : NULL));
STRDCBSTATE(dcb->state),
(session != NULL ? session : NULL))));
if (session != NULL && session->state == SESSION_STATE_STOPPING) if (session != NULL && session->state == SESSION_STATE_STOPPING)
{ {
@ -1778,9 +1738,7 @@ static int gw_error_client_event(
} }
#if defined(SS_DEBUG) #if defined(SS_DEBUG)
LOGIF(LD, (skygw_log_write_flush( MXS_DEBUG("Client error event handling.");
LOGFILE_DEBUG,
"Client error event handling.")));
#endif #endif
dcb_close(dcb); dcb_close(dcb);
@ -1803,9 +1761,7 @@ gw_client_close(DCB *dcb)
if (!DCB_IS_CLONE(dcb)) CHK_PROTOCOL(protocol); if (!DCB_IS_CLONE(dcb)) CHK_PROTOCOL(protocol);
} }
#endif #endif
LOGIF(LD, (skygw_log_write(LOGFILE_DEBUG, MXS_DEBUG("%lu [gw_client_close]", pthread_self());
"%lu [gw_client_close]",
pthread_self())));
mysql_protocol_done(dcb); mysql_protocol_done(dcb);
session = dcb->session; session = dcb->session;
/** /**
@ -1975,9 +1931,9 @@ int do_ssl_accept(MySQLProtocol* protocol)
queue and wait for more.*/ queue and wait for more.*/
rval = 0; rval = 0;
skygw_log_write_flush(LT,"SSL_accept ongoing for %s@%s", MXS_INFO("SSL_accept ongoing for %s@%s",
protocol->owner_dcb->user, protocol->owner_dcb->user,
protocol->owner_dcb->remote); protocol->owner_dcb->remote);
return 0; return 0;
break; break;
case 1: case 1:
@ -1993,9 +1949,9 @@ int do_ssl_accept(MySQLProtocol* protocol)
rval = 1; rval = 1;
skygw_log_write_flush(LT,"SSL_accept done for %s@%s", MXS_INFO("SSL_accept done for %s@%s",
protocol->owner_dcb->user, protocol->owner_dcb->user,
protocol->owner_dcb->remote); protocol->owner_dcb->remote);
break; break;
case -1: case -1:
@ -2004,20 +1960,17 @@ int do_ssl_accept(MySQLProtocol* protocol)
protocol->protocol_auth_state = MYSQL_AUTH_SSL_HANDSHAKE_FAILED; protocol->protocol_auth_state = MYSQL_AUTH_SSL_HANDSHAKE_FAILED;
spinlock_release(&protocol->protocol_lock); spinlock_release(&protocol->protocol_lock);
rval = -1; rval = -1;
skygw_log_write_flush(LE, MXS_ERROR("Fatal error in SSL_accept for %s",
"Error: Fatal error in SSL_accept for %s", protocol->owner_dcb->remote);
protocol->owner_dcb->remote);
break; break;
default: default:
skygw_log_write_flush(LE, MXS_ERROR("Fatal error in SSL_accept, returned value was %d.", rval);
"Error: Fatal error in SSL_accept, returned value was %d.",
rval);
break; break;
} }
#ifdef SS_DEBUG #ifdef SS_DEBUG
skygw_log_write(LD,"[do_ssl_accept] Protocol state: %s", MXS_DEBUG("[do_ssl_accept] Protocol state: %s",
gw_mysql_protocol_state2string(protocol->protocol_auth_state)); gw_mysql_protocol_state2string(protocol->protocol_auth_state));
#endif #endif
return rval; return rval;

View File

@ -86,13 +86,11 @@ MySQLProtocol* mysql_protocol_init(
int eno = errno; int eno = errno;
errno = 0; errno = 0;
char errbuf[STRERROR_BUFLEN]; char errbuf[STRERROR_BUFLEN];
LOGIF(LE, (skygw_log_write_flush( MXS_ERROR("%lu [mysql_init_protocol] MySQL protocol init failed : "
LOGFILE_ERROR, "memory allocation due error %d, %s.",
"%lu [mysql_init_protocol] MySQL protocol init failed : " pthread_self(),
"memory allocation due error %d, %s.", eno,
pthread_self(), strerror_r(eno, errbuf, sizeof(errbuf)));
eno,
strerror_r(eno, errbuf, sizeof(errbuf)))));
goto return_p; goto return_p;
} }
p->protocol_state = MYSQL_PROTOCOL_ALLOC; p->protocol_state = MYSQL_PROTOCOL_ALLOC;
@ -187,13 +185,11 @@ int gw_read_backend_handshake(
if (h_len <= 4) { if (h_len <= 4) {
/* log error this exit point */ /* log error this exit point */
conn->protocol_auth_state = MYSQL_HANDSHAKE_FAILED; conn->protocol_auth_state = MYSQL_HANDSHAKE_FAILED;
LOGIF(LD, (skygw_log_write( MXS_DEBUG("%lu [gw_read_backend_handshake] after "
LOGFILE_DEBUG, "dcb_read, fd %d, "
"%lu [gw_read_backend_handshake] after " "state = MYSQL_HANDSHAKE_FAILED.",
"dcb_read, fd %d, " pthread_self(),
"state = MYSQL_HANDSHAKE_FAILED.", dcb->fd);
pthread_self(),
dcb->fd)));
return 1; return 1;
} }
@ -206,24 +202,20 @@ int gw_read_backend_handshake(
conn->protocol_auth_state = MYSQL_HANDSHAKE_FAILED; conn->protocol_auth_state = MYSQL_HANDSHAKE_FAILED;
LOGIF(LD, (skygw_log_write( MXS_DEBUG("%lu [gw_receive_backend_auth] Invalid "
LOGFILE_DEBUG, "authentication message from backend dcb %p "
"%lu [gw_receive_backend_auth] Invalid " "fd %d, ptr[4] = %d, error code %d, msg %s.",
"authentication message from backend dcb %p " pthread_self(),
"fd %d, ptr[4] = %d, error code %d, msg %s.", dcb,
pthread_self(), dcb->fd,
dcb, payload[4],
dcb->fd, errcode,
payload[4], bufstr);
errcode,
bufstr)));
LOGIF(LE, (skygw_log_write_flush( MXS_ERROR("Invalid authentication message "
LOGFILE_ERROR, "from backend. Error code: %d, Msg : %s",
"Error : Invalid authentication message " errcode,
"from backend. Error code: %d, Msg : %s", bufstr);
errcode,
bufstr)));
/** /**
* If ER_HOST_IS_BLOCKED is found * If ER_HOST_IS_BLOCKED is found
@ -232,12 +224,14 @@ int gw_read_backend_handshake(
*/ */
if (errcode == 1129) { if (errcode == 1129) {
LOGIF(LE, (skygw_log_write_flush( MXS_ERROR("Server %s has been put into maintenance mode due "
LOGFILE_ERROR, "to the server blocking connections from MaxScale. "
"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.", "Run 'mysqladmin -h %s -P %d flush-hosts' on this "
dcb->server->unique_name, "server before taking this server out of maintenance "
dcb->server->name, "mode.",
dcb->server->port))); dcb->server->unique_name,
dcb->server->name,
dcb->server->port);
server_set_status(dcb->server, SERVER_MAINT); server_set_status(dcb->server, SERVER_MAINT);
} }
@ -255,13 +249,11 @@ int gw_read_backend_handshake(
conn->protocol_auth_state = MYSQL_HANDSHAKE_FAILED; conn->protocol_auth_state = MYSQL_HANDSHAKE_FAILED;
LOGIF(LD, (skygw_log_write( MXS_DEBUG("%lu [gw_read_backend_handshake] after "
LOGFILE_DEBUG, "gw_mysql_get_byte3, fd %d, "
"%lu [gw_read_backend_handshake] after " "state = MYSQL_HANDSHAKE_FAILED.",
"gw_mysql_get_byte3, fd %d, " pthread_self(),
"state = MYSQL_HANDSHAKE_FAILED.", dcb->fd);
pthread_self(),
dcb->fd)));
return 1; return 1;
} }
@ -279,13 +271,11 @@ int gw_read_backend_handshake(
*/ */
conn->protocol_auth_state = MYSQL_HANDSHAKE_FAILED; conn->protocol_auth_state = MYSQL_HANDSHAKE_FAILED;
LOGIF(LD, (skygw_log_write( MXS_DEBUG("%lu [gw_read_backend_handshake] after "
LOGFILE_DEBUG, "gw_decode_mysql_server_handshake, fd %d, "
"%lu [gw_read_backend_handshake] after " "state = MYSQL_HANDSHAKE_FAILED.",
"gw_decode_mysql_server_handshake, fd %d, " pthread_self(),
"state = MYSQL_HANDSHAKE_FAILED.", conn->owner_dcb->fd);
pthread_self(),
conn->owner_dcb->fd)));
while((head = gwbuf_consume(head, GWBUF_LENGTH(head)))); while((head = gwbuf_consume(head, GWBUF_LENGTH(head))));
return 1; return 1;
} }
@ -445,24 +435,20 @@ int gw_receive_backend_auth(
char* err = strndup(&((char *)ptr)[8], 5); char* err = strndup(&((char *)ptr)[8], 5);
char* bufstr = strndup(&((char *)ptr)[13], len-4-5); char* bufstr = strndup(&((char *)ptr)[13], len-4-5);
LOGIF(LD, (skygw_log_write( MXS_DEBUG("%lu [gw_receive_backend_auth] Invalid "
LOGFILE_DEBUG, "authentication message from backend dcb %p "
"%lu [gw_receive_backend_auth] Invalid " "fd %d, ptr[4] = %d, error %s, msg %s.",
"authentication message from backend dcb %p " pthread_self(),
"fd %d, ptr[4] = %d, error %s, msg %s.", dcb,
pthread_self(), dcb->fd,
dcb, ptr[4],
dcb->fd, err,
ptr[4], bufstr);
err,
bufstr)));
LOGIF(LE, (skygw_log_write_flush( MXS_ERROR("Invalid authentication message "
LOGFILE_ERROR, "from backend. Error : %s, Msg : %s",
"Error : Invalid authentication message " err,
"from backend. Error : %s, Msg : %s", bufstr);
err,
bufstr)));
free(bufstr); free(bufstr);
free(err); free(err);
@ -470,21 +456,17 @@ int gw_receive_backend_auth(
} }
else else
{ {
LOGIF(LD, (skygw_log_write( MXS_DEBUG("%lu [gw_receive_backend_auth] Invalid "
LOGFILE_DEBUG, "authentication message from backend dcb %p "
"%lu [gw_receive_backend_auth] Invalid " "fd %d, ptr[4] = %d",
"authentication message from backend dcb %p " pthread_self(),
"fd %d, ptr[4] = %d", dcb,
pthread_self(), dcb->fd,
dcb, ptr[4]);
dcb->fd,
ptr[4])));
LOGIF(LE, (skygw_log_write_flush( MXS_ERROR("Invalid authentication message "
LOGFILE_ERROR, "from backend. Packet type : %d",
"Error : Invalid authentication message " ptr[4]);
"from backend. Packet type : %d",
ptr[4])));
} }
/*< /*<
* Remove data from buffer. * Remove data from buffer.
@ -498,33 +480,29 @@ int gw_receive_backend_auth(
* although no bytes was read. * although no bytes was read.
*/ */
rc = 0; rc = 0;
LOGIF(LD, (skygw_log_write( MXS_DEBUG("%lu [gw_receive_backend_auth] Read zero bytes from "
LOGFILE_DEBUG, "backend dcb %p fd %d in state %s. n %d, head %p, len %ld",
"%lu [gw_receive_backend_auth] Read zero bytes from " pthread_self(),
"backend dcb %p fd %d in state %s. n %d, head %p, len %ld", dcb,
pthread_self(), dcb->fd,
dcb, STRDCBSTATE(dcb->state),
dcb->fd, n,
STRDCBSTATE(dcb->state), head,
n, (head == NULL) ? 0 : GWBUF_LENGTH(head));
head,
(head == NULL) ? 0 : GWBUF_LENGTH(head))));
} }
else else
{ {
ss_dassert(n < 0 && head == NULL); ss_dassert(n < 0 && head == NULL);
rc = -1; rc = -1;
LOGIF(LD, (skygw_log_write_flush( MXS_DEBUG("%lu [gw_receive_backend_auth] Reading from backend dcb %p "
LOGFILE_DEBUG, "fd %d in state %s failed. n %d, head %p, len %ld",
"%lu [gw_receive_backend_auth] Reading from backend dcb %p " pthread_self(),
"fd %d in state %s failed. n %d, head %p, len %ld", dcb,
pthread_self(), dcb->fd,
dcb, STRDCBSTATE(dcb->state),
dcb->fd, n,
STRDCBSTATE(dcb->state), head,
n, (head == NULL) ? 0 : GWBUF_LENGTH(head));
head,
(head == NULL) ? 0 : GWBUF_LENGTH(head))));
} }
return rc; return rc;
@ -762,15 +740,13 @@ int gw_do_connect_to_backend(
if (so < 0) { if (so < 0) {
char errbuf[STRERROR_BUFLEN]; char errbuf[STRERROR_BUFLEN];
LOGIF(LE, (skygw_log_write_flush( MXS_ERROR("Establishing connection to backend server "
LOGFILE_ERROR, "%s:%d failed.\n\t\t Socket creation failed "
"Error: Establishing connection to backend server " "due %d, %s.",
"%s:%d failed.\n\t\t Socket creation failed " host,
"due %d, %s.", port,
host, errno,
port, strerror_r(errno, errbuf, sizeof(errbuf)));
errno,
strerror_r(errno, errbuf, sizeof(errbuf)))));
rv = -1; rv = -1;
goto return_rv; goto return_rv;
} }
@ -782,15 +758,13 @@ int gw_do_connect_to_backend(
if(setsockopt(so, SOL_SOCKET, SO_SNDBUF, &bufsize, sizeof(bufsize)) != 0) if(setsockopt(so, SOL_SOCKET, SO_SNDBUF, &bufsize, sizeof(bufsize)) != 0)
{ {
char errbuf[STRERROR_BUFLEN]; char errbuf[STRERROR_BUFLEN];
LOGIF(LE, (skygw_log_write_flush( MXS_ERROR("Failed to set socket options "
LOGFILE_ERROR, "%s:%d failed.\n\t\t Socket configuration failed "
"Error: Failed to set socket options " "due %d, %s.",
"%s:%d failed.\n\t\t Socket configuration failed " host,
"due %d, %s.", port,
host, errno,
port, strerror_r(errno, errbuf, sizeof(errbuf)));
errno,
strerror_r(errno, errbuf, sizeof(errbuf)))));
rv = -1; rv = -1;
/** Close socket */ /** Close socket */
goto close_so; goto close_so;
@ -800,15 +774,13 @@ int gw_do_connect_to_backend(
if(setsockopt(so, SOL_SOCKET, SO_RCVBUF, &bufsize, sizeof(bufsize)) != 0) if(setsockopt(so, SOL_SOCKET, SO_RCVBUF, &bufsize, sizeof(bufsize)) != 0)
{ {
char errbuf[STRERROR_BUFLEN]; char errbuf[STRERROR_BUFLEN];
LOGIF(LE, (skygw_log_write_flush( MXS_ERROR("Failed to set socket options "
LOGFILE_ERROR, "%s:%d failed.\n\t\t Socket configuration failed "
"Error: Failed to set socket options " "due %d, %s.",
"%s:%d failed.\n\t\t Socket configuration failed " host,
"due %d, %s.", port,
host, errno,
port, strerror_r(errno, errbuf, sizeof(errbuf)));
errno,
strerror_r(errno, errbuf, sizeof(errbuf)))));
rv = -1; rv = -1;
/** Close socket */ /** Close socket */
goto close_so; goto close_so;
@ -818,15 +790,13 @@ int gw_do_connect_to_backend(
if(setsockopt(so, IPPROTO_TCP, TCP_NODELAY, &one, sizeof(one)) != 0) if(setsockopt(so, IPPROTO_TCP, TCP_NODELAY, &one, sizeof(one)) != 0)
{ {
char errbuf[STRERROR_BUFLEN]; char errbuf[STRERROR_BUFLEN];
LOGIF(LE, (skygw_log_write_flush( MXS_ERROR("Failed to set socket options "
LOGFILE_ERROR, "%s:%d failed.\n\t\t Socket configuration failed "
"Error: Failed to set socket options " "due %d, %s.",
"%s:%d failed.\n\t\t Socket configuration failed " host,
"due %d, %s.", port,
host, errno,
port, strerror_r(errno, errbuf, sizeof(errbuf)));
errno,
strerror_r(errno, errbuf, sizeof(errbuf)))));
rv = -1; rv = -1;
/** Close socket */ /** Close socket */
goto close_so; goto close_so;
@ -845,27 +815,20 @@ int gw_do_connect_to_backend(
else else
{ {
char errbuf[STRERROR_BUFLEN]; char errbuf[STRERROR_BUFLEN];
LOGIF(LE, (skygw_log_write_flush( MXS_ERROR("Failed to connect backend server %s:%d, "
LOGFILE_ERROR, "due %d, %s.",
"Error: Failed to connect backend server %s:%d, " host,
"due %d, %s.", port,
host, errno,
port, strerror_r(errno, errbuf, sizeof(errbuf)));
errno,
strerror_r(errno, errbuf, sizeof(errbuf)))));
/** Close socket */ /** Close socket */
goto close_so; goto close_so;
} }
} }
*fd = so; *fd = so;
LOGIF(LD, (skygw_log_write_flush( MXS_DEBUG("%lu [gw_do_connect_to_backend] Connected to backend server "
LOGFILE_DEBUG, "%s:%d, fd %d.",
"%lu [gw_do_connect_to_backend] Connected to backend server " pthread_self(), host, port, so);
"%s:%d, fd %d.",
pthread_self(),
host,
port,
so)));
#if defined(FAKE_CODE) #if defined(FAKE_CODE)
conn_open[so] = true; conn_open[so] = true;
#endif /* FAKE_CODE */ #endif /* FAKE_CODE */
@ -878,13 +841,10 @@ close_so:
if (close(so) != 0) if (close(so) != 0)
{ {
char errbuf[STRERROR_BUFLEN]; char errbuf[STRERROR_BUFLEN];
LOGIF(LE, (skygw_log_write_flush( MXS_ERROR("Failed to close socket %d due %d, %s.",
LOGFILE_ERROR, so,
"Error: Failed to " errno,
"close socket %d due %d, %s.", strerror_r(errno, errbuf, sizeof(errbuf)));
so,
errno,
strerror_r(errno, errbuf, sizeof(errbuf)))));
} }
goto return_rv; 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); strcpy(key.hostname, dcb->remote);
} }
LOGIF(LD, MXS_DEBUG("%lu [MySQL Client Auth], checking user [%s@%s]%s%s",
(skygw_log_write_flush( pthread_self(),
LOGFILE_DEBUG, key.user,
"%lu [MySQL Client Auth], checking user [%s@%s]%s%s", dcb->remote,
pthread_self(), key.resource != NULL ?" db: " :"",
key.user, key.resource != NULL ?key.resource :"");
dcb->remote,
key.resource != NULL ?" db: " :"",
key.resource != NULL ?key.resource :"")));
/* look for user@current_ipv4 now */ /* look for user@current_ipv4 now */
user_password = mysql_users_fetch(service->users, &key); 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)); memset(&key.ipv4, 0, sizeof(struct sockaddr_in));
key.netmask = 0; key.netmask = 0;
LOGIF(LD, MXS_DEBUG("%lu [MySQL Client Auth], checking user [%s@%s] with "
(skygw_log_write_flush( "wildcard host [%%]",
LOGFILE_DEBUG, pthread_self(),
"%lu [MySQL Client Auth], checking user [%s@%s] with wildcard host [%%]", key.user,
pthread_self(), dcb->remote);
key.user,
dcb->remote)));
user_password = mysql_users_fetch(service->users, &key); 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. * user@% not found.
*/ */
LOGIF(LD, MXS_DEBUG("%lu [MySQL Client Auth], user [%s@%s] not existent",
(skygw_log_write_flush( pthread_self(),
LOGFILE_DEBUG, key.user,
"%lu [MySQL Client Auth], user [%s@%s] not existent", dcb->remote);
pthread_self(),
key.user,
dcb->remote)));
LOGIF(LT,skygw_log_write_flush( MXS_INFO("Authentication Failed: user [%s@%s] not found.",
LOGFILE_ERROR, key.user,
"Authentication Failed: user [%s@%s] not found.", dcb->remote);
key.user,
dcb->remote));
break; break;
} }
@ -1622,14 +1572,12 @@ mysql_send_auth_error (
if (dcb->state != DCB_STATE_POLLING) if (dcb->state != DCB_STATE_POLLING)
{ {
LOGIF(LD, (skygw_log_write( MXS_DEBUG("%lu [mysql_send_auth_error] dcb %p is in a state %s, "
LOGFILE_DEBUG, "and it is not in epoll set anymore. Skip error sending.",
"%lu [mysql_send_auth_error] dcb %p is in a state %s, " pthread_self(),
"and it is not in epoll set anymore. Skip error sending.", dcb,
pthread_self(), STRDCBSTATE(dcb->state));
dcb, return 0;
STRDCBSTATE(dcb->state))));
return 0;
} }
mysql_errno = 1045; mysql_errno = 1045;
mysql_error_msg = "Access denied!"; mysql_error_msg = "Access denied!";
@ -1830,11 +1778,9 @@ void protocol_archive_srv_command(
s1 = &p->protocol_command; s1 = &p->protocol_command;
#if defined(EXTRA_SS_DEBUG) #if defined(EXTRA_SS_DEBUG)
LOGIF(LT, (skygw_log_write( MXS_INFO("Move command %s from fd %d to command history.",
LOGFILE_TRACE, STRPACKETTYPE(s1->scom_cmd),
"Move command %s from fd %d to command history.", p->owner_dcb->fd);
STRPACKETTYPE(s1->scom_cmd),
p->owner_dcb->fd)));
#endif #endif
/** Copy to history list */ /** Copy to history list */
if ((h1 = p->protocol_cmd_history) == NULL) 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); p->protocol_command.scom_next = server_command_init(NULL, cmd);
} }
#if defined(EXTRA_SS_DEBUG) #if defined(EXTRA_SS_DEBUG)
LOGIF(LT, (skygw_log_write( MXS_INFO("Added command %s to fd %d.",
LOGFILE_TRACE, STRPACKETTYPE(cmd),
"Added command %s to fd %d.", p->owner_dcb->fd);
STRPACKETTYPE(cmd),
p->owner_dcb->fd)));
c = &p->protocol_command; c = &p->protocol_command;
while (c != NULL && c->scom_cmd != MYSQL_COM_UNDEFINED) while (c != NULL && c->scom_cmd != MYSQL_COM_UNDEFINED)
{ {
LOGIF(LT, (skygw_log_write( MXS_INFO("fd %d : %d %s",
LOGFILE_TRACE, p->owner_dcb->fd,
"fd %d : %d %s", c->scom_cmd,
p->owner_dcb->fd, STRPACKETTYPE(c->scom_cmd));
c->scom_cmd, c = c->scom_next;
STRPACKETTYPE(c->scom_cmd))));
c = c->scom_next;
} }
#endif #endif
retblock: retblock:
@ -1944,11 +1886,9 @@ void protocol_remove_srv_command(
spinlock_acquire(&p->protocol_lock); spinlock_acquire(&p->protocol_lock);
s = &p->protocol_command; s = &p->protocol_command;
#if defined(EXTRA_SS_DEBUG) #if defined(EXTRA_SS_DEBUG)
LOGIF(LT, (skygw_log_write( MXS_INFO("Removed command %s from fd %d.",
LOGFILE_TRACE, STRPACKETTYPE(s->scom_cmd),
"Removed command %s from fd %d.", p->owner_dcb->fd);
STRPACKETTYPE(s->scom_cmd),
p->owner_dcb->fd)));
#endif #endif
if (s->scom_next == NULL) if (s->scom_next == NULL)
{ {
@ -1975,12 +1915,10 @@ mysql_server_cmd_t protocol_get_srv_command(
{ {
protocol_remove_srv_command(p); protocol_remove_srv_command(p);
} }
LOGIF(LD, (skygw_log_write( MXS_DEBUG("%lu [protocol_get_srv_command] Read command %s for fd %d.",
LOGFILE_DEBUG, pthread_self(),
"%lu [protocol_get_srv_command] Read command %s for fd %d.", STRPACKETTYPE(cmd),
pthread_self(), p->owner_dcb->fd);
STRPACKETTYPE(cmd),
p->owner_dcb->fd)));
return cmd; return cmd;
} }
@ -2235,10 +2173,8 @@ char *create_auth_fail_str(
if (errstr == NULL) if (errstr == NULL)
{ {
char errbuf[STRERROR_BUFLEN]; char errbuf[STRERROR_BUFLEN];
LOGIF(LE, (skygw_log_write_flush( MXS_ERROR("Memory allocation failed due to %s.",
LOGFILE_ERROR, strerror_r(errno, errbuf, sizeof(errbuf)));
"Error : Memory allocation failed due to %s.",
strerror_r(errno, errbuf, sizeof(errbuf)))));
goto retblock; goto retblock;
} }

View File

@ -116,9 +116,7 @@ version()
void void
ModuleInit() ModuleInit()
{ {
LOGIF(LT, (skygw_log_write( MXS_INFO("Initialise Telnetd Protocol module.");
LOGFILE_TRACE,
"Initialise Telnetd Protocol module.\n")));
} }
/** /**
@ -382,7 +380,8 @@ int syseno = 0;
if(syseno != 0){ if(syseno != 0){
char errbuf[STRERROR_BUFLEN]; 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; return 0;
} }
// set NONBLOCKING mode // set NONBLOCKING mode
@ -396,7 +395,7 @@ int syseno = 0;
rc = listen(listener->fd, SOMAXCONN); rc = listen(listener->fd, SOMAXCONN);
if (rc == 0) { 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 { } else {
int eno = errno; int eno = errno;
errno = 0; errno = 0;