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)) if (objt_server(s->target))
objt_server(s->target)->counters.bytes_in += bytes; objt_server(s->target)->counters.bytes_in += bytes;
if (s->listener->counters) if (s->listener && s->listener->counters)
s->listener->counters->bytes_in += bytes; s->listener->counters->bytes_in += bytes;
for (i = 0; i < MAX_SESS_STKCTR; i++) { for (i = 0; i < MAX_SESS_STKCTR; i++) {
@ -723,7 +723,7 @@ void session_process_counters(struct session *s)
if (objt_server(s->target)) if (objt_server(s->target))
objt_server(s->target)->counters.bytes_out += bytes; objt_server(s->target)->counters.bytes_out += bytes;
if (s->listener->counters) if (s->listener && s->listener->counters)
s->listener->counters->bytes_out += bytes; s->listener->counters->bytes_out += bytes;
for (i = 0; i < MAX_SESS_STKCTR; i++) { for (i = 0; i < MAX_SESS_STKCTR; i++) {
@ -2447,9 +2447,10 @@ struct task *process_session(struct task *t)
s->fe->feconn--; s->fe->feconn--;
if (s->flags & SN_BE_ASSIGNED) if (s->flags & SN_BE_ASSIGNED)
s->be->beconn--; s->be->beconn--;
jobs--;
if (s->listener) {
if (!(s->listener->options & LI_O_UNLIMITED)) if (!(s->listener->options & LI_O_UNLIMITED))
actconn--; actconn--;
jobs--;
s->listener->nbconn--; s->listener->nbconn--;
if (s->listener->state == LI_FULL) if (s->listener->state == LI_FULL)
resume_listener(s->listener); resume_listener(s->listener);
@ -2461,6 +2462,7 @@ struct task *process_session(struct task *t)
if (!LIST_ISEMPTY(&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)) (!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); dequeue_all_listeners(&s->fe->listener_queue);
}
if (unlikely((global.mode & MODE_DEBUG) && if (unlikely((global.mode & MODE_DEBUG) &&
(!(global.mode & MODE_QUIET) || (global.mode & MODE_VERBOSE)))) { (!(global.mode & MODE_QUIET) || (global.mode & MODE_VERBOSE)))) {