This commit is contained in:
Markus Makela
2015-07-20 09:00:53 +03:00
4 changed files with 22 additions and 19 deletions

View File

@ -831,7 +831,7 @@ int dcb_read(
dcb->last_read = hkheartbeat; dcb->last_read = hkheartbeat;
bufsize = MIN(bytesavailable, MAX_BUFFER_SIZE); bufsize = MIN(bytesavailable, MAX_BUFFER_SIZE);
if (maxbytes) bufsize = MIN(bufsize, maxbytes); if (maxbytes) bufsize = MIN(bufsize, maxbytes-nreadtotal);
if ((buffer = gwbuf_alloc(bufsize)) == NULL) if ((buffer = gwbuf_alloc(bufsize)) == NULL)
{ {
@ -1152,8 +1152,12 @@ int below_water;
if (w < 0) if (w < 0)
{ {
dcb_log_write_failure(dcb, queue, errno); dcb_log_write_failure(dcb, queue, errno);
/*<
* What wasn't successfully written is stored to write queue
* for suspended write.
*/
atomic_add(&dcb->writeqlen, gwbuf_length(queue)); atomic_add(&dcb->writeqlen, gwbuf_length(queue));
dcb->writeq = queue; dcb->writeq = queue;
dcb->stats.n_buffered++; dcb->stats.n_buffered++;
spinlock_release(&dcb->writeqlock); spinlock_release(&dcb->writeqlock);
return 0; return 0;
@ -1173,11 +1177,6 @@ int below_water;
STRDCBSTATE(dcb->state), STRDCBSTATE(dcb->state),
dcb->fd))); dcb->fd)));
} /*< while (queue != NULL) */ } /*< while (queue != NULL) */
/*<
* What wasn't successfully written is stored to write queue
* for suspended write.
*/
dcb->writeq = queue;
} /* if (dcb->writeq) */ } /* if (dcb->writeq) */
@ -1188,11 +1187,10 @@ int below_water;
#if defined(FAKE_CODE) #if defined(FAKE_CODE)
/** /**
* Check the parameters for dcb_write * Fake code for dcb_write
* (Should have fuller description)
* *
* @param dcb The DCB of the client * @param dcb The DCB of the client
* @param queue Queue of buffers to write
* @return true if parameters acceptable, false otherwise
*/ */
static inline void static inline void
dcb_write_fake_code(DCB *dcb) dcb_write_fake_code(DCB *dcb)
@ -1227,17 +1225,18 @@ dcb_write_fake_code(DCB *dcb)
static inline bool static inline bool
dcb_write_parameter_check(DCB *dcb, GWBUF *queue) dcb_write_parameter_check(DCB *dcb, GWBUF *queue)
{ {
if (queue == NULL) return false;
if (dcb->fd <= 0) if (dcb->fd <= 0)
{ {
LOGIF(LE, (skygw_log_write_flush( LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR, LOGFILE_ERROR,
"Error : Write failed, dcb is %s.", "Error : Write failed, dcb is %s.",
dcb->fd == DCBFD_CLOSED ? "closed" : "cloned, not writable"))); dcb->fd == DCBFD_CLOSED ? "closed" : "cloned, not writable")));
return false; gwbuf_free(queue);
return false;
} }
if (queue == NULL) return false;
if (dcb->session == NULL || dcb->session->state != SESSION_STATE_STOPPING) if (dcb->session == NULL || dcb->session->state != SESSION_STATE_STOPPING)
{ {
/** /**
@ -1265,7 +1264,7 @@ dcb_write_parameter_check(DCB *dcb, GWBUF *queue)
dcb, dcb,
STRDCBSTATE(dcb->state), STRDCBSTATE(dcb->state),
dcb->fd))); dcb->fd)));
//ss_dassert(false); gwbuf_free(queue);
return false; return false;
} }
} }
@ -1309,7 +1308,7 @@ dcb_write_when_already_queued(DCB *dcb, GWBUF *queue)
* *
* @param dcb The DCB of the client * @param dcb The DCB of the client
* @param queue Queue of buffers to write * @param queue Queue of buffers to write
* @return 0 on failure, 1 on success * @param eno Error number for logging
*/ */
static void static void
dcb_log_write_failure(DCB *dcb, GWBUF *queue, int eno) dcb_log_write_failure(DCB *dcb, GWBUF *queue, int eno)
@ -1385,7 +1384,7 @@ dcb_log_write_failure(DCB *dcb, GWBUF *queue, int eno)
} }
/** /**
* Handle writing when there is already queued data * Last few things to do at end of a write
* *
* @param dcb The DCB of the client * @param dcb The DCB of the client
* @param below_water A boolean * @param below_water A boolean

View File

@ -540,7 +540,7 @@ GWBUF* modutil_get_complete_packets(GWBUF** p_readbuf)
{ {
GWBUF *buff = NULL, *packet; GWBUF *buff = NULL, *packet;
uint8_t *ptr; uint8_t *ptr;
int len,blen,total = 0; uint32_t len,blen,total = 0;
if(p_readbuf == NULL || (*p_readbuf) == NULL || if(p_readbuf == NULL || (*p_readbuf) == NULL ||
gwbuf_length(*p_readbuf) < 3) gwbuf_length(*p_readbuf) < 3)

View File

@ -310,7 +310,7 @@ static inline bool connect_to_db(MONITOR* mon,MONITOR_SERVERS *database)
mysql_options(database->con, MYSQL_OPT_READ_TIMEOUT, (void *)&read_timeout); mysql_options(database->con, MYSQL_OPT_READ_TIMEOUT, (void *)&read_timeout);
mysql_options(database->con, MYSQL_OPT_WRITE_TIMEOUT, (void *)&write_timeout); mysql_options(database->con, MYSQL_OPT_WRITE_TIMEOUT, (void *)&write_timeout);
return (mysql_real_connect(database->con, bool result = (mysql_real_connect(database->con,
database->server->name, database->server->name,
uname, uname,
dpwd, dpwd,
@ -318,6 +318,8 @@ static inline bool connect_to_db(MONITOR* mon,MONITOR_SERVERS *database)
database->server->port, database->server->port,
NULL, NULL,
0) != NULL); 0) != NULL);
free(dpwd);
return result;
} }
static inline void monitor_mysql100_db(MONITOR_SERVERS* database) static inline void monitor_mysql100_db(MONITOR_SERVERS* database)

View File

@ -1115,7 +1115,9 @@ int gw_read_client_event(
* send redundant COM_QUIT. * send redundant COM_QUIT.
*/ */
/* Temporarily suppressed: SESSION_ROUTE_QUERY(session, read_buffer); */ /* Temporarily suppressed: SESSION_ROUTE_QUERY(session, read_buffer); */
/** /* Replaced with freeing the read buffer. */
gwbuf_free(read_buffer);
/**
* Close router session which causes closing of backends. * Close router session which causes closing of backends.
*/ */
dcb_close(dcb); dcb_close(dcb);