Fix to unreported bug which printed result of getsockopt even in case when there was no socket error.

This commit is contained in:
VilhoRaatikka
2014-11-27 15:37:13 +02:00
parent d063df0f4a
commit 83f7203213
2 changed files with 23 additions and 21 deletions

View File

@ -1232,19 +1232,18 @@ bool service_set_param_value (
/* /*
* Function to find a string in typelib_t * Function to find a string in typelib_t
* (similar to find_type() of mysys/typelib.c) * (similar to find_type() of mysys/typelib.c)
* *
* SYNOPSIS * SYNOPSIS
* find_type() * find_type()
* lib typelib_t * lib typelib_t
* find String to find * find String to find
* length Length of string to find * length Length of string to find
* part_match Allow part matching of value * part_match Allow part matching of value
* *
* RETURN * RETURN
* 0 error * 0 error
* > 0 position in TYPELIB->type_names +1 * > 0 position in TYPELIB->type_names +1
*/ */
static int find_type( static int find_type(
typelib_t* tl, typelib_t* tl,
const char* needle, const char* needle,

View File

@ -552,7 +552,7 @@ static int gw_read_backend_event(DCB *dcb) {
{ {
client_protocol = SESSION_PROTOCOL(dcb->session, client_protocol = SESSION_PROTOCOL(dcb->session,
MySQLProtocol); MySQLProtocol);
if (client_protocol != NULL) if (client_protocol != NULL)
{ {
CHK_PROTOCOL(client_protocol); CHK_PROTOCOL(client_protocol);
@ -1065,18 +1065,21 @@ gw_backend_hangup(DCB *dcb)
if (ses_state != SESSION_STATE_ROUTER_READY) if (ses_state != SESSION_STATE_ROUTER_READY)
{ {
int error, len; int error, len;
char buf[100]; char buf[100];
len = sizeof(error); len = sizeof(error);
if (getsockopt(dcb->fd, SOL_SOCKET, SO_ERROR, &error, &len) == 0) if (getsockopt(dcb->fd, SOL_SOCKET, SO_ERROR, &error, &len) == 0)
{ {
strerror_r(error, buf, 100); if (error != 0)
LOGIF(LE, (skygw_log_write_flush( {
LOGFILE_ERROR, strerror_r(error, buf, 100);
"Hangup in session that is not ready for routing, " LOGIF(LE, (skygw_log_write_flush(
"Error reported is '%s'.", LOGFILE_ERROR,
buf))); "Hangup in session that is not ready for routing, "
"Error reported is '%s'.",
buf)));
}
} }
gwbuf_free(errbuf); gwbuf_free(errbuf);
goto retblock; goto retblock;