20
20
#include "sockhub.h"
21
21
22
22
#define SOCKHUB_BUFFER_SIZE (1024*1024)
23
+ #define ERR_BUF_SIZE 1024
23
24
24
25
void ShubAddSocket (Shub * shub ,int fd );
25
26
@@ -30,7 +31,9 @@ inline void ShubAddSocket(Shub* shub, int fd)
30
31
ev .events = EPOLLIN ;
31
32
ev .data .fd = fd ;
32
33
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 );
34
37
}
35
38
#else
36
39
FD_SET (fd ,& shub -> inset );
@@ -441,7 +444,7 @@ void ShubLoop(Shub* shub)
441
444
/* read as much as possible */
442
445
rc = ShubReadSocketEx (chan ,& shub -> in_buffer [pos + available ],sizeof (ShubMessageHdr )- available ,buffer_size - pos - available );
443
446
if (rc < sizeof (ShubMessageHdr )- available ) {
444
- char buf [1024 ];
447
+ char buf [ERR_BUF_SIZE ];
445
448
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 );
446
449
shub -> params -> error_handler (buf ,SHUB_RECOVERABLE_ERROR );
447
450
//shub->params->error_handler("Failed to read local socket", SHUB_RECOVERABLE_ERROR);
@@ -480,7 +483,7 @@ void ShubLoop(Shub* shub)
480
483
do {
481
484
unsignedint n = processed + size > buffer_size ?buffer_size - processed :size ;
482
485
if (chan >=0 && !ShubReadSocket (chan ,shub -> in_buffer + processed ,n )) {
483
- char buf [1024 ];
486
+ char buf [ERR_BUF_SIZE ];
484
487
sprintf (buf ,"Failed to read local socket rc=%d, len=%d, errno=%d" ,rc ,n ,errno );
485
488
shub -> params -> error_handler (buf ,SHUB_RECOVERABLE_ERROR );
486
489
//shub->params->error_handler("Failed to read local socket", SHUB_RECOVERABLE_ERROR);