From: Alan T. DeKok Date: Mon, 14 Nov 2016 18:05:10 +0000 (-0500) Subject: return which channel needs servicing X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6ee9afbe645836456694769db46e182cab0520b2;p=thirdparty%2Ffreeradius-server.git return which channel needs servicing --- diff --git a/src/util/channel.c b/src/util/channel.c index 9839557407e..08ed998a853 100644 --- a/src/util/channel.c +++ b/src/util/channel.c @@ -419,11 +419,13 @@ int fr_channel_worker_sleeping(fr_channel_t *ch) * @param[in] kq the kqueue on which the event was received * @param[in] kev the event of type EVFILT_USER * @param[in] when the current time + * @param[out] p_channel the channel which should be serviced. * @return * - <0 on error * - 0 on success +* - 1 on new channel */ -int fr_channel_service_kevent(int kq, struct kevent *kev, fr_time_t when) +int fr_channel_service_kevent(int kq, struct kevent const *kev, fr_time_t when, fr_channel_t **p_channel) { uint64_t ack; fr_channel_end_t *end; @@ -431,6 +433,8 @@ int fr_channel_service_kevent(int kq, struct kevent *kev, fr_time_t when) rad_assert(kev->filter == EVFILT_USER); + *p_channel = NULL; + ch = kev->udata; #ifndef NDEBUG @@ -440,10 +444,13 @@ int fr_channel_service_kevent(int kq, struct kevent *kev, fr_time_t when) /* * Data is ready on one or both channels. Non-zero * idents are just signals that data is ready. We just - * return to the caller, and rely on it to service it's - * channel. + * return the channel to the caller, and rely on it to + * service the channel. */ - if (kev->ident == FR_CHANNEL_DATA_READY) return 0; + if (kev->ident == FR_CHANNEL_DATA_READY) { + *p_channel = ch; + return 0; + } rad_assert(kev->ident == FR_CHANNEL_WORKER_SLEEPING); diff --git a/src/util/channel.h b/src/util/channel.h index 6eaff2a8940..00ae0eac7db 100644 --- a/src/util/channel.h +++ b/src/util/channel.h @@ -80,7 +80,7 @@ int fr_channel_send_reply(fr_channel_t *ch, fr_channel_data_t *cm, fr_channel_da fr_channel_data_t *fr_channel_recv_reply(fr_channel_t *ch) CC_HINT(nonnull); int fr_channel_worker_sleeping(fr_channel_t *ch) CC_HINT(nonnull); -int fr_channel_service_kevent(int kq, struct kevent *kev, fr_time_t when) CC_HINT(nonnull); +int fr_channel_service_kevent(int kq, struct kevent const *kev, fr_time_t when, fr_channel_t **p_channel) CC_HINT(nonnull); #ifdef __cplusplus }