]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
tweak control message send
authorAlan T. DeKok <aland@freeradius.org>
Thu, 19 Feb 2026 04:02:30 +0000 (23:02 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Thu, 19 Feb 2026 04:02:30 +0000 (23:02 -0500)
arguably we should use a method which is better at high performance

src/lib/io/control.c

index 5cb5b098115edcb5fd63f13e642e824a0375eb8b..947de3f4a4d97e35c05f1922dd34fd18c8e85a72 100644 (file)
@@ -353,19 +353,23 @@ int fr_control_message_send(fr_control_t *c, fr_ring_buffer_t *rb, uint32_t id,
        if (fr_control_message_push(c, rb, id, data, data_size) < 0) return -1;
 
 again:
-       while ((ret = write(c->pipe[1], ".", 1)) == 0) {
-               /* nothing */
-       }
-       if ((ret < 0) && ((errno == EAGAIN))
+       if ((ret = write(c->pipe[1], ".", 1)) == 1) return 0;
+
+       if ((ret < 0) && (errno != EAGAIN)
 #if defined(EWOULDBLOCK) && (EWOULDBLOCK != EAGAIN)
-           || (errno == EWOULDBLOCK)
+           && (errno != EWOULDBLOCK)
 #endif
-       ) {
-               delay += 10;
-               usleep(delay);
-               goto again;
+               ) {
+               return -1;
        }
-       return 0;
+
+       /*
+        *      @todo - this is pretty crap.  We should instead have a better way to deal with things when the
+        *      pipe gets full.
+        */
+       delay += 10;
+       usleep(delay);
+       goto again;
 }