mirror of
https://github.com/3proxy/3proxy.git
synced 2026-11-05 09:25:49 +08:00
Logs: a loop's thread does not write a log itself
A logger whose thread could not be started is written by its clients themselves. A client of a loop, a fiber or a callback on the loop's thread, would hold the loop while a database or a server takes its line, so on a loop's thread the line is dropped instead, counted as the log's lines dropped are. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
270b02293e
commit
a5806b70ae
@ -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)
|
||||
|
||||
|
||||
@ -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){
|
||||
|
||||
@ -1177,6 +1177,7 @@ static int loopsstart(void){
|
||||
sockmapcbfunc = fibermap;
|
||||
#endif
|
||||
fiberpollfunc = fiberpoll;
|
||||
onloopfunc = onlooper;
|
||||
}
|
||||
_3proxy_mutex_unlock(&loops_mutex);
|
||||
return !i;
|
||||
|
||||
@ -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);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user