[MINOR] support a global jobs counter
This counter is incremented for each incoming connection and each active listener, and is used to prevent haproxy from stopping upon SIGUSR1. It will thus be possible for some tasks in increment this counter in order to prevent haproxy from dying until they have completed their job.
This commit is contained in:
parent
0f7f51fbe0
commit
af7ad00a99
@ -102,6 +102,7 @@ extern int pid; /* current process id */
|
||||
extern int relative_pid; /* process id starting at 1 */
|
||||
extern int actconn; /* # of active sessions */
|
||||
extern int listeners;
|
||||
extern int jobs; /* # of active jobs */
|
||||
extern char trash[BUFSIZE];
|
||||
extern char *swap_buffer;
|
||||
extern int nb_oldpids; /* contains the number of old pids found */
|
||||
|
@ -267,6 +267,7 @@ static int str2listener(char *str, struct proxy *curproxy)
|
||||
tcpv4_add_listener(l);
|
||||
}
|
||||
|
||||
jobs++;
|
||||
listeners++;
|
||||
} /* end for(port) */
|
||||
} /* end while(next) */
|
||||
|
@ -124,6 +124,7 @@ struct global global = {
|
||||
/*********************************************************************/
|
||||
|
||||
int stopping; /* non zero means stopping in progress */
|
||||
int jobs = 0; /* number of active jobs (conns, listeners, active tasks, ...) */
|
||||
|
||||
/* Here we store informations about the pids of the processes we may pause
|
||||
* or kill. We will send them a signal every 10 ms until we can bind to all
|
||||
@ -920,8 +921,8 @@ void run_poll_loop()
|
||||
* numbers of proxies. */
|
||||
maintain_proxies(&next);
|
||||
|
||||
/* stop when there's no connection left and we don't allow them anymore */
|
||||
if (!actconn && listeners == 0)
|
||||
/* stop when there's nothing left to do */
|
||||
if (jobs == 0)
|
||||
break;
|
||||
|
||||
/* The poller will ensure it returns around <next> */
|
||||
|
@ -615,6 +615,7 @@ void stop_proxy(struct proxy *p)
|
||||
if (l->state >= LI_ASSIGNED) {
|
||||
delete_listener(l);
|
||||
listeners--;
|
||||
jobs--;
|
||||
}
|
||||
}
|
||||
p->state = PR_STSTOPPED;
|
||||
|
@ -1999,6 +1999,7 @@ struct task *process_session(struct task *t)
|
||||
if (s->flags & SN_BE_ASSIGNED)
|
||||
s->be->beconn--;
|
||||
actconn--;
|
||||
jobs--;
|
||||
s->listener->nbconn--;
|
||||
if (s->listener->state == LI_FULL &&
|
||||
s->listener->nbconn < s->listener->maxconn) {
|
||||
|
@ -1191,6 +1191,7 @@ int stream_sock_accept(int fd)
|
||||
goto out_close;
|
||||
}
|
||||
|
||||
jobs++;
|
||||
actconn++;
|
||||
totalconn++;
|
||||
l->nbconn++;
|
||||
@ -1207,12 +1208,14 @@ int stream_sock_accept(int fd)
|
||||
EV_FD_CLR(fd, DIR_RD);
|
||||
p->state = PR_STIDLE;
|
||||
}
|
||||
jobs--;
|
||||
actconn--;
|
||||
l->nbconn--;
|
||||
goto out_close;
|
||||
}
|
||||
else if (unlikely(ret == 0)) {
|
||||
/* ignore this connection */
|
||||
jobs--;
|
||||
actconn--;
|
||||
l->nbconn--;
|
||||
close(cfd);
|
||||
|
Loading…
x
Reference in New Issue
Block a user