Current-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: File descriptor leak involving kqueue



Tom Ivar Helbekkmo <tih%hamartun.priv.no@localhost> wrote:
>Lately, I'm running my postfix with opendkim and opendmarc milters (both
>from pkgsrc).  Something about opendmarc is bleeding the system empty of
>file handles, and I'd appreciate some help thinking about how to find
>out exactly what's going on.

Could you try with the following patch ?

Only the first section really matters, the other two bits were to also
try to track down a panic caused by firefox.

I think that close() of a socket can leak the kevent(2) structures
if there are some still active.

Robert Swindells

diff -u -r1.252 uipc_socket.c
--- uipc_socket.c       13 Oct 2016 19:10:23 -0000      1.252
+++ uipc_socket.c       13 Dec 2016 19:25:04 -0000
@@ -709,6 +709,12 @@
        /* Remove acccept filter if one is present. */
        if (so->so_accf != NULL)
                (void)accept_filt_clear(so);
+       if (so->so_rcv.sb_flags & SB_KNOTE) {
+               printf("sofree: rcv knote\n");
+       }
+       if (so->so_snd.sb_flags & SB_KNOTE) {
+               printf("sofree: snd knote\n");
+       }
        sounlock(so);
        if (refs == 0)          /* XXX */
                soput(so);
@@ -2218,6 +2224,10 @@
        struct socket   *so;
 
        so = ((file_t *)kn->kn_obj)->f_socket;
+       if (so == NULL) {
+               printf("filt_sordetach: no socket\n");
+               return;
+       }
        solock(so);
        SLIST_REMOVE(&so->so_rcv.sb_sel.sel_klist, kn, knote, kn_selnext);
        if (SLIST_EMPTY(&so->so_rcv.sb_sel.sel_klist))
@@ -2257,6 +2267,10 @@
        struct socket   *so;
 
        so = ((file_t *)kn->kn_obj)->f_socket;
+       if (so == NULL) {
+               printf("filt_sowdetach: no socket\n");
+               return;
+       }
        solock(so);
        SLIST_REMOVE(&so->so_snd.sb_sel.sel_klist, kn, knote, kn_selnext);
        if (SLIST_EMPTY(&so->so_snd.sb_sel.sel_klist))


Home | Main Index | Thread Index | Old Index