View | Details | Raw Unified | Return to bug 256478
Collapse All | Expand All

(-)files/patch-imap__notify.c (+38 lines)
Added Link Here
1
--- imap/notify.c.orig	2021-05-10 04:34:24 UTC
2
+++ imap/notify.c
3
@@ -209,6 +209,27 @@ EXPORTED void notify(const char *method,
4
                 FNAME_NOTIFY_SOCK, sizeof(sun_data.sun_path));
5
     }
6
 
7
+#if defined(__FreeBSD__)
8
+    size_t maxsockbuf;
9
+    size_t len = sizeof(maxsockbuf);
10
+    r = sysctlbyname("kern.ipc.maxsockbuf", &maxsockbuf, &len, NULL, 0);
11
+    if (r == 0) {
12
+        bufsiz = MIN(maxsockbuf, NOTIFY_MAXSIZE);
13
+    } else {
14
+        syslog(LOG_WARNING,
15
+               "NOTIFY(%s): unable to sysctlbyname(kern.ipc.maxsockbuf): %m",
16
+               loginfo);
17
+        bufsiz = NOTIFY_MAXSIZE;
18
+    }
19
+
20
+    optlen = sizeof(bufsiz);
21
+    r = setsockopt(soc, SOL_SOCKET, SO_SNDBUF, &bufsiz, optlen);
22
+    if (r == -1) {
23
+        syslog(LOG_WARNING,
24
+               "NOTIFY(%s): unable to setsockopt(SO_SNDBUF) on socket: %m",
25
+               loginfo);
26
+    }
27
+#else
28
     /* Get send buffer size */
29
     optlen = sizeof(bufsiz);
30
     r = getsockopt(soc, SOL_SOCKET, SO_SNDBUF, &bufsiz, &optlen);
31
@@ -221,6 +242,7 @@ EXPORTED void notify(const char *method,
32
 
33
     /* Use minimum of 1/10 of send buffer size (-overhead) NOTIFY_MAXSIZE */
34
     bufsiz = MIN(bufsiz / 10 - 32, NOTIFY_MAXSIZE);
35
+#endif
36
 
37
     /*
38
      * build request of the form:
(-)files/patch-notifyd__notifyd.c (+32 lines)
Added Link Here
1
--- notifyd/notifyd.c.orig	2021-05-05 03:21:59 UTC
2
+++ notifyd/notifyd.c
3
@@ -111,6 +111,21 @@ static int do_notify(void)
4
     unsigned bufsiz;
5
     socklen_t optlen;
6
 
7
+#if defined(__FreeBSD__)
8
+    size_t maxsockbuf;
9
+    size_t len = sizeof(maxsockbuf);
10
+    if (sysctlbyname("kern.ipc.maxsockbuf", &maxsockbuf, &len, NULL, 0) == 0) {
11
+        bufsiz = MIN(maxsockbuf, NOTIFY_MAXSIZE);
12
+    } else {
13
+        syslog(LOG_WARNING, "unable to sysctlbyname(kern.ipc.maxsockbuf): %m");
14
+        bufsiz = NOTIFY_MAXSIZE;
15
+    }
16
+
17
+    optlen = sizeof(bufsiz);
18
+    if (setsockopt(soc, SOL_SOCKET, SO_RCVBUF, &bufsiz, optlen) == -1) {
19
+        syslog(LOG_WARNING, "unable to setsockopt(SO_RCVBUF) on notify socket: %m");
20
+    }
21
+#else
22
     /* Get receive buffer size */
23
     optlen = sizeof(bufsiz);
24
     r = getsockopt(soc, SOL_SOCKET, SO_RCVBUF, &bufsiz, &optlen);
25
@@ -121,6 +136,7 @@ static int do_notify(void)
26
 
27
     /* Use minimum of 1/10 of receive buffer size (-overhead) NOTIFY_MAXSIZE */
28
     bufsiz = MIN(bufsiz / 10 - 32, NOTIFY_MAXSIZE);
29
+#endif
30
 
31
     while (1) {
32
         method = class = priority = user = mailbox = message = reply = NULL;

Return to bug 256478