Index: files/patch-imap__notify.c diff -u -p /dev/null files/patch-imap__notify.c --- /dev/null 2021-06-14 19:06:22.270449000 +0900 +++ files/patch-imap__notify.c 2021-06-14 17:31:13.634831000 +0900 @@ -0,0 +1,38 @@ +--- imap/notify.c.orig 2021-05-10 04:34:24 UTC ++++ imap/notify.c +@@ -209,6 +209,27 @@ EXPORTED void notify(const char *method, + FNAME_NOTIFY_SOCK, sizeof(sun_data.sun_path)); + } + ++#if defined(__FreeBSD__) ++ size_t maxsockbuf; ++ size_t len = sizeof(maxsockbuf); ++ r = sysctlbyname("kern.ipc.maxsockbuf", &maxsockbuf, &len, NULL, 0); ++ if (r == 0) { ++ bufsiz = MIN(maxsockbuf, NOTIFY_MAXSIZE); ++ } else { ++ syslog(LOG_WARNING, ++ "NOTIFY(%s): unable to sysctlbyname(kern.ipc.maxsockbuf): %m", ++ loginfo); ++ bufsiz = NOTIFY_MAXSIZE; ++ } ++ ++ optlen = sizeof(bufsiz); ++ r = setsockopt(soc, SOL_SOCKET, SO_SNDBUF, &bufsiz, optlen); ++ if (r == -1) { ++ syslog(LOG_WARNING, ++ "NOTIFY(%s): unable to setsockopt(SO_SNDBUF) on socket: %m", ++ loginfo); ++ } ++#else + /* Get send buffer size */ + optlen = sizeof(bufsiz); + r = getsockopt(soc, SOL_SOCKET, SO_SNDBUF, &bufsiz, &optlen); +@@ -221,6 +242,7 @@ EXPORTED void notify(const char *method, + + /* Use minimum of 1/10 of send buffer size (-overhead) NOTIFY_MAXSIZE */ + bufsiz = MIN(bufsiz / 10 - 32, NOTIFY_MAXSIZE); ++#endif + + /* + * build request of the form: Index: files/patch-notifyd__notifyd.c diff -u -p /dev/null files/patch-notifyd__notifyd.c --- /dev/null 2021-06-14 19:06:22.274483000 +0900 +++ files/patch-notifyd__notifyd.c 2021-06-14 17:32:11.638265000 +0900 @@ -0,0 +1,32 @@ +--- notifyd/notifyd.c.orig 2021-05-05 03:21:59 UTC ++++ notifyd/notifyd.c +@@ -111,6 +111,21 @@ static int do_notify(void) + unsigned bufsiz; + socklen_t optlen; + ++#if defined(__FreeBSD__) ++ size_t maxsockbuf; ++ size_t len = sizeof(maxsockbuf); ++ if (sysctlbyname("kern.ipc.maxsockbuf", &maxsockbuf, &len, NULL, 0) == 0) { ++ bufsiz = MIN(maxsockbuf, NOTIFY_MAXSIZE); ++ } else { ++ syslog(LOG_WARNING, "unable to sysctlbyname(kern.ipc.maxsockbuf): %m"); ++ bufsiz = NOTIFY_MAXSIZE; ++ } ++ ++ optlen = sizeof(bufsiz); ++ if (setsockopt(soc, SOL_SOCKET, SO_RCVBUF, &bufsiz, optlen) == -1) { ++ syslog(LOG_WARNING, "unable to setsockopt(SO_RCVBUF) on notify socket: %m"); ++ } ++#else + /* Get receive buffer size */ + optlen = sizeof(bufsiz); + r = getsockopt(soc, SOL_SOCKET, SO_RCVBUF, &bufsiz, &optlen); +@@ -121,6 +136,7 @@ static int do_notify(void) + + /* Use minimum of 1/10 of receive buffer size (-overhead) NOTIFY_MAXSIZE */ + bufsiz = MIN(bufsiz / 10 - 32, NOTIFY_MAXSIZE); ++#endif + + while (1) { + method = class = priority = user = mailbox = message = reply = NULL;