MINOR: session: don't always assume there's a listener

For outgoing connections initiated from an applet, there might not be
any listener. It's the case with peers, which resort to a hack consisting
in making the session's listener point to the peer. This listener is only
used for statistics now so it's much easier to check for its presence now.
This commit is contained in:
Thierry FOURNIER 2014-03-20 15:42:53 +01:00 committed by Willy Tarreau
parent f7e04e9c2f
commit a47a94fb13
1 changed files with 15 additions and 13 deletions

View File

@ -689,7 +689,7 @@ void session_process_counters(struct session *s)
if (objt_server(s->target))
objt_server(s->target)->counters.bytes_in += bytes;
if (s->listener->counters)
if (s->listener && s->listener->counters)
s->listener->counters->bytes_in += bytes;
for (i = 0; i < MAX_SESS_STKCTR; i++) {
@ -723,7 +723,7 @@ void session_process_counters(struct session *s)
if (objt_server(s->target))
objt_server(s->target)->counters.bytes_out += bytes;
if (s->listener->counters)
if (s->listener && s->listener->counters)
s->listener->counters->bytes_out += bytes;
for (i = 0; i < MAX_SESS_STKCTR; i++) {
@ -2447,20 +2447,22 @@ struct task *process_session(struct task *t)
s->fe->feconn--;
if (s->flags & SN_BE_ASSIGNED)
s->be->beconn--;
if (!(s->listener->options & LI_O_UNLIMITED))
actconn--;
jobs--;
s->listener->nbconn--;
if (s->listener->state == LI_FULL)
resume_listener(s->listener);
if (s->listener) {
if (!(s->listener->options & LI_O_UNLIMITED))
actconn--;
s->listener->nbconn--;
if (s->listener->state == LI_FULL)
resume_listener(s->listener);
/* Dequeues all of the listeners waiting for a resource */
if (!LIST_ISEMPTY(&global_listener_queue))
dequeue_all_listeners(&global_listener_queue);
/* Dequeues all of the listeners waiting for a resource */
if (!LIST_ISEMPTY(&global_listener_queue))
dequeue_all_listeners(&global_listener_queue);
if (!LIST_ISEMPTY(&s->fe->listener_queue) &&
(!s->fe->fe_sps_lim || freq_ctr_remain(&s->fe->fe_sess_per_sec, s->fe->fe_sps_lim, 0) > 0))
dequeue_all_listeners(&s->fe->listener_queue);
if (!LIST_ISEMPTY(&s->fe->listener_queue) &&
(!s->fe->fe_sps_lim || freq_ctr_remain(&s->fe->fe_sess_per_sec, s->fe->fe_sps_lim, 0) > 0))
dequeue_all_listeners(&s->fe->listener_queue);
}
if (unlikely((global.mode & MODE_DEBUG) &&
(!(global.mode & MODE_QUIET) || (global.mode & MODE_VERBOSE)))) {