]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: log: make the backend fall back to the frontend when there's no stream
authorWilly Tarreau <w@1wt.eu>
Wed, 5 Sep 2018 13:07:15 +0000 (15:07 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 5 Sep 2018 18:01:23 +0000 (20:01 +0200)
This is already what happens before the backend is assigned, except that
now we don't need to dereference a NULL stream to figure this.

src/log.c

index 4e7818da06078a64b508cb3d20df407750578dce..2613940e7ec797c2acd62d41bb91bfeb3fa02ef8 100644 (file)
--- a/src/log.c
+++ b/src/log.c
@@ -1571,7 +1571,7 @@ void deinit_log_buffers()
 int sess_build_logline(struct session *sess, struct stream *s, char *dst, size_t maxsize, struct list *list_format)
 {
        struct proxy *fe = sess->fe;
-       struct proxy *be = s->be;
+       struct proxy *be = s ? s->be : fe;
        struct http_txn *txn = s->txn;
        struct buffer chunk;
        char *uri;
@@ -1995,7 +1995,7 @@ int sess_build_logline(struct session *sess, struct stream *s, char *dst, size_t
                                break;
 
                        case LOG_FMT_TD: // %Td
-                               if (s->be->mode == PR_MODE_HTTP)
+                               if (be->mode == PR_MODE_HTTP)
                                        ret = ltoa_o((s->logs.t_data >= 0) ? s->logs.t_close - s->logs.t_data : -1,
                                                     tmplog, dst + maxsize - tmplog);
                                else