2020#include "sockhub.h"
2121
2222#define SOCKHUB_BUFFER_SIZE (1024*1024)
23+ #define ERR_BUF_SIZE 1024
2324
2425void 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