]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
handle EWOULDBLOCK. Helps with #5286
authorAlan T. DeKok <aland@freeradius.org>
Mon, 29 Jan 2024 19:52:03 +0000 (14:52 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Mon, 29 Jan 2024 19:52:03 +0000 (14:52 -0500)
src/listen/radius/proto_radius_tcp.c
src/listen/tacacs/proto_tacacs_tcp.c

index 46f0157147011c059d5ca40c80ac799883c7681e..5d24641df4241866414e551240c8a6db9bfe33de 100644 (file)
@@ -113,6 +113,23 @@ static ssize_t mod_read(fr_listen_t *li, UNUSED void **packet_ctx, fr_time_t *re
         */
        data_size = read(thread->sockfd, buffer + *leftover, buffer_len - *leftover);
        if (data_size < 0) {
+               switch (errno) {
+#if defined(EWOULDBLOCK) && (EWOULDBLOCK != EAGAIN)
+               case EWOULDBLOCK:
+#endif
+               case EAGAIN:
+                       /*
+                        *      We didn't read any data leave the buffers alone.
+                        *
+                        *      i.e. if we had a partial packet in the buffer and we didn't read any data,
+                        *      then the partial packet is still left in the buffer.
+                        */
+                       return 0;
+
+               default:
+                       break;
+               }
+
                PDEBUG2("proto_radius_tcp got read error %zd", data_size);
                return data_size;
        }
index 2c2df97beeacdb3e88b705373b3670453d527c5a..19d58c3892d8015b06cf5938dfe98e37b206103a 100644 (file)
@@ -135,6 +135,23 @@ static ssize_t mod_read(fr_listen_t *li, UNUSED void **packet_ctx, fr_time_t *re
         */
        data_size = read(thread->sockfd, buffer + (*leftover), buffer_len - (*leftover));
        if (data_size < 0) {
+               switch (errno) {
+#if defined(EWOULDBLOCK) && (EWOULDBLOCK != EAGAIN)
+               case EWOULDBLOCK:
+#endif
+               case EAGAIN:
+                       /*
+                        *      We didn't read any data leave the buffers alone.
+                        *
+                        *      i.e. if we had a partial packet in the buffer and we didn't read any data,
+                        *      then the partial packet is still left in the buffer.
+                        */
+                       return 0;
+
+               default:
+                       break;
+               }
+
                ERROR("proto_tacacs_tcp got read error (%zd) - %s", data_size, fr_syserror(errno));
                return data_size;
        }