diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 1997-02-16 23:49:22 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 1997-02-16 23:49:22 +0000 |
commit | 85f8f05d1a2f560f8a2b89c5d4b324625ffab2f7 (patch) | |
tree | 815548fa2d7a6dad32e3f9d12b4f844db0378bf5 /libexec | |
parent | d6d6428f9be26b6e788ca9578790dc6fe98ab3f9 (diff) |
clean
Diffstat (limited to 'libexec')
-rw-r--r-- | libexec/tftpd/tftpd.c | 66 |
1 files changed, 31 insertions, 35 deletions
diff --git a/libexec/tftpd/tftpd.c b/libexec/tftpd/tftpd.c index d848a7e05f1..a46938f6eb4 100644 --- a/libexec/tftpd/tftpd.c +++ b/libexec/tftpd/tftpd.c @@ -39,7 +39,7 @@ char copyright[] = #ifndef lint /*static char sccsid[] = "from: @(#)tftpd.c 5.13 (Berkeley) 2/26/91";*/ -static char rcsid[] = "$Id: tftpd.c,v 1.5 1996/12/22 03:41:22 tholo Exp $"; +static char rcsid[] = "$Id: tftpd.c,v 1.6 1997/02/16 23:49:21 deraadt Exp $"; #endif /* not lint */ /* @@ -105,6 +105,8 @@ main(argc, argv) register int n = 0; int on = 1; int fd = 0; + int pid; + int i, j; int c; openlog("tftpd", LOG_PID, LOG_DAEMON); @@ -175,42 +177,36 @@ main(argc, argv) * break before doing the above "recvfrom", inetd would * spawn endless instances, clogging the system. */ - { - int pid; - int i, j; - - for (i = 1; i < 20; i++) { - pid = fork(); - if (pid < 0) { - sleep(i); - /* - * flush out to most recently sent request. - * - * This may drop some request, but those - * will be resent by the clients when - * they timeout. The positive effect of - * this flush is to (try to) prevent more - * than one tftpd being started up to service - * a single request from a single client. - */ - j = sizeof from; - i = recvfrom(fd, buf, sizeof (buf), 0, - (struct sockaddr *)&from, &j); - if (i > 0) { - n = i; - fromlen = j; - } - } else { - break; - } - } + for (i = 1; i < 20; i++) { + pid = fork(); if (pid < 0) { - syslog(LOG_ERR, "fork: %m\n"); - exit(1); - } else if (pid != 0) { - exit(0); - } + sleep(i); + /* + * flush out to most recently sent request. + * + * This may drop some request, but those + * will be resent by the clients when + * they timeout. The positive effect of + * this flush is to (try to) prevent more + * than one tftpd being started up to service + * a single request from a single client. + */ + j = sizeof from; + i = recvfrom(fd, buf, sizeof (buf), 0, + (struct sockaddr *)&from, &j); + if (i > 0) { + n = i; + fromlen = j; + } + } else + break; } + if (pid < 0) { + syslog(LOG_ERR, "fork: %m\n"); + exit(1); + } else if (pid != 0) + exit(0); + from.sin_len = sizeof(struct sockaddr_in); from.sin_family = AF_INET; alarm(0); |