Fixes to Coverity defects.
This commit is contained in:
@ -939,10 +939,10 @@ int dcb_read_n(
|
|||||||
goto return_n;
|
goto return_n;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (b == 0 && nread == 0)
|
if (b == 0)
|
||||||
{
|
{
|
||||||
/** Handle closed client socket */
|
/** Handle closed client socket */
|
||||||
if (dcb_isclient(dcb))
|
if (nread == 0 && dcb_isclient(dcb))
|
||||||
{
|
{
|
||||||
char c;
|
char c;
|
||||||
int l_errno = 0;
|
int l_errno = 0;
|
||||||
@ -964,11 +964,6 @@ int dcb_read_n(
|
|||||||
n = 0;
|
n = 0;
|
||||||
goto return_n;
|
goto return_n;
|
||||||
}
|
}
|
||||||
else if (b == 0)
|
|
||||||
{
|
|
||||||
n = 0;
|
|
||||||
goto return_n;
|
|
||||||
}
|
|
||||||
|
|
||||||
dcb->last_read = hkheartbeat;
|
dcb->last_read = hkheartbeat;
|
||||||
|
|
||||||
@ -1208,6 +1203,10 @@ int dcb_read_SSL(
|
|||||||
}
|
}
|
||||||
|
|
||||||
gwbuf_rtrim(buffer,bufsize - n);
|
gwbuf_rtrim(buffer,bufsize - n);
|
||||||
|
if(buffer == NULL)
|
||||||
|
{
|
||||||
|
goto return_n;
|
||||||
|
}
|
||||||
#ifdef SS_DEBUG
|
#ifdef SS_DEBUG
|
||||||
skygw_log_write(LD,"%lu SSL: Truncated buffer from %d to %d bytes. "
|
skygw_log_write(LD,"%lu SSL: Truncated buffer from %d to %d bytes. "
|
||||||
"Read %d bytes, %d bytes waiting.\n",pthread_self(),
|
"Read %d bytes, %d bytes waiting.\n",pthread_self(),
|
||||||
@ -1234,9 +1233,6 @@ int dcb_read_SSL(
|
|||||||
|
|
||||||
/*< Append read data to the gwbuf */
|
/*< Append read data to the gwbuf */
|
||||||
*head = gwbuf_append(*head, buffer);
|
*head = gwbuf_append(*head, buffer);
|
||||||
rc = ioctl(dcb->fd, FIONREAD, &b);
|
|
||||||
pending = SSL_pending(dcb->ssl);
|
|
||||||
|
|
||||||
} /*< while (true) */
|
} /*< while (true) */
|
||||||
return_n:
|
return_n:
|
||||||
return nread;
|
return nread;
|
||||||
@ -1639,16 +1635,6 @@ dcb_write_SSL(DCB *dcb, GWBUF *queue)
|
|||||||
dcb,
|
dcb,
|
||||||
STRDCBSTATE(dcb->state),
|
STRDCBSTATE(dcb->state),
|
||||||
dcb->fd,ssl_errno)));
|
dcb->fd,ssl_errno)));
|
||||||
if(ssl_errno == SSL_ERROR_SSL ||
|
|
||||||
ssl_errno == SSL_ERROR_SYSCALL)
|
|
||||||
{
|
|
||||||
while((ssl_errno = ERR_get_error()) != 0)
|
|
||||||
{
|
|
||||||
char errbuf[140];
|
|
||||||
ERR_error_string(ssl_errno,errbuf);
|
|
||||||
skygw_log_write(LD,"%s",errbuf);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1666,19 +1652,19 @@ dcb_write_SSL(DCB *dcb, GWBUF *queue)
|
|||||||
STRDCBSTATE(dcb->state),
|
STRDCBSTATE(dcb->state),
|
||||||
dcb->fd,
|
dcb->fd,
|
||||||
ssl_errno)));
|
ssl_errno)));
|
||||||
if(ssl_errno == SSL_ERROR_SSL)
|
if(ssl_errno == SSL_ERROR_SSL || ssl_errno == SSL_ERROR_SYSCALL)
|
||||||
{
|
{
|
||||||
|
if(ssl_errno == SSL_ERROR_SYSCALL)
|
||||||
|
{
|
||||||
|
skygw_log_write(LE,"%d:%s",errno,strerror(errno));
|
||||||
|
}
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
char errbuf[140];
|
char errbuf[140];
|
||||||
ERR_error_string(ssl_errno,errbuf);
|
ERR_error_string(ssl_errno,errbuf);
|
||||||
skygw_log_write(LE,"%s",errbuf);
|
skygw_log_write(LE,"%d:%s",ssl_errno,errbuf);
|
||||||
}while((ssl_errno = ERR_get_error()) != 0);
|
}while((ssl_errno = ERR_get_error()) != 0);
|
||||||
}
|
}
|
||||||
if(ssl_errno == SSL_ERROR_SYSCALL)
|
|
||||||
{
|
|
||||||
skygw_log_write(LE,"%d:%s",errno,strerror(errno));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if(w == 0)
|
else if(w == 0)
|
||||||
{
|
{
|
||||||
@ -1686,7 +1672,7 @@ dcb_write_SSL(DCB *dcb, GWBUF *queue)
|
|||||||
{
|
{
|
||||||
char errbuf[140];
|
char errbuf[140];
|
||||||
ERR_error_string(ssl_errno,errbuf);
|
ERR_error_string(ssl_errno,errbuf);
|
||||||
skygw_log_write(LE,"%s",errbuf);
|
skygw_log_write(LE,"%d:%s",ssl_errno,errbuf);
|
||||||
}while((ssl_errno = ERR_get_error()) != 0);
|
}while((ssl_errno = ERR_get_error()) != 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1695,16 +1681,14 @@ dcb_write_SSL(DCB *dcb, GWBUF *queue)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}while(w <= 0);
|
}while(w <= 0);
|
||||||
/*
|
|
||||||
* Pull the number of bytes we have written from
|
if(w <= 0)
|
||||||
* queue with have.
|
|
||||||
*/
|
|
||||||
if(w == -1)
|
|
||||||
{
|
{
|
||||||
while((queue = GWBUF_CONSUME_ALL(queue)));
|
break;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
/** Remove written bytes from the queue */
|
||||||
queue = gwbuf_consume(queue, w);
|
queue = gwbuf_consume(queue, w);
|
||||||
LOGIF(LD, (skygw_log_write(
|
LOGIF(LD, (skygw_log_write(
|
||||||
LOGFILE_DEBUG,
|
LOGFILE_DEBUG,
|
||||||
@ -1733,38 +1717,6 @@ dcb_write_SSL(DCB *dcb, GWBUF *queue)
|
|||||||
}
|
}
|
||||||
} /* if (dcb->writeq) */
|
} /* if (dcb->writeq) */
|
||||||
|
|
||||||
if (saved_errno != 0 &&
|
|
||||||
queue != NULL &&
|
|
||||||
saved_errno != EAGAIN &&
|
|
||||||
saved_errno != EWOULDBLOCK)
|
|
||||||
{
|
|
||||||
bool dolog = true;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Do not log if writing COM_QUIT to backend failed.
|
|
||||||
*/
|
|
||||||
if (GWBUF_IS_TYPE_MYSQL(queue))
|
|
||||||
{
|
|
||||||
uint8_t* data = GWBUF_DATA(queue);
|
|
||||||
|
|
||||||
if (data[4] == 0x01)
|
|
||||||
{
|
|
||||||
dolog = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (dolog)
|
|
||||||
{
|
|
||||||
LOGIF(LD, (skygw_log_write(
|
|
||||||
LOGFILE_DEBUG,
|
|
||||||
"%lu [dcb_write] Writing to %s socket failed due %d, %s.",
|
|
||||||
pthread_self(),
|
|
||||||
dcb_isclient(dcb) ? "client" : "backend server",
|
|
||||||
saved_errno,
|
|
||||||
strerror(saved_errno))));
|
|
||||||
}
|
|
||||||
spinlock_release(&dcb->writeqlock);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
spinlock_release(&dcb->writeqlock);
|
spinlock_release(&dcb->writeqlock);
|
||||||
|
|
||||||
if (dcb->high_water && dcb->writeqlen > dcb->high_water && below_water)
|
if (dcb->high_water && dcb->writeqlen > dcb->high_water && below_water)
|
||||||
|
@ -228,6 +228,12 @@ unsigned int randval;
|
|||||||
MAXKEYS key;
|
MAXKEYS key;
|
||||||
char secret_file[PATH_MAX + 10];
|
char secret_file[PATH_MAX + 10];
|
||||||
|
|
||||||
|
if(strlen(path) > PATH_MAX)
|
||||||
|
{
|
||||||
|
skygw_log_write(LOGFILE_ERROR,"Error: Pathname too long.");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
sprintf(secret_file,"%s/.secrets",path);
|
sprintf(secret_file,"%s/.secrets",path);
|
||||||
|
|
||||||
/* Open for writing | Create | Truncate the file for writing */
|
/* Open for writing | Create | Truncate the file for writing */
|
||||||
|
@ -268,7 +268,7 @@ GWPROTOCOL *funcs;
|
|||||||
/* Save authentication data to file cache */
|
/* Save authentication data to file cache */
|
||||||
char *ptr, path[PATH_MAX + 1];
|
char *ptr, path[PATH_MAX + 1];
|
||||||
int mkdir_rval = 0;
|
int mkdir_rval = 0;
|
||||||
strcpy(path, get_cachedir());
|
strncpy(path, get_cachedir(),PATH_MAX);
|
||||||
strncat(path, "/", 4096);
|
strncat(path, "/", 4096);
|
||||||
strncat(path, service->name, PATH_MAX);
|
strncat(path, service->name, PATH_MAX);
|
||||||
if (access(path, R_OK) == -1)
|
if (access(path, R_OK) == -1)
|
||||||
|
@ -155,7 +155,10 @@ startMonitor(void *arg,void* opt)
|
|||||||
else if(!strcmp(params->name,"script"))
|
else if(!strcmp(params->name,"script"))
|
||||||
{
|
{
|
||||||
if(handle->script)
|
if(handle->script)
|
||||||
|
{
|
||||||
free(handle->script);
|
free(handle->script);
|
||||||
|
handle->script = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if(access(params->value,X_OK) == 0)
|
if(access(params->value,X_OK) == 0)
|
||||||
{
|
{
|
||||||
|
@ -396,6 +396,7 @@ mlist_cursor_t* mlist_cursor_init(
|
|||||||
|
|
||||||
if (c == NULL) {
|
if (c == NULL) {
|
||||||
goto return_cursor;
|
goto return_cursor;
|
||||||
|
simple_mutex_unlock(&list->mlist_mutex);
|
||||||
}
|
}
|
||||||
c->mlcursor_chk_top = CHK_NUM_MLIST_CURSOR;
|
c->mlcursor_chk_top = CHK_NUM_MLIST_CURSOR;
|
||||||
c->mlcursor_chk_tail = CHK_NUM_MLIST_CURSOR;
|
c->mlcursor_chk_tail = CHK_NUM_MLIST_CURSOR;
|
||||||
@ -581,6 +582,7 @@ bool mlist_cursor_move_to_first(
|
|||||||
simple_mutex_lock(&list->mlist_mutex, true);
|
simple_mutex_lock(&list->mlist_mutex, true);
|
||||||
|
|
||||||
if (mc->mlcursor_list->mlist_deleted) {
|
if (mc->mlcursor_list->mlist_deleted) {
|
||||||
|
simple_mutex_unlock(&list->mlist_mutex);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
/** Set position point to first node */
|
/** Set position point to first node */
|
||||||
|
Reference in New Issue
Block a user