diff --git a/src/common.c b/src/common.c index af3dd1b..b3844d0 100644 --- a/src/common.c +++ b/src/common.c @@ -338,6 +338,8 @@ int are told to its loop. errno is left as it was. */ void (*fiberblockfunc)(SOCKET s, short events) = NULL; void (*fiberclosefunc)(SOCKET s) = NULL; +/* set as well: whether this thread is a loop's, which is not to wait */ +int (*onloopfunc)(void) = NULL; #define BLOCKED(s, ev) do { if(fiberblockfunc && (errno == EAGAIN || errno == EWOULDBLOCK)) \ fiberblockfunc((s), (ev)); } while(0) diff --git a/src/log.c b/src/log.c index 6db8484..61dca96 100644 --- a/src/log.c +++ b/src/log.c @@ -1049,6 +1049,14 @@ static void logdirect(struct logger *lg, struct clientparam *param, const unsign unsigned msec, n = 0, lost = 0; int res = 0, reopened = 0; + /* a loop's thread does not wait for a log whose thread could not be + started, a database's or a server's: the line is dropped, counted */ + if(onloopfunc && onloopfunc()){ + _3proxy_mutex_lock(&lg->mutex); + lg->faildropped++; + _3proxy_mutex_unlock(&lg->mutex); + return; + } lognow(&sec, &msec); _3proxy_mutex_lock(&lg->mutex); if(lg->failed && sec - lg->failtime >= LOGRETRY){ diff --git a/src/mainloop.c b/src/mainloop.c index dd9b5eb..5d216f0 100644 --- a/src/mainloop.c +++ b/src/mainloop.c @@ -1177,6 +1177,7 @@ static int loopsstart(void){ sockmapcbfunc = fibermap; #endif fiberpollfunc = fiberpoll; + onloopfunc = onlooper; } _3proxy_mutex_unlock(&loops_mutex); return !i; diff --git a/src/proxy.h b/src/proxy.h index fa4cd38..c2097d0 100644 --- a/src/proxy.h +++ b/src/proxy.h @@ -340,6 +340,7 @@ int sockpoll(struct sockfuncs *sf, void *state, struct pollfd *fds, unsigned nfd extern int (*fiberpollfunc)(struct pollfd *fds, unsigned nfds, int timeout); extern void (*fiberblockfunc)(SOCKET s, short events); extern void (*fiberclosefunc)(SOCKET s); +extern int (*onloopfunc)(void); int sockreadable(SOCKET s); #ifndef _WIN32 int fdclose(int fd);