log_manager.cc :

tuned error printing and log writing output format
dcb.c : 
	dcb_connect, check return value of poll_add_dcb and behave accordingly.
	dcb_write, in case of SIFPIPE, only write to trace log.
	dcb_close, dassert with incorrect dcb states.
gateway.c :
	added file_write_header to print header similar than in logs to stderr.
	main, add signal handler for SIGPIPE
poll.c : 
	poll_remove_dcb, don't fail if dcb is in NOPOLLING or in ZOMBIE states.
	poll_waitevents, write EPOLLHUPs to trace log, don't even attempt to write to closed socket.
readconnection.h : 
	shortened comment.
readwritesplit.h : 
	replaced generic names with more specific ones. 
httpd.c : 
	Check listen return value and behave accordingly.
mysql_backend.c : 
	 Tiny clean up.
mysql_client.c : 
	gw_MySQLListener, Check listen return value and behave accordingly. 
mysql_common.c : 
	Shortened a header.
telnetd.c : 
	telnetd_listen, check listen return value and behave accordingly.
readconnroute.c : 
	Tuned log writing format.
readwritesplit.c : 
	Added function search_backend_servers, which chooses suitable backend and master server among those known by Maxscale. Fixed clean-up routines. Not ready yet but works somehow.
testroute.c : 
	Cleanup.
skygw_utils.cc : 
	Log writing clean up.
This commit is contained in:
vraatikka
2013-10-04 12:06:44 +03:00
parent 9f2f0ac006
commit 849a366e95
14 changed files with 955 additions and 533 deletions

View File

@ -426,6 +426,7 @@ dcb_connect(SERVER *server, SESSION *session, const char *protocol)
DCB *dcb;
GWPROTOCOL *funcs;
int fd;
int rc;
if ((dcb = dcb_alloc(DCB_ROLE_REQUEST_HANDLER)) == NULL)
{
@ -483,7 +484,7 @@ int fd;
session->client,
session->client->fd);
}
ss_dassert(dcb->fd == -1);
ss_dassert(dcb->fd == -1); /**< must be uninitialized at this point */
/**
* Successfully connected to backend. Assign file descriptor to dcb
*/
@ -505,7 +506,13 @@ int fd;
/**
* Add the dcb in the poll set
*/
poll_add_dcb(dcb);
rc = poll_add_dcb(dcb);
if (rc == -1) {
dcb_set_state(dcb, DCB_STATE_DISCONNECTED, NULL);
dcb_final_free(dcb);
return NULL;
}
return dcb;
}
@ -518,7 +525,8 @@ int fd;
*
* @param dcb The DCB to read from
* @param head Pointer to linked list to append data to
* @return -1 on error, otherwise the number of read bytes on the last. 0 is returned if no data available.
* @return -1 on error, otherwise the number of read bytes on the last.
* 0 is returned if no data available.
* iteration of while loop.
*/
int
@ -694,15 +702,30 @@ int w, saved_errno = 0;
if (w < 0)
{
skygw_log_write_flush(
LOGFILE_ERROR,
"Error : Write to dcb %p in "
"state %s fd %d failed due errno %d, %s",
dcb,
STRDCBSTATE(dcb->state),
dcb->fd,
saved_errno,
strerror(saved_errno));
if (saved_errno == EPIPE) {
skygw_log_write(
LOGFILE_TRACE,
"%lu [dcb_write] Write to dcb "
"%p in state %s fd %d failed "
"due errno %d, %s",
pthread_self(),
dcb,
STRDCBSTATE(dcb->state),
dcb->fd,
saved_errno,
strerror(saved_errno));
} else {
skygw_log_write_flush(
LOGFILE_ERROR,
"Error : Write to dcb %p in "
"state %s fd %d failed due "
"errno %d, %s",
dcb,
STRDCBSTATE(dcb->state),
dcb->fd,
saved_errno,
strerror(saved_errno));
}
break;
}
@ -836,10 +859,17 @@ dcb_close(DCB *dcb)
int rc;
CHK_DCB(dcb);
ss_dassert(dcb->state == DCB_STATE_POLLING ||
dcb->state == DCB_STATE_NOPOLLING ||
dcb->state == DCB_STATE_ZOMBIE);
/**
* Stop dcb's listening and modify state accordingly.
*/
rc = poll_remove_dcb(dcb);
ss_dassert(dcb->state == DCB_STATE_NOPOLLING ||
dcb->state == DCB_STATE_ZOMBIE);
if (rc == 0) {
skygw_log_write(
@ -850,13 +880,15 @@ dcb_close(DCB *dcb)
dcb,
STRDCBSTATE(dcb->state));
} else {
skygw_log_write_flush(
LOGFILE_ERROR,
"Error : Removing dcb %p in state %s from "
"poll set failed.",
dcb,
STRDCBSTATE(dcb->state));
skygw_log_write(
LOGFILE_ERROR,
"%lu [dcb_close] Error : Removing dcb %p in state %s from "
"poll set failed.",
pthread_self(),
dcb,
STRDCBSTATE(dcb->state));
}
if (dcb->state == DCB_STATE_NOPOLLING) {
dcb_add_to_zombieslist(dcb);
}