#define TO_WORKER (0)
#define FROM_WORKER (1)
+/*
+ * To make debugging easier...
+ */
+#define EV_FLAG (EV_ADD | EV_CLEAR)
+
+/**
+ * Require more than this number of packets outstanding, before
+ * we start suppressing signals from the master.
+ */
+#define SUPPRESS_SIGNALS_MASTER (0)
+
+/*&
+ * Whether or not to quench some signals from the worker.
+ */
+#define SUPPRESS_SIGNALS_WORKER (1)
+
/**
* The minimum interval between worker signals.
*/
} fr_channel_t;
-/*
- * To make debugging easier...
- */
-#define EV_FLAG (EV_ADD | EV_CLEAR)
-
static int fr_channel_add_kevent_worker(struct kevent *kev, int size)
{
if (size < 3) return -1;
rad_assert(end->last_write <= when);
end->last_write = when;
+ end->num_outstanding++;
+
/*
- * Increment the number of outstanding packets. If we
- * just sent a new one, wake up the other end.
- * Otherwise, rely on the other end to poll or signal as
- * necessary.
+ * We just sent the first packet. There can't possibly be a reply, so don't bother looking.
*/
- end->num_outstanding++;
- if (end->num_outstanding > 1) {
+ if (end->num_outstanding == 1) {
+ *p_reply = NULL;
+
+
+ /*
+ * There is at least one old packet which is
+ * outstanding, look for a reply.
+ */
+ } else if (end->num_outstanding > 1) {
*p_reply = fr_channel_recv_reply(ch);
- return 0;
}
/*
- * We just sent the first request, so there can't
- * possibly be a reply yet.
+ * If we got a reply, AND there are still more
+ * outstanding packets, don't bother signaling the
+ * worker. It will check our queue when it sends the reply.
*/
- *p_reply = NULL;
+ if (*p_reply && (end->num_outstanding > SUPPRESS_SIGNALS_MASTER)) {
+ return 0;
+ }
/*
* Tell the other end that there is new data ready.
MPRINT("\twhen - ast signal = %zd - %zd = %zd\n", when, end->last_sent_signal, when - end->last_sent_signal);
MPRINT("\tsequence - ack = %zd - %zd = %zd\n", end->sequence, other->ack, end->sequence - other->ack);
+#ifdef SUPPRESS_SIGNALS_WORKER
/*
* If we've received a new packet in the last while, OR
* we've sent a signal in the last while, then we don't
MPRINT("WORKER SKIPS\n");
return 0;
}
+#endif
MPRINT("WORKER SIGNALS\n");
return fr_channel_data_ready(ch, when, end, FR_CHANNEL_SIGNAL_DATA_FROM_WORKER);