]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Minor cleanups in channel code
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Mon, 16 Dec 2019 07:53:35 +0000 (14:53 +0700)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Mon, 16 Dec 2019 08:40:39 +0000 (15:40 +0700)
Use REQUESTOR in place of "master" and "network", and RESPONDER in place of "worker". The channel code will likely be reused very soon to create module specific thread pools to deal with blocking requests, and it's confusing to use usecase specific terms in generic code.

Move all size_t to uint64_t.  Guessing the original author was just being lazy and didn't want to type %"PRIu64 in a bunch of places.

Rename "ctx" to "uctx" because that's what it is...

src/lib/io/channel.c
src/lib/io/channel.h
src/lib/io/network.c
src/lib/io/worker.c
src/tests/util/channel_test.c
src/tests/util/radius1_test.c
src/tests/util/worker_test.c

index a67e2117a05837d014746195604417e5dc5a852b..46981242c484c27bcb2108ca5eca040382c56e76 100644 (file)
@@ -32,7 +32,7 @@ RCSID("$Id$")
 /*
  *     Debugging, mainly for channel_test
  */
-#if 0
+#ifdef DEBUG_CHANNEL
 #define MPRINT(...) fprintf(stdout, __VA_ARGS__)
 #else
 #define MPRINT(...)
@@ -43,11 +43,21 @@ RCSID("$Id$")
  */
 #define ENABLE_SKIPS (0)
 
-#define TO_WORKER (0)
-#define FROM_WORKER (1)
+typedef enum {
+       TO_RESPONDER = 0,
+       TO_REQUESTOR = 1
+} fr_channel_direction_t;
+
+#ifdef DEBUG_CHANNEL
+static fr_table_num_sorted_t const channel_direction[] = {
+       { "to responder",       TO_RESPONDER },
+       { "to requestor",       TO_REQUESTOR },
+};
+size_t channel_direction_len = NUM_ELEMENTS(channel_direction);
+#endif
 
 #if 0
-#define SIGNAL_INTERVAL (1000000)      //!< The minimum interval between worker signals.
+#define SIGNAL_INTERVAL (1000000)      //!< The minimum interval between responder signals.
 #endif
 
 /** Size of the atomic queues
@@ -65,8 +75,8 @@ RCSID("$Id$")
 
 typedef enum fr_channel_signal_t {
        FR_CHANNEL_SIGNAL_ERROR                 = FR_CHANNEL_ERROR,
-       FR_CHANNEL_SIGNAL_DATA_TO_WORKER        = FR_CHANNEL_DATA_READY_WORKER,
-       FR_CHANNEL_SIGNAL_DATA_FROM_WORKER      = FR_CHANNEL_DATA_READY_NETWORK,
+       FR_CHANNEL_SIGNAL_DATA_TO_RESPONDER     = FR_CHANNEL_DATA_READY_RESPONDER,
+       FR_CHANNEL_SIGNAL_DATA_TO_REQUESTOR     = FR_CHANNEL_DATA_READY_REQUESTOR,
        FR_CHANNEL_SIGNAL_OPEN                  = FR_CHANNEL_OPEN,
        FR_CHANNEL_SIGNAL_CLOSE                 = FR_CHANNEL_CLOSE,
 
@@ -74,8 +84,8 @@ typedef enum fr_channel_signal_t {
         *      The preceding MUST be in the same order as fr_channel_event_t
         */
 
