Remove dependency on skygw_utils.h
- STRERROR_BUFLEN moved to cdefs.h and renamed to MXS_STRERROR_BUFLEN. Better would be to provide a 'const char* mxs_strerror(int errno)' that would have a thread specific buffer for the error message. - MIN and MAX also moved to defs.h as MXS_MIN and MXS_MAX. - Now only mlist.h of the headers depend upon skygw_utils.h.
This commit is contained in:
@ -672,7 +672,7 @@ dcb_process_victim_queue(DCB *listofdcb)
|
||||
{
|
||||
int eno = errno;
|
||||
errno = 0;
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
char errbuf[MXS_STRERROR_BUFLEN];
|
||||
MXS_ERROR("%lu [dcb_process_victim_queue] Error : Failed to close "
|
||||
"socket %d on dcb %p due error %d, %s.",
|
||||
pthread_self(),
|
||||
@ -1003,7 +1003,7 @@ dcb_bytes_readable(DCB *dcb)
|
||||
|
||||
if (-1 == ioctl(dcb->fd, FIONREAD, &bytesavailable))
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
char errbuf[MXS_STRERROR_BUFLEN];
|
||||
/* <editor-fold defaultstate="collapsed" desc=" Error Logging "> */
|
||||
MXS_ERROR("%lu [dcb_read] Error : ioctl FIONREAD for dcb %p in "
|
||||
"state %s fd %d failed due error %d, %s.",
|
||||
@ -1069,10 +1069,10 @@ dcb_basic_read(DCB *dcb, int bytesavailable, int maxbytes, int nreadtotal, int *
|
||||
{
|
||||
GWBUF *buffer;
|
||||
|
||||
int bufsize = MIN(bytesavailable, MAX_BUFFER_SIZE);
|
||||
int bufsize = MXS_MIN(bytesavailable, MAX_BUFFER_SIZE);
|
||||
if (maxbytes)
|
||||
{
|
||||
bufsize = MIN(bufsize, maxbytes - nreadtotal);
|
||||
bufsize = MXS_MIN(bufsize, maxbytes - nreadtotal);
|
||||
}
|
||||
|
||||
if ((buffer = gwbuf_alloc(bufsize)) == NULL)
|
||||
@ -1081,7 +1081,7 @@ dcb_basic_read(DCB *dcb, int bytesavailable, int maxbytes, int nreadtotal, int *
|
||||
* This is a fatal error which should cause shutdown.
|
||||
* Todo shutdown if memory allocation fails.
|
||||
*/
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
char errbuf[MXS_STRERROR_BUFLEN];
|
||||
/* <editor-fold defaultstate="collapsed" desc=" Error Logging "> */
|
||||
MXS_ERROR("%lu [dcb_read] Error : Failed to allocate read buffer "
|
||||
"for dcb %p fd %d, due %d, %s.",
|
||||
@ -1102,7 +1102,7 @@ dcb_basic_read(DCB *dcb, int bytesavailable, int maxbytes, int nreadtotal, int *
|
||||
{
|
||||
if (errno != 0 && errno != EAGAIN && errno != EWOULDBLOCK)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
char errbuf[MXS_STRERROR_BUFLEN];
|
||||
/* <editor-fold defaultstate="collapsed" desc=" Error Logging "> */
|
||||
MXS_ERROR("%lu [dcb_read] Error : Read failed, dcb %p in state "
|
||||
"%s fd %d, due %d, %s.",
|
||||
@ -1211,7 +1211,7 @@ dcb_basic_read_SSL(DCB *dcb, int *nsingleread)
|
||||
* This is a fatal error which should cause shutdown.
|
||||
* Todo shutdown if memory allocation fails.
|
||||
*/
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
char errbuf[MXS_STRERROR_BUFLEN];
|
||||
/* <editor-fold defaultstate="collapsed" desc=" Error Logging "> */
|
||||
MXS_ERROR("%lu [dcb_read] Error : Failed to allocate read buffer "
|
||||
"for dcb %p fd %d, due %d, %s.",
|
||||
@ -1297,7 +1297,7 @@ dcb_basic_read_SSL(DCB *dcb, int *nsingleread)
|
||||
static int
|
||||
dcb_log_errors_SSL (DCB *dcb, const char *called_by, int ret)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
char errbuf[MXS_STRERROR_BUFLEN];
|
||||
unsigned long ssl_errno;
|
||||
|
||||
ssl_errno = ERR_get_error();
|
||||
@ -1327,7 +1327,7 @@ dcb_log_errors_SSL (DCB *dcb, const char *called_by, int ret)
|
||||
{
|
||||
while (ssl_errno != 0)
|
||||
{
|
||||
ERR_error_string_n(ssl_errno, errbuf, STRERROR_BUFLEN);
|
||||
ERR_error_string_n(ssl_errno, errbuf, MXS_STRERROR_BUFLEN);
|
||||
MXS_ERROR("%s", errbuf);
|
||||
ssl_errno = ERR_get_error();
|
||||
}
|
||||
@ -1475,7 +1475,7 @@ dcb_log_write_failure(DCB *dcb, GWBUF *queue, int eno)
|
||||
{
|
||||
if (eno == EPIPE)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
char errbuf[MXS_STRERROR_BUFLEN];
|
||||
MXS_DEBUG("%lu [dcb_write] Write to dcb "
|
||||
"%p in state %s fd %d failed "
|
||||
"due errno %d, %s",
|
||||
@ -1494,7 +1494,7 @@ dcb_log_write_failure(DCB *dcb, GWBUF *queue, int eno)
|
||||
eno != EAGAIN &&
|
||||
eno != EWOULDBLOCK)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
char errbuf[MXS_STRERROR_BUFLEN];
|
||||
MXS_ERROR("Write to dcb %p in "
|
||||
"state %s fd %d failed due "
|
||||
"errno %d, %s",
|
||||
@ -1528,7 +1528,7 @@ dcb_log_write_failure(DCB *dcb, GWBUF *queue, int eno)
|
||||
}
|
||||
if (dolog)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
char errbuf[MXS_STRERROR_BUFLEN];
|
||||
MXS_DEBUG("%lu [dcb_write] Writing to %s socket failed due %d, %s.",
|
||||
pthread_self(),
|
||||
DCB_ROLE_CLIENT_HANDLER == dcb->dcb_role ? "client" : "backend server",
|
||||
@ -2458,7 +2458,7 @@ gw_write(DCB *dcb, GWBUF *writeq, bool *stop_writing)
|
||||
saved_errno != EPIPE)
|
||||
#endif
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
char errbuf[MXS_STRERROR_BUFLEN];
|
||||
MXS_ERROR("Write to %s %s in state %s failed due errno %d, %s",
|
||||
DCB_STRTYPE(dcb), dcb->remote, STRDCBSTATE(dcb->state),
|
||||
saved_errno, strerror_r(saved_errno, errbuf, sizeof(errbuf)));
|
||||
@ -2802,7 +2802,7 @@ dcb_persistent_clean_count(DCB *dcb, bool cleanall)
|
||||
}
|
||||
persistentdcb = nextdcb;
|
||||
}
|
||||
server->persistmax = MAX(server->persistmax, count);
|
||||
server->persistmax = MXS_MAX(server->persistmax, count);
|
||||
spinlock_release(&server->persistlock);
|
||||
/** Call possible callback for this DCB in case of close */
|
||||
while (disposals)
|
||||
@ -3087,7 +3087,7 @@ dcb_accept(DCB *listener, GWPROTOCOL *protocol_funcs)
|
||||
int sendbuf;
|
||||
struct sockaddr_storage client_conn;
|
||||
socklen_t optlen = sizeof(sendbuf);
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
char errbuf[MXS_STRERROR_BUFLEN];
|
||||
|
||||
if ((c_sock = dcb_accept_one_connection(listener, (struct sockaddr *)&client_conn)) >= 0)
|
||||
{
|
||||
@ -3256,7 +3256,7 @@ dcb_accept_one_connection(DCB *listener, struct sockaddr *client_conn)
|
||||
|
||||
if (c_sock == -1)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
char errbuf[MXS_STRERROR_BUFLEN];
|
||||
/* Did not get a file descriptor */
|
||||
if (eno == EAGAIN || eno == EWOULDBLOCK)
|
||||
{
|
||||
@ -3348,7 +3348,7 @@ dcb_listen(DCB *listener, const char *config, const char *protocol_name)
|
||||
|
||||
if (listen(listener_socket, 10 * SOMAXCONN) != 0)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
char errbuf[MXS_STRERROR_BUFLEN];
|
||||
MXS_ERROR("Failed to start listening on '%s' with protocol '%s': %d, %s",
|
||||
config,
|
||||
protocol_name,
|
||||
@ -3402,7 +3402,7 @@ dcb_listen_create_socket_inet(const char *config_bind)
|
||||
/** Create the TCP socket */
|
||||
if ((listener_socket = socket(AF_INET, SOCK_STREAM, 0)) < 0)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
char errbuf[MXS_STRERROR_BUFLEN];
|
||||
MXS_ERROR("Can't create socket: %i, %s",
|
||||
errno,
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
@ -3426,7 +3426,7 @@ dcb_listen_create_socket_inet(const char *config_bind)
|
||||
|
||||
if (bind(listener_socket, (struct sockaddr *) &server_address, sizeof(server_address)) < 0)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
char errbuf[MXS_STRERROR_BUFLEN];
|
||||
MXS_ERROR("Failed to bind on '%s': %i, %s",
|
||||
config_bind,
|
||||
errno,
|
||||
@ -3469,7 +3469,7 @@ dcb_listen_create_socket_unix(const char *config_bind)
|
||||
// UNIX socket create
|
||||
if ((listener_socket = socket(AF_UNIX, SOCK_STREAM, 0)) < 0)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
char errbuf[MXS_STRERROR_BUFLEN];
|
||||
MXS_ERROR("Can't create UNIX socket: %i, %s",
|
||||
errno,
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
@ -3496,7 +3496,7 @@ dcb_listen_create_socket_unix(const char *config_bind)
|
||||
|
||||
if ((-1 == unlink(config_bind)) && (errno != ENOENT))
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
char errbuf[MXS_STRERROR_BUFLEN];
|
||||
MXS_ERROR("Failed to unlink Unix Socket %s: %d %s",
|
||||
config_bind, errno, strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
}
|
||||
@ -3504,7 +3504,7 @@ dcb_listen_create_socket_unix(const char *config_bind)
|
||||
/* Bind the socket to the Unix domain socket */
|
||||
if (bind(listener_socket, (struct sockaddr *) &local_addr, sizeof(local_addr)) < 0)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
char errbuf[MXS_STRERROR_BUFLEN];
|
||||
MXS_ERROR("Failed to bind to UNIX Domain socket '%s': %i, %s",
|
||||
config_bind,
|
||||
errno,
|
||||
@ -3516,7 +3516,7 @@ dcb_listen_create_socket_unix(const char *config_bind)
|
||||
/* set permission for all users */
|
||||
if (chmod(config_bind, 0777) < 0)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
char errbuf[MXS_STRERROR_BUFLEN];
|
||||
MXS_ERROR("Failed to change permissions on UNIX Domain socket '%s': %i, %s",
|
||||
config_bind,
|
||||
errno,
|
||||
@ -3543,7 +3543,7 @@ dcb_set_socket_option(int sockfd, int level, int optname, void *optval, socklen_
|
||||
{
|
||||
if (setsockopt(sockfd, level, optname, optval, optlen) != 0)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
char errbuf[MXS_STRERROR_BUFLEN];
|
||||
MXS_ERROR("Failed to set socket options. Error %d: %s",
|
||||
errno,
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
|
||||
Reference in New Issue
Block a user