*/
int resume_listener(struct listener *l);
+/* Marks a ready listener as full so that the session code tries to re-enable
+ * it upon next close() using resume_listener().
+ */
+void listener_full(struct listener *l);
+
/* This function adds all of the protocol's listener's file descriptors to the
* polling lists when they are in the LI_LISTEN state. It is intended to be
* used as a protocol's generic enable_all() primitive, for use after the
return 1;
}
+/* Marks a ready listener as full so that the session code tries to re-enable
+ * it upon next close() using resume_listener().
+ */
+void listener_full(struct listener *l)
+{
+ if (l->state >= LI_READY) {
+ EV_FD_CLR(l->fd, DIR_RD);
+ l->state = LI_FULL;
+ }
+}
+
/* This function adds all of the protocol's listener's file descriptors to the
* polling lists when they are in the LI_LISTEN state. It is intended to be
* used as a protocol's generic enable_all() primitive, for use after the
#include <proto/log.h>
#include <proto/session.h>
#include <proto/pipe.h>
+#include <proto/protocols.h>
#include <proto/proto_http.h>
#include <proto/proto_tcp.h>
#include <proto/proxy.h>
actconn--;
jobs--;
s->listener->nbconn--;
- if (s->listener->state == LI_FULL &&
- s->listener->nbconn < s->listener->maxconn) {
- /* we should reactivate the listener */
- EV_FD_SET(s->listener->fd, DIR_RD);
- s->listener->state = LI_READY;
- }
+ if (s->listener->state == LI_FULL)
+ resume_listener(s->listener);
if (unlikely((global.mode & MODE_DEBUG) &&
(!(global.mode & MODE_QUIET) || (global.mode & MODE_VERBOSE)))) {
int ret;
if (unlikely(l->nbconn >= l->maxconn)) {
- EV_FD_CLR(l->fd, DIR_RD);
- l->state = LI_FULL;
+ listener_full(l);
return 0;
}
send_log(p, LOG_EMERG,
"Proxy %s reached system FD limit at %d. Please check system tunables.\n",
p->id, maxfd);
- if (l->nbconn) {
- EV_FD_CLR(l->fd, DIR_RD);
- l->state = LI_FULL;
- }
+ if (l->nbconn)
+ listener_full(l);
return 0;
case EMFILE:
if (p)
send_log(p, LOG_EMERG,
"Proxy %s reached process FD limit at %d. Please check 'ulimit-n' and restart.\n",
p->id, maxfd);
- if (l->nbconn) {
- EV_FD_CLR(l->fd, DIR_RD);
- l->state = LI_FULL;
- }
+ if (l->nbconn)
+ listener_full(l);
return 0;
case ENOBUFS:
case ENOMEM:
send_log(p, LOG_EMERG,
"Proxy %s reached system memory limit at %d sockets. Please check system tunables.\n",
p->id, maxfd);
- if (l->nbconn) {
- EV_FD_CLR(l->fd, DIR_RD);
- l->state = LI_FULL;
- }
+ if (l->nbconn)
+ listener_full(l);
return 0;
default:
return 0;
}
if (l->nbconn >= l->maxconn) {
- EV_FD_CLR(l->fd, DIR_RD);
- l->state = LI_FULL;
+ listener_full(l);
return 0;
}
+
} /* end of while (p->feconn < p->maxconn) */
return 0;
}