]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
return which channel needs servicing
authorAlan T. DeKok <aland@freeradius.org>
Mon, 14 Nov 2016 18:05:10 +0000 (13:05 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Mon, 14 Nov 2016 18:05:10 +0000 (13:05 -0500)
src/util/channel.c
src/util/channel.h

index 9839557407ea02d49d30201c043f3e291e9e2a91..08ed998a85347f151835dcabb49ad6cfd3126005 100644 (file)
@@ -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);
 
index 6eaff2a8940b22fa87f9dc00ece3fbe392dd99c3..00ae0eac7db5c7b6a9520cc75dae0d55efb557ea 100644 (file)
@@ -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
 }