]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
Make recvbuf unlimited and add check for full buffers
authorDanny Mayer <mayer@ntp.org>
Tue, 13 Dec 2005 04:32:47 +0000 (23:32 -0500)
committerDanny Mayer <mayer@ntp.org>
Tue, 13 Dec 2005 04:32:47 +0000 (23:32 -0500)
bk: 439e4eefRsLwYGfHckM90mbckgis3Q

include/recvbuff.h
libntp/recvbuff.c

index e38fc7f2e46b2e4d3d3c89235e53f944de8c38d5..1df7b371d7eb7d0aee93a9934ea57544c598a492 100644 (file)
@@ -10,6 +10,7 @@
 #include "ntp_types.h"
 
 #include <isc/list.h>
+#include <isc/result.h>
 
 /*
  * recvbuf memory management
@@ -110,5 +111,10 @@ extern u_long lowater_additions P((void));
  */
 extern struct recvbuf *get_full_recv_buffer P((void));
 
+/*
+ * Checks to see if there are buffers to process
+ */
+extern isc_boolean_t has_full_recv_buffer P((void));
+
 #endif /* defined __recvbuff_h */
 
index 8720a8a2b6b565851673602a340d71641f9978d1..3985ca365aead3c099f1030e67605581f84d924e 100644 (file)
@@ -94,7 +94,6 @@ create_buffers(int nbufs)
                total_recvbufs++;
        }
        lowater_adds++;
-
        return (nbufs);
 }
 
@@ -148,21 +147,13 @@ get_free_recv_buffer(void)
        buffer = ISC_LIST_HEAD(free_list);
        if (buffer == NULL)
        {
-               if (full_recvbufs >= RECV_TOOMANY) {
-                   msyslog(LOG_ERR, "too many recvbufs allocated (%ld)",
-                   full_recvbufs);
-                   return (buffer);
-               }
-               else
+               /*
+                * See if more are available
+                */
+               if (create_buffers(RECV_INC) <= 0)
                {
-                       /*
-                        * See if more are available
-                        */
-                       if (create_buffers(RECV_INC) <= 0)
-                       {
-                               msyslog(LOG_ERR, "No more memory for recvufs");
-                               return (NULL);
-                       }
+                       msyslog(LOG_ERR, "No more memory for recvufs");
+                       return (NULL);
                }
        }
        else
@@ -185,6 +176,24 @@ get_full_recv_buffer(void)
                ISC_LIST_DEQUEUE(full_list, rbuf, link);
                --full_recvbufs;
        }
+       else
+       {
+               /*
+                * Make sure we reset the full count to 0
+                */
+               full_recvbufs = 0;
+       }
        UNLOCK();
        return (rbuf);
 }
+
+/*
+ * Checks to see if there are buffers to process
+ */
+isc_boolean_t has_full_recv_buffer(void)
+{
+       if (ISC_LIST_HEAD(full_list) != NULL)
+               return (ISC_TRUE);
+       else
+               return (ISC_FALSE);
+}