Subject: longjump and gethostbyaddr
To: None <tech-toolchain@netbsd.org>
From: Wolfgang S. Rupprecht <wolfgang+gnus20040317T171142@dailyplanet.dontspam.wsrcc.com>
List: tech-toolchain
Date: 03/17/2004 17:22:29
I've been trying to track down a socket leak in analog
(pkgsrc/www/analog) that leads to an eventual segv.  Analog() appears
to be leaking UDP sockets that were opened by the resolver stubs.  The
code around the resolver calls is essentially:

    if (SETJMP(jumpbuf))
      signal(SIGALRM, SIG_DFL);
    else {
      signal(SIGALRM, sighandler);
      alarm(dnstimeout);
      tempp = gethostbyaddr(addrp, sizeof(IN_ADDR_T), AF_INET);
      alarm(0);
      signal(SIGALRM, SIG_DFL);
    }   

where sighandler does the obvious longjump(jumpbuf);

Is this legal?  Should the resolver be taking more pains to avoid
leaving sockets laying around, or is the analog code simply taking too
many liberties by wildly jumping out of code that is knows nothing
about?

-wolfgang