[syslinux] Issue with running tftpd-hpa in inetd mode?

Dan Swartzendruber dswartz at druber.com
Thu Jan 30 08:25:23 PST 2014


Hopefully I'm not out to lunch here.  I ported tftp-hpa to our proprietary
OS, VOS (at stratus.com).  We've always runs the old legacy tftpd from
inetd, so I wanted to continue doing so with tftp-hpa.  It seems to work
okay, but I noticed that the code in tftpd.c has a 'while (1)' loop that
has this at the end:

        /*
         * Now that we have read the request packet from the UDP
         * socket, we fork and go back to listening to the socket.
         */
        pid = fork();
        if (pid < 0) {
            syslog(LOG_ERR, "fork: %m");
            exit(EX_OSERR);     /* Return to inetd, just in case */
        } else if (pid == 0)
            break;              /* Child exit, parent loop */
    }

    /* Child process: handle the actual request here */

What I noticed was, every request I did would work okay, but would leave
the parent process waiting for data on the socket.  Note that xinetd
already forks, so it is no longer waiting for us, and can (and will) field
the next request just fine.  After 900 seconds (the timeout passed to the
select call), the parent tftpd process terminates.  Maybe I am dense, but
I don't understand how this loop can ever make sense if tftpd is running
out of xinetd?  You get a request, fork, the child breaks out of the loop
and handles the request and exits.  The parent, however, is sitting there
waiting for another request?  I tried an experiment of putting an 'else
exit (0);' after the 'child exit, parent loop' comment, and it exits just
fine and everything works okay, but I am skeptical this is the right fix,
or in fact how this is supposed to work.  Any comments/corrections would
be much appreciated!



More information about the Syslinux mailing list