CLEANUP: ring: rename the ring lock "RING_LOCK" instead of "LOGSRV_LOCK"
authorWilly Tarreau <w@1wt.eu>
Wed, 20 Sep 2023 18:42:07 +0000 (20:42 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 20 Sep 2023 19:38:33 +0000 (21:38 +0200)
The ring lock was initially mostly used for the logs and used to inherit
its name in lock stats. Now that it's exclusively used by rings, let's
rename it accordingly.

dev/haring/haring.c
include/haproxy/sink.h
include/haproxy/thread.h
src/ring.c
src/sink.c
src/thread.c

index df455be..ee7e1aa 100644 (file)
@@ -131,7 +131,7 @@ int dump_ring(struct ring *ring, size_t ofs, int flags)
        }
 
        while (1) {
-               //HA_RWLOCK_RDLOCK(LOGSRV_LOCK, &ring->lock);
+               //HA_RWLOCK_RDLOCK(RING_LOCK, &ring->lock);
 
                if (ofs >= buf.size) {
                        fprintf(stderr, "FATAL error at %d\n", __LINE__);
@@ -199,7 +199,7 @@ int dump_ring(struct ring *ring, size_t ofs, int flags)
                }
 
                //HA_ATOMIC_INC(b_peek(&buf, ofs));
-               //HA_RWLOCK_RDUNLOCK(LOGSRV_LOCK, &ring->lock);
+               //HA_RWLOCK_RDUNLOCK(RING_LOCK, &ring->lock);
 
                if (!(flags & RING_WF_WAIT_MODE))
                        break;
index 50f82b1..59d4b1c 100644 (file)
@@ -58,9 +58,9 @@ static inline ssize_t sink_write(struct sink *sink, size_t maxlen,
                 * so that the dropped event arrives exactly at the right
                 * position.
                 */
-               HA_RWLOCK_WRLOCK(LOGSRV_LOCK, &sink->ctx.lock);
+               HA_RWLOCK_WRLOCK(RING_LOCK, &sink->ctx.lock);
                sent = sink_announce_dropped(sink, facility);
-               HA_RWLOCK_WRUNLOCK(LOGSRV_LOCK, &sink->ctx.lock);
+               HA_RWLOCK_WRUNLOCK(RING_LOCK, &sink->ctx.lock);
 
                if (!sent) {
                        /* we failed, we don't try to send our log as if it
@@ -70,9 +70,9 @@ static inline ssize_t sink_write(struct sink *sink, size_t maxlen,
                }
        }
 
-       HA_RWLOCK_RDLOCK(LOGSRV_LOCK, &sink->ctx.lock);
+       HA_RWLOCK_RDLOCK(RING_LOCK, &sink->ctx.lock);
        sent = __sink_write(sink, maxlen, msg, nmsg, level, facility, metadata);
-       HA_RWLOCK_RDUNLOCK(LOGSRV_LOCK, &sink->ctx.lock);
+       HA_RWLOCK_RDUNLOCK(RING_LOCK, &sink->ctx.lock);
 
  fail:
        if (unlikely(sent <= 0))
index df3c17b..b2e6014 100644 (file)
@@ -417,7 +417,7 @@ enum lock_label {
        PIPES_LOCK,
        TLSKEYS_REF_LOCK,
        AUTH_LOCK,
-       LOGSRV_LOCK,
+       RING_LOCK,
        DICT_LOCK,
        PROTO_LOCK,
        QUEUE_LOCK,
index 9b8863a..06b2cba 100644 (file)
@@ -133,7 +133,7 @@ struct ring *ring_resize(struct ring *ring, size_t size)
        if (!area)
                return NULL;
 
-       HA_RWLOCK_WRLOCK(LOGSRV_LOCK, &ring->lock);
+       HA_RWLOCK_WRLOCK(RING_LOCK, &ring->lock);
 
        /* recheck the buffer's size, it may have changed during the malloc */
        if (b_size(&ring->buf) < size) {
@@ -143,7 +143,7 @@ struct ring *ring_resize(struct ring *ring, size_t size)
                ring->buf.size = size;
        }
 
-       HA_RWLOCK_WRUNLOCK(LOGSRV_LOCK, &ring->lock);
+       HA_RWLOCK_WRUNLOCK(RING_LOCK, &ring->lock);
 
        free(area);
        return ring;
@@ -200,7 +200,7 @@ ssize_t ring_write(struct ring *ring, size_t maxlen, const struct ist pfx[], siz
 
        lenlen = varint_bytes(totlen);
 
-       HA_RWLOCK_WRLOCK(LOGSRV_LOCK, &ring->lock);
+       HA_RWLOCK_WRLOCK(RING_LOCK, &ring->lock);
        if (lenlen + totlen + 1 + 1 > b_size(buf))
                goto done_buf;
 
@@ -254,7 +254,7 @@ ssize_t ring_write(struct ring *ring, size_t maxlen, const struct ist pfx[], siz
                appctx_wakeup(appctx);
 
  done_buf:
-       HA_RWLOCK_WRUNLOCK(LOGSRV_LOCK, &ring->lock);
+       HA_RWLOCK_WRUNLOCK(RING_LOCK, &ring->lock);
        return sent;
 }
 
@@ -285,7 +285,7 @@ void ring_detach_appctx(struct ring *ring, struct appctx *appctx, size_t ofs)
        if (!ring)
                return;
 
-       HA_RWLOCK_WRLOCK(LOGSRV_LOCK, &ring->lock);
+       HA_RWLOCK_WRLOCK(RING_LOCK, &ring->lock);
        if (ofs != ~0) {
                /* reader was still attached */
                if (ofs < b_head_ofs(&ring->buf))
@@ -298,7 +298,7 @@ void ring_detach_appctx(struct ring *ring, struct appctx *appctx, size_t ofs)
                HA_ATOMIC_DEC(b_peek(&ring->buf, ofs));
        }
        HA_ATOMIC_DEC(&ring->readers_count);
-       HA_RWLOCK_WRUNLOCK(LOGSRV_LOCK, &ring->lock);
+       HA_RWLOCK_WRUNLOCK(RING_LOCK, &ring->lock);
 }
 
 /* Tries to attach CLI handler <appctx> as a new reader on ring <ring>. This is
@@ -353,11 +353,11 @@ int cli_io_handler_show_ring(struct appctx *appctx)
        if (unlikely(sc_opposite(sc)->flags & SC_FL_SHUT_DONE))
                return 1;
 
-       HA_RWLOCK_WRLOCK(LOGSRV_LOCK, &ring->lock);
+       HA_RWLOCK_WRLOCK(RING_LOCK, &ring->lock);
        LIST_DEL_INIT(&appctx->wait_entry);
-       HA_RWLOCK_WRUNLOCK(LOGSRV_LOCK, &ring->lock);
+       HA_RWLOCK_WRUNLOCK(RING_LOCK, &ring->lock);
 
-       HA_RWLOCK_RDLOCK(LOGSRV_LOCK, &ring->lock);
+       HA_RWLOCK_RDLOCK(RING_LOCK, &ring->lock);
 
        /* explanation for the initialization below: it would be better to do
         * this in the parsing function but this would occasionally result in
@@ -417,7 +417,7 @@ int cli_io_handler_show_ring(struct appctx *appctx)
        HA_ATOMIC_INC(b_peek(buf, ofs));
        last_ofs = b_tail_ofs(buf);
        ctx->ofs = b_peek_ofs(buf, ofs);
-       HA_RWLOCK_RDUNLOCK(LOGSRV_LOCK, &ring->lock);
+       HA_RWLOCK_RDUNLOCK(RING_LOCK, &ring->lock);
 
        if (ret && (ctx->flags & RING_WF_WAIT_MODE)) {
                /* we've drained everything and are configured to wait for more
@@ -425,10 +425,10 @@ int cli_io_handler_show_ring(struct appctx *appctx)
                 */
                if (!sc_oc(sc)->output && !(sc->flags & SC_FL_SHUT_DONE)) {
                        /* let's be woken up once new data arrive */
-                       HA_RWLOCK_WRLOCK(LOGSRV_LOCK, &ring->lock);
+                       HA_RWLOCK_WRLOCK(RING_LOCK, &ring->lock);
                        LIST_APPEND(&ring->waiters, &appctx->wait_entry);
                        ofs = b_tail_ofs(&ring->buf);
-                       HA_RWLOCK_WRUNLOCK(LOGSRV_LOCK, &ring->lock);
+                       HA_RWLOCK_WRUNLOCK(RING_LOCK, &ring->lock);
                        if (ofs != last_ofs) {
                                /* more data was added into the ring between the
                                 * unlock and the lock, and the writer might not
index 46fc965..8c03e68 100644 (file)
@@ -346,11 +346,11 @@ static void sink_forward_io_handler(struct appctx *appctx)
                goto close;
        }
 
-       HA_RWLOCK_WRLOCK(LOGSRV_LOCK, &ring->lock);
+       HA_RWLOCK_WRLOCK(RING_LOCK, &ring->lock);
        LIST_DEL_INIT(&appctx->wait_entry);
-       HA_RWLOCK_WRUNLOCK(LOGSRV_LOCK, &ring->lock);
+       HA_RWLOCK_WRUNLOCK(RING_LOCK, &ring->lock);
 
-       HA_RWLOCK_RDLOCK(LOGSRV_LOCK, &ring->lock);
+       HA_RWLOCK_RDLOCK(RING_LOCK, &ring->lock);
 
        /* explanation for the initialization below: it would be better to do
         * this in the parsing function but this would occasionally result in
@@ -409,14 +409,14 @@ static void sink_forward_io_handler(struct appctx *appctx)
        last_ofs = b_tail_ofs(buf);
        sft->ofs = b_peek_ofs(buf, ofs);
 
-       HA_RWLOCK_RDUNLOCK(LOGSRV_LOCK, &ring->lock);
+       HA_RWLOCK_RDUNLOCK(RING_LOCK, &ring->lock);
 
        if (ret) {
                /* let's be woken up once new data arrive */
-               HA_RWLOCK_WRLOCK(LOGSRV_LOCK, &ring->lock);
+               HA_RWLOCK_WRLOCK(RING_LOCK, &ring->lock);
                LIST_APPEND(&ring->waiters, &appctx->wait_entry);
                ofs = b_tail_ofs(buf);
-               HA_RWLOCK_WRUNLOCK(LOGSRV_LOCK, &ring->lock);
+               HA_RWLOCK_WRUNLOCK(RING_LOCK, &ring->lock);
                if (ofs != last_ofs) {
                        /* more data was added into the ring between the
                         * unlock and the lock, and the writer might not
@@ -478,11 +478,11 @@ static void sink_forward_oc_io_handler(struct appctx *appctx)
                goto close;
        }
 
-       HA_RWLOCK_WRLOCK(LOGSRV_LOCK, &ring->lock);
+       HA_RWLOCK_WRLOCK(RING_LOCK, &ring->lock);
        LIST_DEL_INIT(&appctx->wait_entry);
-       HA_RWLOCK_WRUNLOCK(LOGSRV_LOCK, &ring->lock);
+       HA_RWLOCK_WRUNLOCK(RING_LOCK, &ring->lock);
 
-       HA_RWLOCK_RDLOCK(LOGSRV_LOCK, &ring->lock);
+       HA_RWLOCK_RDLOCK(RING_LOCK, &ring->lock);
 
        /* explanation for the initialization below: it would be better to do
         * this in the parsing function but this would occasionally result in
@@ -544,13 +544,13 @@ static void sink_forward_oc_io_handler(struct appctx *appctx)
        HA_ATOMIC_INC(b_peek(buf, ofs));
        sft->ofs = b_peek_ofs(buf, ofs);
 
-       HA_RWLOCK_RDUNLOCK(LOGSRV_LOCK, &ring->lock);
+       HA_RWLOCK_RDUNLOCK(RING_LOCK, &ring->lock);
 
        if (ret) {
                /* let's be woken up once new data arrive */
-               HA_RWLOCK_WRLOCK(LOGSRV_LOCK, &ring->lock);
+               HA_RWLOCK_WRLOCK(RING_LOCK, &ring->lock);
                LIST_APPEND(&ring->waiters, &appctx->wait_entry);
-               HA_RWLOCK_WRUNLOCK(LOGSRV_LOCK, &ring->lock);
+               HA_RWLOCK_WRUNLOCK(RING_LOCK, &ring->lock);
                applet_have_no_more_data(appctx);
        }
        HA_SPIN_UNLOCK(SFT_LOCK, &sft->lock);
@@ -574,9 +574,9 @@ void __sink_forward_session_deinit(struct sink_forward_target *sft)
        if (!sink)
                return;
 
-       HA_RWLOCK_WRLOCK(LOGSRV_LOCK, &sink->ctx.ring->lock);
+       HA_RWLOCK_WRLOCK(RING_LOCK, &sink->ctx.ring->lock);
        LIST_DEL_INIT(&sft->appctx->wait_entry);
-       HA_RWLOCK_WRUNLOCK(LOGSRV_LOCK, &sink->ctx.ring->lock);
+       HA_RWLOCK_WRUNLOCK(RING_LOCK, &sink->ctx.ring->lock);
 
        sft->appctx = NULL;
        task_wakeup(sink->forward_task, TASK_WOKEN_MSG);
index 6c3eddd..cabc754 100644 (file)
@@ -450,7 +450,7 @@ static const char *lock_label(enum lock_label label)
        case PIPES_LOCK:           return "PIPES";
        case TLSKEYS_REF_LOCK:     return "TLSKEYS_REF";
        case AUTH_LOCK:            return "AUTH";
-       case LOGSRV_LOCK:          return "LOGSRV";
+       case RING_LOCK:            return "RING";
        case DICT_LOCK:            return "DICT";
        case PROTO_LOCK:           return "PROTO";
        case QUEUE_LOCK:           return "QUEUE";