]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: log: make sess_log() support sess=NULL
authorWilly Tarreau <w@1wt.eu>
Fri, 5 Oct 2018 08:22:27 +0000 (10:22 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 12 Oct 2018 14:58:01 +0000 (16:58 +0200)
At many places in muxes we'll have to add tests to check if the
connection is front or back before deciding to log. Instead let's
centralize this test in sess_log() to simply do nothing when sess=NULL.

src/log.c

index 32308fa020ade346e3b2d0e1ef506d691f39cdd7..cd9ff01b996b5db7a9bb6b6bc7855a58cbbfc7ff 100644 (file)
--- a/src/log.c
+++ b/src/log.c
@@ -2684,13 +2684,17 @@ void strm_log(struct stream *s)
  * cannot lead to the creation of a regular stream. Because of this the log
  * level is LOG_INFO or LOG_ERR depending on the "log-separate-error" setting
  * in the frontend. The caller must simply know that it should not call this
- * function to report unimportant events.
+ * function to report unimportant events. It is safe to call this function with
+ * sess==NULL (will not do anything).
  */
 void sess_log(struct session *sess)
 {
        int size, level;
        int sd_size = 0;
 
+       if (!sess)
+               return;
+
        if (LIST_ISEMPTY(&sess->fe->logsrvs))
                return;