Skip to content

Commit 866f8d1

Browse files
committed
Add more trace
1 parent e2954b8 commit 866f8d1

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

contrib/multimaster/sockhub/sockhub.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "sockhub.h"
2121

2222
#define SOCKHUB_BUFFER_SIZE (1024*1024)
23+
#define ERR_BUF_SIZE 1024
2324

2425
void ShubAddSocket(Shub* shub, int fd);
2526

@@ -30,7 +31,9 @@ inline void ShubAddSocket(Shub* shub, int fd)
3031
ev.events = EPOLLIN;
3132
ev.data.fd = fd;
3233
if (epoll_ctl(shub->epollfd, EPOLL_CTL_ADD, fd, &ev) < 0) {
33-
shub->params->error_handler("Failed to add socket to epoll set", SHUB_FATAL_ERROR);
34+
char buf[ERR_BUF_SIZE];
35+
sprintf(buf, "Failed to add socket %d to epoll set", fd);
36+
shub->params->error_handler(buf, SHUB_FATAL_ERROR);
3437
}
3538
#else
3639
FD_SET(fd, &shub->inset);
@@ -441,7 +444,7 @@ void ShubLoop(Shub* shub)
441444
/* read as much as possible */
442445
rc = ShubReadSocketEx(chan, &shub->in_buffer[pos + available], sizeof(ShubMessageHdr) - available, buffer_size - pos - available);
443446
if (rc < sizeof(ShubMessageHdr) - available) {
444-
char buf[1024];
447+
char buf[ERR_BUF_SIZE];
445448
sprintf(buf, "Failed to read local socket chan=%d, rc=%d, min requested=%ld, max requested=%d, errno=%d", chan, rc, sizeof(ShubMessageHdr) - available, buffer_size - pos - available, errno);
446449
shub->params->error_handler(buf, SHUB_RECOVERABLE_ERROR);
447450
//shub->params->error_handler("Failed to read local socket", SHUB_RECOVERABLE_ERROR);
@@ -480,7 +483,7 @@ void ShubLoop(Shub* shub)
480483
do {
481484
unsigned int n = processed + size > buffer_size ? buffer_size - processed : size;
482485
if (chan >= 0 && !ShubReadSocket(chan, shub->in_buffer + processed, n)) {
483-
char buf[1024];
486+
char buf[ERR_BUF_SIZE];
484487
sprintf(buf, "Failed to read local socket rc=%d, len=%d, errno=%d", rc, n, errno);
485488
shub->params->error_handler(buf, SHUB_RECOVERABLE_ERROR);
486489
//shub->params->error_handler("Failed to read local socket", SHUB_RECOVERABLE_ERROR);

0 commit comments

Comments
 (0)