-       FR_CHANNEL_SIGNAL_DATA_DONE_WORKER,
-       FR_CHANNEL_SIGNAL_WORKER_SLEEPING,
+       FR_CHANNEL_SIGNAL_DATA_DONE_RESPONDER,
+       FR_CHANNEL_SIGNAL_RESPONDER_SLEEPING,
 } fr_channel_signal_t;
 
 typedef struct {
@@ -91,23 +101,25 @@ typedef struct {
  * than pushing 1M+ events per second through a kqueue.
  */
 typedef struct {
+       fr_channel_direction_t  direction;      //!< Use for debug messages.
+
        fr_control_t            *control;       //!< The control plane, consisting of an atomic queue and kqueue.
 
        fr_ring_buffer_t        *rb;            //!< Ring buffer for control-plane messages.
 
-       void                    *ctx;           //!< Worker context.
+       void                    *uctx;          //!< Worker context.
 
        fr_channel_recv_callback_t recv;        //!< callback for receiving messages
-       void                    *recv_ctx;      //!< context for receiving messages
+       void                    *recv_uctx;     //!< context for receiving messages
 
        int                     num_outstanding; //!< Number of outstanding requests with no reply.
        bool                    must_signal;    //!< we need to signal the other end
 
-       size_t                  num_signals;    //!< Number of kevent signals we've sent.
+       uint64_t                num_signals;    //!< Number of kevent signals we've sent.
 
-       size_t                  num_resignals;  //!< Number of signals resent.
+       uint64_t                num_resignals;  //!< Number of signals resent.
 
-       size_t                  num_kevents;    //!< Number of times we've looked at kevents.
+       uint64_t                num_kevents;    //!< Number of times we've looked at kevents.
 
        uint64_t                sequence;       //!< Sequence number for this channel.
        uint64_t                ack;            //!< Sequence number of the other end.
@@ -118,24 +130,25 @@ typedef struct {
        uint64_t                num_packets;    //!< Number of actual data packets.
 
        fr_time_t               last_write;     //!< Last write to the channel.
-       fr_time_t               last_read_other; //!< Last time we successfully read a message from the other the channe;
-       fr_time_t               message_interval; //!< Interval between messages.
+       fr_time_t               last_read_other; //!< Last time we successfully read a message from the other the channel
+       fr_time_delta_t         message_interval; //!< Interval between messages.
 
        fr_time_t               last_sent_signal; //!< The last time when we signaled the other end.
 
        fr_atomic_queue_t       *aq;            //!< The queue of messages - visible only to this channel.
+
 } fr_channel_end_t;
 
 typedef struct fr_channel_s fr_channel_t;
 
 /** A full channel, which consists of two ends
  *
- * A channel consists of the kqueue identifiers and an atomic queue in each
- * direction to allow for bidirectional communication.
+ * A channel consists of an I/O identifier that can be placed in kequeue
+ * and an atomic queue in each direction to allow for bidirectional communication.
  */
 struct fr_channel_s {
-       fr_time_t               cpu_time;       //!< Total time used by the worker for this channel.
-       fr_time_t               processing_time; //!< Time spent by the worker processing requests.
+       fr_time_t               cpu_time;       //!< Total time used by the responder for this channel.
+       fr_time_t               processing_time; //!< Time spent by the responder processing requests.
 
        bool                    active;         //!< Whether the channel is active.
        bool                    same_thread;    //!< are both ends in the same thread?
@@ -143,6 +156,19 @@ struct fr_channel_s {
        fr_channel_end_t        end[2];         //!< Two ends of the channel.
 };
 
+#ifdef DEBUG_CHANNEL
+static fr_table_num_sorted_t const channel_signals[] = {
+       { "error",                      FR_CHANNEL_ERROR                        },
+       { "data-to-responder",          FR_CHANNEL_SIGNAL_DATA_TO_RESPONDER     },
+       { "data-to-requestor",          FR_CHANNEL_DATA_READY_REQUESTOR         },
+       { "open",                       FR_CHANNEL_OPEN                         },
+       { "close",                      FR_CHANNEL_CLOSE                        },
+       { "data-done-responder",        FR_CHANNEL_SIGNAL_DATA_DONE_RESPONDER   },
+       { "responder-sleeping",         FR_CHANNEL_SIGNAL_RESPONDER_SLEEPING    },
+};
+size_t const channel_signals_len = NUM_ELEMENTS(channel_signals);
+#endif
+
 fr_table_num_sorted_t const channel_packet_priority[] = {
        { "high",       PRIORITY_HIGH           },
        { "low",        PRIORITY_LOW            },
@@ -155,16 +181,16 @@ size_t channel_packet_priority_len = NUM_ELEMENTS(channel_packet_priority);
 /** Create a new channel
  *
  * @param[in] ctx      The talloc_ctx to allocate channel data in.
- * @param[in] master   control plane.
- * @param[in] worker   control plane.
+ * @param[in] requestor        control plane.
+ * @param[in] responder        control plane.
  * @param[in] same     whether or not the channel is for the same thread
  * @return
  *     - NULL on error
  *     - channel on success
  */
-fr_channel_t *fr_channel_create(TALLOC_CTX *ctx, fr_control_t *master, fr_control_t *worker, bool same)
+fr_channel_t *fr_channel_create(TALLOC_CTX *ctx, fr_control_t *requestor, fr_control_t *responder, bool same)
 {
-       fr_time_t when;
+       fr_time_t now;
        fr_channel_t *ch;
 
        ch = talloc_zero(ctx, fr_channel_t);
@@ -176,35 +202,38 @@ fr_channel_t *fr_channel_create(TALLOC_CTX *ctx, fr_control_t *master, fr_contro
 
        ch->same_thread = same;
 
-       ch->end[TO_WORKER].aq = fr_atomic_queue_create(ch, ATOMIC_QUEUE_SIZE);
-       if (!ch->end[TO_WORKER].aq) {
+       ch->end[TO_RESPONDER].direction = TO_RESPONDER;
+       ch->end[TO_REQUESTOR].direction = TO_REQUESTOR;
+
+       ch->end[TO_RESPONDER].aq = fr_atomic_queue_create(ch, ATOMIC_QUEUE_SIZE);
+       if (!ch->end[TO_RESPONDER].aq) {
                talloc_free(ch);
                goto nomem;
        }
 
-       ch->end[FROM_WORKER].aq = fr_atomic_queue_create(ch, ATOMIC_QUEUE_SIZE);
-       if (!ch->end[FROM_WORKER].aq) {
+       ch->end[TO_REQUESTOR].aq = fr_atomic_queue_create(ch, ATOMIC_QUEUE_SIZE);
+       if (!ch->end[TO_REQUESTOR].aq) {
                talloc_free(ch);
                goto nomem;
        }
 
-       ch->end[TO_WORKER].control = worker;
-       ch->end[FROM_WORKER].control = master;
+       ch->end[TO_RESPONDER].control = responder;
+       ch->end[TO_REQUESTOR].control = requestor;
 
        /*
-        *      Create the ring buffer for the master to send
-        *      control-plane messages to the worker, and vice-versa.
+        *      Create the ring buffer for the requestor to send
+        *      control-plane messages to the responder, and vice-versa.
         */
-       ch->end[TO_WORKER].rb = fr_ring_buffer_create(ch, FR_CONTROL_MAX_MESSAGES * FR_CONTROL_MAX_SIZE);
-       if (!ch->end[TO_WORKER].rb) {
+       ch->end[TO_RESPONDER].rb = fr_ring_buffer_create(ch, FR_CONTROL_MAX_MESSAGES * FR_CONTROL_MAX_SIZE);
+       if (!ch->end[TO_RESPONDER].rb) {
        rb_nomem:
                fr_strerror_printf_push("Failed allocating ring buffer");
                talloc_free(ch);
                return NULL;
        }
 
-       ch->end[FROM_WORKER].rb = fr_ring_buffer_create(ch, FR_CONTROL_MAX_MESSAGES * FR_CONTROL_MAX_SIZE);
-       if (!ch->end[FROM_WORKER].rb) {
+       ch->end[TO_REQUESTOR].rb = fr_ring_buffer_create(ch, FR_CONTROL_MAX_MESSAGES * FR_CONTROL_MAX_SIZE);
+       if (!ch->end[TO_REQUESTOR].rb) {
                talloc_free(ch);
                goto rb_nomem;
        }
@@ -212,15 +241,15 @@ fr_channel_t *fr_channel_create(TALLOC_CTX *ctx, fr_control_t *master, fr_contro
        /*
         *      Initialize all of the timers to now.
         */
-       when = fr_time();
+       now = fr_time();
 
-       ch->end[TO_WORKER].last_write = when;
-       ch->end[TO_WORKER].last_read_other = when;
-       ch->end[TO_WORKER].last_sent_signal = when;
+       ch->end[TO_RESPONDER].last_write = now;
+       ch->end[TO_RESPONDER].last_read_other = now;
+       ch->end[TO_RESPONDER].last_sent_signal = now;
 
-       ch->end[FROM_WORKER].last_write = when;
-       ch->end[FROM_WORKER].last_read_other = when;
-       ch->end[FROM_WORKER].last_sent_signal = when;
+       ch->end[TO_REQUESTOR].last_write = now;
+       ch->end[TO_REQUESTOR].last_read_other = now;
+       ch->end[TO_REQUESTOR].last_sent_signal = now;
 
        ch->active = true;
 
@@ -232,7 +261,7 @@ fr_channel_t *fr_channel_create(TALLOC_CTX *ctx, fr_control_t *master, fr_contro
  *
  * Note that the caller doesn't care about data in the event, that is
  * sent via the atomic queue.  The kevent code takes care of
- * delivering the signal once, even if it's sent by multiple master
+ * delivering the signal once, even if it's sent by multiple requestor
  * threads.
  *
  * The thread watching the KQ knows which end it is.  So when it gets
@@ -260,6 +289,10 @@ static int fr_channel_data_ready(fr_channel_t *ch, fr_time_t when, fr_channel_en
        cc.ack = end->ack;
        cc.ch = ch;
 
+       MPRINT("Signalling %s, with %s\n",
+              fr_table_str_by_value(channel_direction, end->direction, "<INVALID>"),
+              fr_table_str_by_value(channel_signals, which, "<INVALID>"));
+
        return fr_control_message_send(end->control, end->rb, FR_CONTROL_ID_CHANNEL, &cc, sizeof(cc));
 }
 
@@ -282,74 +315,70 @@ int fr_channel_send_request(fr_channel_t *ch, fr_channel_data_t *cd)
 {
        uint64_t sequence;
        fr_time_t when, message_interval;
-       fr_channel_end_t *master;
+       fr_channel_end_t *requestor;
 
        /*
         *      Same thread?  Just call the "recv" function directly.
         */
        if (ch->same_thread) {
-               ch->end[FROM_WORKER].recv(ch->end[FROM_WORKER].recv_ctx, ch, cd);
+               ch->end[TO_REQUESTOR].recv(ch->end[TO_REQUESTOR].recv_uctx, ch, cd);
                return 0;
        }
 
-       master = &(ch->end[TO_WORKER]);
+       requestor = &(ch->end[TO_RESPONDER]);
        when = cd->m.when;
 
-       sequence = master->sequence + 1;
+       sequence = requestor->sequence + 1;
        cd->live.sequence = sequence;
-       cd->live.ack = master->ack;
+       cd->live.ack = requestor->ack;
 
        /*
         *      Push the message onto the queue for the other end.  If
         *      the push fails, the caller should try another queue.
         */
-       if (!fr_atomic_queue_push(master->aq, cd)) {
+       if (!fr_atomic_queue_push(requestor->aq, cd)) {
                fr_strerror_printf("Failed pushing to atomic queue");
-               while (fr_channel_recv_reply(ch)) {
-                       /* do nothing */
-               }
+               while (fr_channel_recv_reply(ch));
                return -1;
        }
 
-       master->sequence = sequence;
-       message_interval = when - master->last_write;
+       requestor->sequence = sequence;
+       message_interval = when - requestor->last_write;
 
-       if (!master->message_interval) {
-               master->message_interval = message_interval;
+       if (!requestor->message_interval) {
+               requestor->message_interval = message_interval;
        } else {
-               master->message_interval = RTT(master->message_interval, message_interval);
+               requestor->message_interval = RTT(requestor->message_interval, message_interval);
        }
 
-       rad_assert(master->last_write <= when);
-       master->last_write = when;
+       rad_assert(requestor->last_write <= when);
+       requestor->last_write = when;
 
-       master->num_outstanding++;
-       master->num_packets++;
+       requestor->num_outstanding++;
+       requestor->num_packets++;
 
-       MPRINT("MASTER requests %zd, num_outstanding %zd\n", master->num_packets, master->num_outstanding);
+       MPRINT("REQUESTOR requests %"PRIu64", num_outstanding %"PRIu64"\n", requestor->num_packets, requestor->num_outstanding);
 
 #if ENABLE_SKIPS
        /*
         *      We just sent the first packet.  There can't possibly be a reply, so don't bother looking.
         */
-       if (master->num_outstanding == 1) {
+       if (requestor->num_outstanding == 1) {
 
                /*
                 *      There is at least one old packet which is
                 *      outstanding, look for a reply.
                 */
-       } else if (master->num_outstanding > 1) {
-               while (fr_channel_recv_reply(ch)) {
-                       /* do nothing */
-               }
+       } else if (requestor->num_outstanding > 1) {
+               while (fr_channel_recv_reply(ch));
 
                /*
                 *      There's no reply yet, so we still have packets outstanding.
                 *      Or, there is a reply, and there are more packets outstanding.
                 *      Skip the signal.
                 */
-               if (!master->must_signal && (!*p_reply || (*p_reply && (master->num_outstanding > 1)))) {
-                       MPRINT("MASTER SKIPS signal\n");
+               if (!requestor->must_signal && (!*p_reply || (*p_reply && (requestor->num_outstanding > 1)))) {
+                       MPRINT("REQUESTOR SKIPS signal\n");
                        return 0;
                }
        }
@@ -358,12 +387,12 @@ int fr_channel_send_request(fr_channel_t *ch, fr_channel_data_t *cd)
        /*
         *      Tell the other end that there is new data ready.
         *
-        *      Ignore errors on signalling.  The worker already has
+        *      Ignore errors on signalling.  The responder already has
         *      the packet in its inbound queue, so at some point, it
         *      will pick up the message.
         */
-       MPRINT("MASTER SIGNALS\n");
-       (void) fr_channel_data_ready(ch, when, master, FR_CHANNEL_SIGNAL_DATA_TO_WORKER);
+       MPRINT("REQUESTOR SIGNALS\n");
+       (void) fr_channel_data_ready(ch, when, requestor, FR_CHANNEL_SIGNAL_DATA_TO_RESPONDER);
        return 0;
 }
 
@@ -377,13 +406,13 @@ int fr_channel_send_request(fr_channel_t *ch, fr_channel_data_t *cd)
 bool fr_channel_recv_reply(fr_channel_t *ch)
 {
        fr_channel_data_t *cd;
-       fr_channel_end_t *master;
+       fr_channel_end_t *requestor;
        fr_atomic_queue_t *aq;
 
-       rad_assert(ch->end[TO_WORKER].recv != NULL);
+       rad_assert(ch->end[TO_RESPONDER].recv != NULL);
 
-       aq = ch->end[FROM_WORKER].aq;
-       master = &(ch->end[TO_WORKER]);
+       aq = ch->end[TO_REQUESTOR].aq;
+       requestor = &(ch->end[TO_RESPONDER]);
 
        /*
         *      It's OK for the queue to be empty.
@@ -411,21 +440,21 @@ bool fr_channel_recv_reply(fr_channel_t *ch)
 
        /*
         *      Update the outbound channel with the knowledge that
-        *      we've received one more reply, and with the workers
+        *      we've received one more reply, and with the responders
         *      ACK.
         */
-       rad_assert(master->num_outstanding > 0);
-       rad_assert(cd->live.sequence > master->ack);
-       rad_assert(cd->live.sequence <= master->sequence); /* must have fewer replies than requests */
+       rad_assert(requestor->num_outstanding > 0);
+       rad_assert(cd->live.sequence > requestor->ack);
+       rad_assert(cd->live.sequence <= requestor->sequence); /* must have fewer replies than requests */
 
-       master->num_outstanding--;
-       master->ack = cd->live.sequence;
-       master->their_view_of_my_sequence = cd->live.ack;
+       requestor->num_outstanding--;
+       requestor->ack = cd->live.sequence;
+       requestor->their_view_of_my_sequence = cd->live.ack;
 
-       rad_assert(master->last_read_other <= cd->m.when);
-       master->last_read_other = cd->m.when;
+       rad_assert(requestor->last_read_other <= cd->m.when);
+       requestor->last_read_other = cd->m.when;
 
-       ch->end[TO_WORKER].recv(ch->end[TO_WORKER].recv_ctx, ch, cd);
+       ch->end[TO_RESPONDER].recv(ch->end[TO_RESPONDER].recv_uctx, ch, cd);
 
        return true;
 }
@@ -441,28 +470,28 @@ bool fr_channel_recv_reply(fr_channel_t *ch)
 bool fr_channel_recv_request(fr_channel_t *ch)
 {
        fr_channel_data_t *cd;
-       fr_channel_end_t *worker;
+       fr_channel_end_t *responder;
        fr_atomic_queue_t *aq;
 
-       aq = ch->end[TO_WORKER].aq;
-       worker = &(ch->end[FROM_WORKER]);
+       aq = ch->end[TO_RESPONDER].aq;
+       responder = &(ch->end[TO_REQUESTOR]);
 
        /*
         *      It's OK for the queue to be empty.
         */
        if (!fr_atomic_queue_pop(aq, (void **) &cd)) return false;
 
-       rad_assert(cd->live.sequence > worker->ack);
-       rad_assert(cd->live.sequence >= worker->sequence); /* must have more requests than replies */
+       rad_assert(cd->live.sequence > responder->ack);
+       rad_assert(cd->live.sequence >= responder->sequence); /* must have more requests than replies */
 
-       worker->num_outstanding++;
-       worker->ack = cd->live.sequence;
-       worker->their_view_of_my_sequence = cd->live.ack;
+       responder->num_outstanding++;
+       responder->ack = cd->live.sequence;
+       responder->their_view_of_my_sequence = cd->live.ack;
 
-       rad_assert(worker->last_read_other <= cd->m.when);
-       worker->last_read_other = cd->m.when;
+       rad_assert(responder->last_read_other <= cd->m.when);
+       responder->last_read_other = cd->m.when;
 
-       ch->end[FROM_WORKER].recv(ch->end[FROM_WORKER].recv_ctx, ch, cd);
+       ch->end[TO_REQUESTOR].recv(ch->end[TO_REQUESTOR].recv_uctx, ch, cd);
 
        return true;
 }
@@ -481,66 +510,62 @@ int fr_channel_send_reply(fr_channel_t *ch, fr_channel_data_t *cd)
 {
        uint64_t sequence;
        fr_time_t when, message_interval;
-       fr_channel_end_t *worker;
+       fr_channel_end_t *responder;
 
        /*
         *      Same thread?  Just call the "recv" function directly.
         */
        if (ch->same_thread) {
-               ch->end[TO_WORKER].recv(ch->end[TO_WORKER].recv_ctx, ch, cd);
+               ch->end[TO_RESPONDER].recv(ch->end[TO_RESPONDER].recv_uctx, ch, cd);
                return 0;
        }
 
-       worker = &(ch->end[FROM_WORKER]);
+       responder = &(ch->end[TO_REQUESTOR]);
 
        when = cd->m.when;
 
-       sequence = worker->sequence + 1;
+       sequence = responder->sequence + 1;
        cd->live.sequence = sequence;
-       cd->live.ack = worker->ack;
+       cd->live.ack = responder->ack;
 
-       if (!fr_atomic_queue_push(worker->aq, cd)) {
+       if (!fr_atomic_queue_push(responder->aq, cd)) {
                fr_strerror_printf("Failed pushing to atomic queue");
-               while (fr_channel_recv_request(ch)) {
-                       /* nothing */
-               }
+               while (fr_channel_recv_request(ch));
                return -1;
        }
 
-       rad_assert(worker->num_outstanding > 0);
-       worker->num_outstanding--;
-       worker->num_packets++;
+       rad_assert(responder->num_outstanding > 0);
+       responder->num_outstanding--;
+       responder->num_packets++;
 
-       MPRINT("\tWORKER replies %zd, num_outstanding %zd\n", worker->num_packets, worker->num_outstanding);
+       MPRINT("\tRESPONDER replies %"PRIu64", num_outstanding %"PRIu64"\n", responder->num_packets, responder->num_outstanding);
 
-       worker->sequence = sequence;
-       message_interval = when - worker->last_write;
-       worker->message_interval = RTT(worker->message_interval, message_interval);
+       responder->sequence = sequence;
+       message_interval = when - responder->last_write;
+       responder->message_interval = RTT(responder->message_interval, message_interval);
 
-       rad_assert(worker->last_write <= when);
-       worker->last_write = when;
+       rad_assert(responder->last_write <= when);
+       responder->last_write = when;
 
        /*
         *      Even if we think we have no more packets to process,
         *      the caller may have sent us one.  Go check the input
         *      channel.
         */
-       while (fr_channel_recv_request(ch)) {
-               /* nothing */
-       }
+       while (fr_channel_recv_request(ch));
 
        /*
-        *      No packets outstanding, we HAVE to signal the master
+        *      No packets outstanding, we HAVE to signal the requestor
         *      thread.
         */
-       if (worker->num_outstanding == 0) {
-               (void) fr_channel_data_ready(ch, when, worker, FR_CHANNEL_SIGNAL_DATA_DONE_WORKER);
+       if (responder->num_outstanding == 0) {
+               (void) fr_channel_data_ready(ch, when, responder, FR_CHANNEL_SIGNAL_DATA_DONE_RESPONDER);
                return 0;
        }
 
-       MPRINT("\twhen - last_read_other = %zd - %zd = %zd\n", when, worker->last_read_other, when - worker->last_read_other);
-       MPRINT("\twhen - last signal = %zd - %zd = %zd\n", when, worker->last_sent_signal, when - worker->last_sent_signal);
-       MPRINT("\tsequence - ack = %zd - %zd = %zd\n", worker->sequence, worker->their_view_of_my_sequence, worker->sequence - worker->their_view_of_my_sequence);
+       MPRINT("\twhen - last_read_other = %"PRIu64" - %"PRIu64" = %"PRIu64"\n", when, responder->last_read_other, when - responder->last_read_other);
+       MPRINT("\twhen - last signal = %"PRIu64" - %"PRIu64" = %"PRIu64"\n", when, responder->last_sent_signal, when - responder->last_sent_signal);
+       MPRINT("\tsequence - ack = %"PRIu64" - %"PRIu64" = %"PRIu64"\n", responder->sequence, responder->their_view_of_my_sequence, responder->sequence - responder->their_view_of_my_sequence);
 
 #ifdef __APPLE__
        /*
@@ -551,7 +576,7 @@ int fr_channel_send_reply(fr_channel_t *ch, fr_channel_data_t *cd)
         *      But... this doesn't appear to work on the Linux
         *      libkqueue implementation.
         */
-       if (worker->sequence_at_last_signal > worker->their_view_of_my_sequence) return 0;
+       if (responder->sequence_at_last_signal > responder->their_view_of_my_sequence) return 0;
 #endif
 
        /*
@@ -563,18 +588,18 @@ int fr_channel_send_reply(fr_channel_t *ch, fr_channel_data_t *cd)
         *      FIXME: make these limits configurable, or include
         *      predictions about packet processing time?
         */
-       rad_assert(worker->their_view_of_my_sequence <= worker->sequence);
+       rad_assert(responder->their_view_of_my_sequence <= responder->sequence);
 #if 0
-       if (((worker->sequence - worker->their_view_of_my_sequence) <= 1000) &&
-           ((when - worker->last_read_other < SIGNAL_INTERVAL) ||
-            ((when - worker->last_sent_signal) < SIGNAL_INTERVAL))) {
-               MPRINT("\tWORKER SKIPS signal\n");
+       if (((responder->sequence - their_view_of_my_sequence) <= 1000) &&
+           ((when - responder->last_read_other < SIGNAL_INTERVAL) ||
+            ((when - responder->last_sent_signal) < SIGNAL_INTERVAL))) {
+               MPRINT("\tRESPONDER SKIPS signal\n");
                return 0;
        }
 #endif
 
-       MPRINT("\tWORKER SIGNALS num_outstanding %zd\n", worker->num_outstanding);
-       (void) fr_channel_data_ready(ch, when, worker, FR_CHANNEL_SIGNAL_DATA_FROM_WORKER);
+       MPRINT("\tRESPONDER SIGNALS num_outstanding %"PRIu64"\n", responder->num_outstanding);
+       (void) fr_channel_data_ready(ch, when, responder, FR_CHANNEL_SIGNAL_DATA_TO_REQUESTOR);
        return 0;
 }
 
@@ -590,19 +615,19 @@ int fr_channel_send_reply(fr_channel_t *ch, fr_channel_data_t *cd)
  */
 int fr_channel_null_reply(fr_channel_t *ch)
 {
-       fr_channel_end_t *worker;
+       fr_channel_end_t *responder;
 
-       worker = &(ch->end[FROM_WORKER]);
+       responder = &(ch->end[TO_REQUESTOR]);
 
-       worker->sequence++;
+       responder->sequence++;
        return 0;
 }
 
 
 
-/** Signal a channel that the worker is sleeping
+/** Signal a channel that the responder is sleeping
  *
- * This function should be called from the workers idle loop.
+ * This function should be called from the responders idle loop.
  * i.e. only when it has nothing else to do.
  *
  * @param[in] ch       the channel to signal we're no longer listening on.
@@ -610,29 +635,29 @@ int fr_channel_null_reply(fr_channel_t *ch)
  *     - <0 on error
  *     - 0 on success
  */
-int fr_channel_worker_sleeping(fr_channel_t *ch)
+int fr_channel_responder_sleeping(fr_channel_t *ch)
 {
-       fr_channel_end_t *worker;
+       fr_channel_end_t *responder;
        fr_channel_control_t cc;
 
-       worker = &(ch->end[FROM_WORKER]);
+       responder = &(ch->end[TO_REQUESTOR]);
 
        /*
         *      We don't have any outstanding requests to process for
         *      this channel, don't signal the network thread that
         *      we're sleeping.  It already knows.
         */
-       if (worker->num_outstanding == 0) return 0;
+       if (responder->num_outstanding == 0) return 0;
 
-       worker->num_signals++;
+       responder->num_signals++;
 
-       cc.signal = FR_CHANNEL_SIGNAL_WORKER_SLEEPING;
-       cc.ack = worker->ack;
+       cc.signal = FR_CHANNEL_SIGNAL_RESPONDER_SLEEPING;
+       cc.ack = responder->ack;
        cc.ch = ch;
 
-       MPRINT("\tWORKER SLEEPING num_outstanding %zd, packets in %zd, packets out %zd\n", worker->num_outstanding,
-              ch->end[TO_WORKER].num_packets, worker->num_packets);
-       return fr_control_message_send(worker->control, worker->rb, FR_CONTROL_ID_CHANNEL, &cc, sizeof(cc));
+       MPRINT("\tRESPONDER SLEEPING num_outstanding %"PRIu64", packets in %"PRIu64", packets out %"PRIu64"\n", responder->num_outstanding,
+              ch->end[TO_RESPONDER].num_packets, responder->num_packets);
+       return fr_control_message_send(responder->control, responder->rb, FR_CONTROL_ID_CHANNEL, &cc, sizeof(cc));
 }
 
 
@@ -658,7 +683,7 @@ fr_channel_event_t fr_channel_service_message(fr_time_t when, fr_channel_t **p_c
        fr_channel_control_t cc;
        fr_channel_signal_t cs;
        fr_channel_event_t ce = FR_CHANNEL_ERROR;
-       fr_channel_end_t *master;
+       fr_channel_end_t *requestor;
        fr_channel_t *ch;
 
        rad_assert(data_size == sizeof(cc));
@@ -677,62 +702,62 @@ fr_channel_event_t fr_channel_service_message(fr_time_t when, fr_channel_t **p_c
         *      return them as-is.
         */
        case FR_CHANNEL_SIGNAL_ERROR:
-       case FR_CHANNEL_SIGNAL_DATA_TO_WORKER:
-       case FR_CHANNEL_SIGNAL_DATA_FROM_WORKER:
+       case FR_CHANNEL_SIGNAL_DATA_TO_RESPONDER:
+       case FR_CHANNEL_SIGNAL_DATA_TO_REQUESTOR:
        case FR_CHANNEL_SIGNAL_OPEN:
        case FR_CHANNEL_SIGNAL_CLOSE:
                MPRINT("channel got %d\n", cs);
                return (fr_channel_event_t) cs;
 
        /*
-        *      Only sent by the worker.  Both of these
+        *      Only sent by the responder.  Both of these
         *      situations are largely the same, except for
         *      return codes.
         */
-       case FR_CHANNEL_SIGNAL_DATA_DONE_WORKER:
-               MPRINT("channel got data_done_worker\n");
-               ce = FR_CHANNEL_DATA_READY_NETWORK;
-               ch->end[TO_WORKER].must_signal = true;
+       case FR_CHANNEL_SIGNAL_DATA_DONE_RESPONDER:
+               MPRINT("channel got data_done_responder\n");
+               ce = FR_CHANNEL_DATA_READY_REQUESTOR;
+               ch->end[TO_RESPONDER].must_signal = true;
                break;
 
-       case FR_CHANNEL_SIGNAL_WORKER_SLEEPING:
-               MPRINT("channel got worker_sleeping\n");
+       case FR_CHANNEL_SIGNAL_RESPONDER_SLEEPING:
+               MPRINT("channel got responder_sleeping\n");
                ce = FR_CHANNEL_NOOP;
-               ch->end[TO_WORKER].must_signal = true;
+               ch->end[TO_RESPONDER].must_signal = true;
                break;
        }
 
        /*
         *      Compare their ACK to the last sequence we
-        *      sent.  If it's different, we signal the worker
+        *      sent.  If it's different, we signal the responder
         *      to wake up.
         */
-       master = &ch->end[TO_WORKER];
+       requestor = &ch->end[TO_RESPONDER];
 #if ENABLE_SKIPS
-       if (!master->must_signal && (ack == master->sequence)) {
-               MPRINT("MASTER SKIPS signal AFTER CE %d num_outstanding %zd\n", cs, master->num_outstanding);
-               MPRINT("MASTER has ack %zd, my seq %zd my_view %zd\n", ack, master->sequence, master->their_view_of_my_sequence);
+       if (!requestor->must_signal && (ack == requestor->sequence)) {
+               MPRINT("REQUESTOR SKIPS signal AFTER CE %d num_outstanding %"PRIu64"\n", cs, requestor->num_outstanding);
+               MPRINT("REQUESTOR has ack %"PRIu64", my seq %"PRIu64" my_view %"PRIu64"\n", ack, requestor->sequence, requestor->their_view_of_my_sequence);
                return ce;
        }
 
        /*
-        *      The worker is sleeping or done.  There are more
+        *      The responder is sleeping or done.  There are more
         *      packets available, so we signal it to wake up again.
         */
-       rad_assert(ack <= master->sequence);
+       rad_assert(ack <= requestor->sequence);
 #endif
 
        /*
         *      We're signaling it again...
         */
-       master->num_resignals++;
+       requestor->num_resignals++;
 
        /*
-        *      The worker hasn't seen our last few packets.  Signal
+        *      The responder hasn't seen our last few packets.  Signal
         *      that there is data ready.
         */
-       MPRINT("MASTER SIGNALS AFTER CE %d\n", cs);
-       rcode = fr_channel_data_ready(ch, when, master, FR_CHANNEL_SIGNAL_DATA_TO_WORKER);
+       MPRINT("REQUESTOR SIGNALS AFTER CE %d\n", cs);
+       rcode = fr_channel_data_ready(ch, when, requestor, FR_CHANNEL_SIGNAL_DATA_TO_RESPONDER);
        if (rcode < 0) return FR_CHANNEL_ERROR;
 
        return ce;
@@ -756,10 +781,10 @@ int fr_channel_service_kevent(fr_channel_t *ch, fr_control_t *c, UNUSED struct k
 {
        (void) talloc_get_type_abort(ch, fr_channel_t);
 
-       if (c == ch->end[TO_WORKER].control) {
-               ch->end[TO_WORKER].num_kevents++;
+       if (c == ch->end[TO_RESPONDER].control) {
+               ch->end[TO_RESPONDER].num_kevents++;
        } else {
-               ch->end[FROM_WORKER].num_kevents++;
+               ch->end[TO_REQUESTOR].num_kevents++;
        }
 
        return 0;
@@ -781,14 +806,14 @@ bool fr_channel_active(fr_channel_t *ch)
        return ch->active;
 }
 
-/** Signal a worker that the channel is closing
+/** Signal a responder that the channel is closing
  *
  * @param[in] ch       The channel.
  * @return
  *     - <0 on error
  *     - 0 on success
  */
-int fr_channel_signal_worker_close(fr_channel_t *ch)
+int fr_channel_signal_responder_close(fr_channel_t *ch)
 {
        fr_channel_control_t cc;
 
@@ -797,10 +822,10 @@ int fr_channel_signal_worker_close(fr_channel_t *ch)
        ch->active = false;
 
        cc.signal = FR_CHANNEL_SIGNAL_CLOSE;
-       cc.ack = TO_WORKER;
+       cc.ack = TO_RESPONDER;
        cc.ch = ch;
 
-       return fr_control_message_send(ch->end[TO_WORKER].control, ch->end[TO_WORKER].rb, FR_CONTROL_ID_CHANNEL, &cc, sizeof(cc));
+       return fr_control_message_send(ch->end[TO_RESPONDER].control, ch->end[TO_RESPONDER].rb, FR_CONTROL_ID_CHANNEL, &cc, sizeof(cc));
 }
 
 /** Acknowledge that the channel is closing
@@ -810,7 +835,7 @@ int fr_channel_signal_worker_close(fr_channel_t *ch)
  *     - <0 on error
  *     - 0 on success
  */
-int fr_channel_worker_ack_close(fr_channel_t *ch)
+int fr_channel_responder_ack_close(fr_channel_t *ch)
 {
        fr_channel_control_t cc;
 
@@ -819,47 +844,47 @@ int fr_channel_worker_ack_close(fr_channel_t *ch)
        ch->active = false;
 
        cc.signal = FR_CHANNEL_SIGNAL_CLOSE;
-       cc.ack = FROM_WORKER;
+       cc.ack = TO_REQUESTOR;
        cc.ch = ch;
 
-       return fr_control_message_send(ch->end[FROM_WORKER].control, ch->end[FROM_WORKER].rb, FR_CONTROL_ID_CHANNEL, &cc, sizeof(cc));
+       return fr_control_message_send(ch->end[TO_REQUESTOR].control, ch->end[TO_REQUESTOR].rb, FR_CONTROL_ID_CHANNEL, &cc, sizeof(cc));
 }
 
-/** Add worker-specific data to a channel
+/** Add responder-specific data to a channel
  *
  * @param[in] ch       The channel.
- * @param[in] ctx      The context to add.
+ * @param[in] uctx     The context to add.
  */
-void fr_channel_worker_ctx_add(fr_channel_t *ch, void *ctx)
+void fr_channel_responder_uctx_add(fr_channel_t *ch, void *uctx)
 {
        (void) talloc_get_type_abort(ch, fr_channel_t);
 
-       ch->end[FROM_WORKER].ctx = ctx;
+       ch->end[TO_REQUESTOR].uctx = uctx;
 }
 
 
-/** Get worker-specific data from a channel
+/** Get responder-specific data from a channel
  *
  * @param[in] ch       The channel.
  */
-void *fr_channel_worker_ctx_get(fr_channel_t *ch)
+void *fr_channel_responder_uctx_get(fr_channel_t *ch)
 {
        (void) talloc_get_type_abort(ch, fr_channel_t);
 
-       return ch->end[FROM_WORKER].ctx;
+       return ch->end[TO_REQUESTOR].uctx;
 }
 
 
 /** Add network-specific data to a channel
  *
  * @param[in] ch       The channel.
- * @param[in] ctx      The context to add.
+ * @param[in] uctx     The context to add.
  */
-void fr_channel_network_ctx_add(fr_channel_t *ch, void *ctx)
+void fr_channel_requestor_uctx_add(fr_channel_t *ch, void *uctx)
 {
        (void) talloc_get_type_abort(ch, fr_channel_t);
 
-       ch->end[TO_WORKER].ctx = ctx;
+       ch->end[TO_RESPONDER].uctx = uctx;
 }
 
 
@@ -867,30 +892,30 @@ void fr_channel_network_ctx_add(fr_channel_t *ch, void *ctx)
  *
  * @param[in] ch       The channel.
  */
-void *fr_channel_network_ctx_get(fr_channel_t *ch)
+void *fr_channel_requestor_uctx_get(fr_channel_t *ch)
 {
        (void) talloc_get_type_abort(ch, fr_channel_t);
 
-       return ch->end[TO_WORKER].ctx;
+       return ch->end[TO_RESPONDER].uctx;
 }
 
 
-int fr_channel_set_recv_reply(fr_channel_t *ch, void *ctx, fr_channel_recv_callback_t recv_reply)
+int fr_channel_set_recv_reply(fr_channel_t *ch, void *uctx, fr_channel_recv_callback_t recv_reply)
 {
-       ch->end[TO_WORKER].recv = recv_reply;
-       ch->end[TO_WORKER].recv_ctx = ctx;
+       ch->end[TO_RESPONDER].recv = recv_reply;
+       ch->end[TO_RESPONDER].recv_uctx = uctx;
 
        return 0;
 }
 
-int fr_channel_set_recv_request(fr_channel_t *ch, void *ctx, fr_channel_recv_callback_t recv_request)
+int fr_channel_set_recv_request(fr_channel_t *ch, void *uctx, fr_channel_recv_callback_t recv_request)
 {
-       ch->end[FROM_WORKER].recv = recv_request;
-       ch->end[FROM_WORKER].recv_ctx = ctx;
+       ch->end[TO_REQUESTOR].recv = recv_request;
+       ch->end[TO_REQUESTOR].recv_uctx = uctx;
        return 0;
 }
 
-/** Send a channel to a worker
+/** Send a channel to a responder
  *
  * @param[in] ch       The channel.
  * @return
@@ -905,21 +930,21 @@ int fr_channel_signal_open(fr_channel_t *ch)
        cc.ack = 0;
        cc.ch = ch;
 
-       return fr_control_message_send(ch->end[TO_WORKER].control, ch->end[TO_WORKER].rb, FR_CONTROL_ID_CHANNEL, &cc, sizeof(cc));
+       return fr_control_message_send(ch->end[TO_RESPONDER].control, ch->end[TO_RESPONDER].rb, FR_CONTROL_ID_CHANNEL, &cc, sizeof(cc));
 }
 
 void fr_channel_debug(fr_channel_t *ch, FILE *fp)
 {
-       fprintf(fp, "to worker\n");
-       fprintf(fp, "\tnum_signals sent = %zu\n", ch->end[TO_WORKER].num_signals);
-       fprintf(fp, "\tnum_signals re-sent = %zu\n", ch->end[TO_WORKER].num_resignals);
-       fprintf(fp, "\tnum_kevents checked = %zu\n", ch->end[TO_WORKER].num_kevents);
-       fprintf(fp, "\tsequence = %"PRIu64"\n", ch->end[TO_WORKER].sequence);
-       fprintf(fp, "\tack = %"PRIu64"\n", ch->end[TO_WORKER].ack);
-
-       fprintf(fp, "to receive\n");
-       fprintf(fp, "\tnum_signals sent = %zu\n", ch->end[FROM_WORKER].num_signals);
-       fprintf(fp, "\tnum_kevents checked = %zu\n", ch->end[FROM_WORKER].num_kevents);
-       fprintf(fp, "\tsequence = %"PRIu64"\n", ch->end[FROM_WORKER].sequence);
-       fprintf(fp, "\tack = %"PRIu64"\n", ch->end[FROM_WORKER].ack);
+       fprintf(fp, "to responder\n");
+       fprintf(fp, "\tnum_signals sent = %" PRIu64 "\n", ch->end[TO_RESPONDER].num_signals);
+       fprintf(fp, "\tnum_signals re-sent = %" PRIu64 "\n", ch->end[TO_RESPONDER].num_resignals);
+       fprintf(fp, "\tnum_kevents checked = %" PRIu64 "\n", ch->end[TO_RESPONDER].num_kevents);
+       fprintf(fp, "\tsequence = %"PRIu64"\n", ch->end[TO_RESPONDER].sequence);
+       fprintf(fp, "\tack = %"PRIu64"\n", ch->end[TO_RESPONDER].ack);
+
+       fprintf(fp, "to requestor\n");
+       fprintf(fp, "\tnum_signals sent = %" PRIu64"\n", ch->end[TO_REQUESTOR].num_signals);
+       fprintf(fp, "\tnum_kevents checked = %" PRIu64 "\n", ch->end[TO_REQUESTOR].num_kevents);
+       fprintf(fp, "\tsequence = %"PRIu64"\n", ch->end[TO_REQUESTOR].sequence);
+       fprintf(fp, "\tack = %"PRIu64"\n", ch->end[TO_REQUESTOR].ack);
 }
index 9712cf51a9b1b7a678e1f637548c02e3efdafa7e..603416356263983ec04ab93d6f4242c476e77b30 100644 (file)
@@ -35,8 +35,8 @@ extern "C" {
  *  A two-way channel (i.e. pipe) for exchanging information
  *
  *  While the channels are two-way, they are designed to have a
- *  "master" writing requests to the channel, and a "worker" reading
- *  requests, and writing replies back to the master.
+ *  "frontend" writing requests to the channel, and a "worker" reading
+ *  requests, and writing replies back to the frontend.
  */
 typedef struct fr_channel_s fr_channel_t;
 
@@ -64,8 +64,8 @@ extern "C" {
 
 typedef enum fr_channel_event_t {
        FR_CHANNEL_ERROR = 0,
-       FR_CHANNEL_DATA_READY_WORKER,
-       FR_CHANNEL_DATA_READY_NETWORK,
+       FR_CHANNEL_DATA_READY_RESPONDER,
+       FR_CHANNEL_DATA_READY_REQUESTOR,
        FR_CHANNEL_OPEN,
        FR_CHANNEL_CLOSE,
 
@@ -134,39 +134,39 @@ typedef struct {
 extern fr_table_num_sorted_t const channel_packet_priority[];
 extern size_t channel_packet_priority_len;
 
-fr_channel_t *fr_channel_create(TALLOC_CTX *ctx, fr_control_t *master, fr_control_t *worker, bool same) CC_HINT(nonnull);
+fr_channel_t *fr_channel_create(TALLOC_CTX *ctx, fr_control_t *frontend, fr_control_t *worker, bool same) CC_HINT(nonnull);
 
-int fr_channel_send_request(fr_channel_t *ch, fr_channel_data_t *cm) CC_HINT(nonnull);
-bool fr_channel_recv_request(fr_channel_t *ch) CC_HINT(nonnull);
+int    fr_channel_send_request(fr_channel_t *ch, fr_channel_data_t *cm) CC_HINT(nonnull);
+bool   fr_channel_recv_request(fr_channel_t *ch) CC_HINT(nonnull);
 
-int fr_channel_send_reply(fr_channel_t *ch, fr_channel_data_t *cd) CC_HINT(nonnull);
-int fr_channel_null_reply(fr_channel_t *ch) CC_HINT(nonnull);
+int    fr_channel_send_reply(fr_channel_t *ch, fr_channel_data_t *cd) CC_HINT(nonnull);
+int    fr_channel_null_reply(fr_channel_t *ch) CC_HINT(nonnull);
 
-bool fr_channel_recv_reply(fr_channel_t *ch) CC_HINT(nonnull);
+bool   fr_channel_recv_reply(fr_channel_t *ch) CC_HINT(nonnull);
 
 typedef void (*fr_channel_recv_callback_t)(void *ctx, fr_channel_t *ch, fr_channel_data_t *cd);
-int fr_channel_set_recv_reply(fr_channel_t *ch, void *ctx, fr_channel_recv_callback_t recv_reply) CC_HINT(nonnull(1,3));
-int fr_channel_set_recv_request(fr_channel_t *ch, void *ctx, fr_channel_recv_callback_t recv_reply) CC_HINT(nonnull(1,3));
+int    fr_channel_set_recv_reply(fr_channel_t *ch, void *ctx, fr_channel_recv_callback_t recv_reply) CC_HINT(nonnull(1,3));
+int    fr_channel_set_recv_request(fr_channel_t *ch, void *ctx, fr_channel_recv_callback_t recv_reply) CC_HINT(nonnull(1,3));
 
-int fr_channel_worker_sleeping(fr_channel_t *ch) CC_HINT(nonnull);
+int    fr_channel_responder_sleeping(fr_channel_t *ch) CC_HINT(nonnull);
 
-int fr_channel_service_kevent(fr_channel_t *ch, fr_control_t *c, struct kevent const *kev) CC_HINT(nonnull);
-fr_channel_event_t fr_channel_service_message(fr_time_t when, fr_channel_t **p_channel, void const *data, size_t data_size) CC_HINT(nonnull);
+int    fr_channel_service_kevent(fr_channel_t *ch, fr_control_t *c, struct kevent const *kev) CC_HINT(nonnull);
+fr_channel_event_t     fr_channel_service_message(fr_time_t when, fr_channel_t **p_channel, void const *data, size_t data_size) CC_HINT(nonnull);
 
-bool fr_channel_active(fr_channel_t *ch) CC_HINT(nonnull);
+bool   fr_channel_active(fr_channel_t *ch) CC_HINT(nonnull);
 
-int fr_channel_signal_open(fr_channel_t *ch) CC_HINT(nonnull);
+int    fr_channel_signal_open(fr_channel_t *ch) CC_HINT(nonnull);
 
-int fr_channel_signal_worker_close(fr_channel_t *ch) CC_HINT(nonnull);
-int fr_channel_worker_ack_close(fr_channel_t *ch) CC_HINT(nonnull);
+int    fr_channel_signal_responder_close(fr_channel_t *ch) CC_HINT(nonnull);
+int    fr_channel_responder_ack_close(fr_channel_t *ch) CC_HINT(nonnull);
 
-void fr_channel_worker_ctx_add(fr_channel_t *ch, void *ctx) CC_HINT(nonnull);
-void *fr_channel_worker_ctx_get(fr_channel_t *ch) CC_HINT(nonnull);
-void fr_channel_network_ctx_add(fr_channel_t *ch, void *ctx) CC_HINT(nonnull);
-void *fr_channel_network_ctx_get(fr_channel_t *ch) CC_HINT(nonnull);
+void   fr_channel_responder_uctx_add(fr_channel_t *ch, void *ctx) CC_HINT(nonnull);
+void   *fr_channel_responder_uctx_get(fr_channel_t *ch) CC_HINT(nonnull);
+void   fr_channel_requestor_uctx_add(fr_channel_t *ch, void *ctx) CC_HINT(nonnull);
+void   *fr_channel_requestor_uctx_get(fr_channel_t *ch) CC_HINT(nonnull);
 
 
-void fr_channel_debug(fr_channel_t *ch, FILE *fp);
+void   fr_channel_debug(fr_channel_t *ch, FILE *fp);
 
 #ifdef __cplusplus
 }
index febfc4b9286bb74a4b654e2ff96227714e238b86..e7324d9d36e1a8976fafff0c03210de1b70c84ae 100644 (file)
@@ -214,7 +214,7 @@ static void fr_network_recv_reply(void *ctx, fr_channel_t *ch, fr_channel_data_t
        /*
         *      Update stats for the worker.
         */
-       worker = fr_channel_network_ctx_get(ch);
+       worker = fr_channel_requestor_uctx_get(ch);
        worker->stats.out++;
        worker->cpu_time = cd->reply.cpu_time;
        if (!worker->predicted) {
@@ -253,7 +253,7 @@ static void fr_network_channel_callback(void *ctx, void const *data, size_t data
                DEBUG3("noop <--");
                break;
 
-       case FR_CHANNEL_DATA_READY_NETWORK:
+       case FR_CHANNEL_DATA_READY_REQUESTOR:
                rad_assert(ch != NULL);
                DEBUG3("data <--");
                while (fr_channel_recv_reply(ch)) {
@@ -261,7 +261,7 @@ static void fr_network_channel_callback(void *ctx, void const *data, size_t data
                }
                break;
 
-       case FR_CHANNEL_DATA_READY_WORKER:
+       case FR_CHANNEL_DATA_READY_RESPONDER:
                rad_assert(0 == 1);
                DEBUG3("worker ??? <--");
                break;
@@ -876,7 +876,7 @@ static void fr_network_worker_callback(void *ctx, void const *data, size_t data_
        w->channel = fr_worker_channel_create(worker, w, nr->control);
        if (!w->channel) fr_exit_now(1);
 
-       fr_channel_network_ctx_add(w->channel, w);
+       fr_channel_requestor_uctx_add(w->channel, w);
        fr_channel_set_recv_reply(w->channel, nr, fr_network_recv_reply);
 
        /*
@@ -1066,7 +1066,7 @@ int fr_network_destroy(fr_network_t *nr)
        for (i = 0; i < nr->num_workers; i++) {
                fr_network_worker_t *worker = nr->workers[i];
 
-               fr_channel_signal_worker_close(worker->channel);
+               fr_channel_signal_responder_close(worker->channel);
        }
 
        /*
index 180ab3f736bd76862f1b6af1cfc62fc9607ad97f..70a6c1c286cae07dc1bf761c5ecdc6f03c5ac1ab 100644 (file)
@@ -231,12 +231,12 @@ static void fr_worker_channel_callback(void *ctx, void const *data, size_t data_
                DEBUG3("\t--> noop");
                return;
 
-       case FR_CHANNEL_DATA_READY_NETWORK:
+       case FR_CHANNEL_DATA_READY_REQUESTOR:
                rad_assert(0 == 1);
                DEBUG3("\t--> ??? network");
                break;
 
-       case FR_CHANNEL_DATA_READY_WORKER:
+       case FR_CHANNEL_DATA_READY_RESPONDER:
                rad_assert(ch != NULL);
                DEBUG3("\t--> data");
 
@@ -266,7 +266,7 @@ static void fr_worker_channel_callback(void *ctx, void const *data, size_t data_
                                                   sizeof(fr_channel_data_t),
                                                   worker->ring_buffer_size);
                        rad_assert(ms != NULL);
-                       fr_channel_worker_ctx_add(ch, ms);
+                       fr_channel_responder_uctx_add(ch, ms);
 
                        worker->num_channels++;
                        ok = true;
@@ -295,9 +295,9 @@ static void fr_worker_channel_callback(void *ctx, void const *data, size_t data_
                         *      wake up after a time and try
                         *      to close it again.
                         */
-                       (void) fr_channel_worker_ack_close(ch);
+                       (void) fr_channel_responder_ack_close(ch);
 
-                       ms = fr_channel_worker_ctx_get(ch);
+                       ms = fr_channel_responder_uctx_get(ch);
                        rad_assert(ms != NULL);
                        fr_message_set_gc(ms);
                        talloc_free(ms);
@@ -339,7 +339,7 @@ static void fr_worker_nak(fr_worker_t *worker, fr_channel_data_t *cd, fr_time_t
        ch = cd->channel.ch;
        listen = cd->listen;
 
-       ms = fr_channel_worker_ctx_get(ch);
+       ms = fr_channel_responder_uctx_get(ch);
        rad_assert(ms != NULL);
 
        size = listen->app_io->default_reply_size;
@@ -431,7 +431,7 @@ static void fr_worker_send_reply(fr_worker_t *worker, REQUEST *request, size_t s
        ch = request->async->channel;
        rad_assert(ch != NULL);
 
-       ms = fr_channel_worker_ctx_get(ch);
+       ms = fr_channel_responder_uctx_get(ch);
        rad_assert(ms != NULL);
 
        reply = (fr_channel_data_t *) fr_message_reserve(ms, size);
@@ -1101,14 +1101,14 @@ static int fr_worker_pre_event(void *ctx, fr_time_t wake)
        /*
         *      Nothing more to do, and the event loop has us sleeping
         *      for a period of time.  Signal the producers that we're
-        *      sleeping.  The fr_channel_worker_sleeping() function
+        *      sleeping.  The fr_channel_responder_sleeping() function
         *      will take care of skipping the signal if there are no
         *      outstanding requests for it.
         */
        for (i = 0; i < worker->max_channels; i++) {
                if (!worker->channel[i]) continue;
 
-               (void) fr_channel_worker_sleeping(worker->channel[i]);
+               (void) fr_channel_responder_sleeping(worker->channel[i]);
        }
        worker->was_sleeping = true;
 
@@ -1223,7 +1223,7 @@ void fr_worker_destroy(fr_worker_t *worker)
        for (i = 0; i < worker->max_channels; i++) {
                if (!worker->channel[i]) continue;
 
-               fr_channel_worker_ack_close(worker->channel[i]);
+               fr_channel_responder_ack_close(worker->channel[i]);
        }
 #endif
 
index 2da7d51e0f722fcde5b313e0ba495f84ef572dee..02859431d863c68cd16b576cc32aff52c72a6645 100644 (file)
@@ -199,7 +199,7 @@ check_close:
 
                if (!signaled_close && (num_messages >= max_messages) && (num_outstanding == 0)) {
                        MPRINT1("Master signaling worker to exit.\n");
-                       rcode = fr_channel_signal_worker_close(channel);
+                       rcode = fr_channel_signal_responder_close(channel);
                        if (rcode < 0) {
                                fprintf(stderr, "Failed signaling close: %s\n", fr_syserror(errno));
                                exit(EXIT_FAILURE);
@@ -248,7 +248,7 @@ check_close:
                        MPRINT1("Master got channel event %d\n", ce);
 
                        switch (ce) {
-                       case FR_CHANNEL_DATA_READY_NETWORK:
+                       case FR_CHANNEL_DATA_READY_REQUESTOR:
                                MPRINT1("Master got data ready signal\n");
                                rad_assert(new_channel == channel);
 
@@ -395,10 +395,10 @@ static void *channel_worker(void *arg)
                                        fr_message_done(&cd->m);
                                }
 
-                               (void) fr_channel_worker_ack_close(channel);
+                               (void) fr_channel_responder_ack_close(channel);
                                break;
 
-                       case FR_CHANNEL_DATA_READY_WORKER:
+                       case FR_CHANNEL_DATA_READY_RESPONDER:
                                MPRINT1("\tWorker got data ready signal\n");
                                rad_assert(new_channel == channel);
 
index 5262d27d2e5d360dd32c805770036962fc033927..6f43997b3dc3aeb0e54cdf4c05af915e490520b4 100644 (file)
@@ -436,7 +436,7 @@ static void master_process(TALLOC_CTX *ctx)
                        MPRINT1("Master got channel event %d\n", ce);
 
                        switch (ce) {
-                       case FR_CHANNEL_DATA_READY_NETWORK:
+                       case FR_CHANNEL_DATA_READY_REQUESTOR:
                                MPRINT1("Master got data ready signal\n");
 
                                reply = fr_channel_recv_reply(ch);
index ea942e8473806a69ca8af0f60c2fbb708b6ce3df..eb54d700a9a33c3dcc8f86501a83bd47dec4a074 100644 (file)
@@ -338,7 +338,7 @@ check_close:
                                        fr_worker_debug(workers[i].worker, stdout);
                                }
 
-                               rcode = fr_channel_signal_worker_close(workers[i].ch);
+                               rcode = fr_channel_signal_responder_close(workers[i].ch);
                                MPRINT1("Master asked exit for worker %d.\n", workers[i].id);
                                if (rcode < 0) {
                                        fprintf(stderr, "Failed signaling close %d: %s\n", i, fr_syserror(errno));
@@ -390,7 +390,7 @@ check_close:
                        MPRINT1("Master got channel event %d\n", ce);
 
                        switch (ce) {
-                       case FR_CHANNEL_DATA_READY_NETWORK:
+                       case FR_CHANNEL_DATA_READY_REQUESTOR:
                                MPRINT1("Master got data ready signal\n");
 
                                reply = fr_channel_recv_reply(ch);