[exim-cvs] FreeBSD: fix listener-socket backlog monitoring

Inizio della pagina
Delete this message
Reply to this message
Autore: Exim Git Commits Mailing List
Data:  
To: exim-cvs
Oggetto: [exim-cvs] FreeBSD: fix listener-socket backlog monitoring
Gitweb: https://git.exim.org/exim.git/commitdiff/5281dce92f37ab268bfa781e384d64dc5947203f
Commit:     5281dce92f37ab268bfa781e384d64dc5947203f
Parent:     712684792801868efbc821d21ce5c38feeec2e05
Author:     Jeremy Harris <jgh146exb@???>
AuthorDate: Fri Dec 30 18:53:51 2022 +0000
Committer:  Jeremy Harris <jgh146exb@???>
CommitDate: Fri Dec 30 18:53:51 2022 +0000


    FreeBSD: fix listener-socket backlog monitoring
---
 src/src/daemon.c | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)


diff --git a/src/src/daemon.c b/src/src/daemon.c
index d3fec42ee..05d94b188 100644
--- a/src/src/daemon.c
+++ b/src/src/daemon.c
@@ -2553,7 +2553,19 @@ for (;;)
       if (p->revents & POLLIN)
             {
         EXIM_SOCKLEN_T alen = sizeof(accepted);
-#ifdef TCP_INFO
+#if defined(__FreeBSD__) && defined(SO_LISTENQLEN)
+        int backlog;
+        socklen_t blen = sizeof(backlog);
+
+        if (  smtp_backlog_monitor > 0
+           && getsockopt(p->fd, SOL_SOCKET, SO_LISTENQLEN, &backlog, &blen) == 0)
+          {
+          DEBUG(D_interface)
+        debug_printf("listen fd %d queue curr %d\n", p->fd, backlog);
+          smtp_listen_backlog = backlog;
+          }
+
+#elif defined(TCP_INFO) && defined(EXIM_HAVE_TCPI_UNACKED)
         struct tcp_info ti;
         socklen_t tlen = sizeof(ti);


@@ -2563,15 +2575,9 @@ for (;;)
         if (  smtp_backlog_monitor > 0
            && getsockopt(p->fd, IPPROTO_TCP, TCP_INFO, &ti, &tlen) == 0)
           {
-# ifdef EXIM_HAVE_TCPI_UNACKED
           DEBUG(D_interface) debug_printf("listen fd %d queue max %u curr %u\n",
               p->fd, ti.tcpi_sacked, ti.tcpi_unacked);
           smtp_listen_backlog = ti.tcpi_unacked;
-# elif defined(__FreeBSD__)    /* This does not work. Investigate kernel sourcecode. */
-          DEBUG(D_interface) debug_printf("listen fd %d queue max %u curr %u\n",
-              p->fd, ti.__tcpi_sacked, ti.__tcpi_unacked);
-          smtp_listen_backlog = ti.__tcpi_unacked;
-# endif
           }
 #endif
         p->revents = 0;