summaryrefslogtreecommitdiff
path: root/tests/server/tftpd.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/server/tftpd.c')
-rw-r--r--tests/server/tftpd.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/tests/server/tftpd.c b/tests/server/tftpd.c
index 6a6640460..841d08d97 100644
--- a/tests/server/tftpd.c
+++ b/tests/server/tftpd.c
@@ -212,9 +212,10 @@ static const char *ipv_inuse = "IPv4";
const char *serverlogfile = DEFAULT_LOGFILE;
static const char *pidname = ".tftpd.pid";
-static const char *portfile = NULL;
+static const char *portname = NULL; /* none by default */
static int serverlogslocked = 0;
static int wrotepidfile = 0;
+static int wroteportfile = 0;
#ifdef HAVE_SIGSETJMP
static sigjmp_buf timeoutbuf;
@@ -289,6 +290,10 @@ static void timer(int signum)
wrotepidfile = 0;
unlink(pidname);
}
+ if(wroteportfile) {
+ wroteportfile = 0;
+ unlink(portname);
+ }
if(serverlogslocked) {
serverlogslocked = 0;
clear_advisor_read_lock(SERVERLOGS_LOCK);
@@ -579,7 +584,7 @@ int main(int argc, char **argv)
else if(!strcmp("--portfile", argv[arg])) {
arg++;
if(argc>arg)
- portfile = argv[arg++];
+ portname = argv[arg++];
}
else if(!strcmp("--logfile", argv[arg])) {
arg++;
@@ -621,6 +626,7 @@ int main(int argc, char **argv)
" --version\n"
" --logfile [file]\n"
" --pidfile [file]\n"
+ " --portfile [file]\n"
" --ipv4\n"
" --ipv6\n"
" --port [port]\n"
@@ -739,9 +745,9 @@ int main(int argc, char **argv)
goto tftpd_cleanup;
}
- if(portfile) {
- wrotepidfile = write_portfile(portfile, port);
- if(!wrotepidfile) {
+ if(portname) {
+ wroteportfile = write_portfile(portname, port);
+ if(!wroteportfile) {
result = 1;
goto tftpd_cleanup;
}
@@ -846,8 +852,8 @@ tftpd_cleanup:
if(wrotepidfile)
unlink(pidname);
- if(portfile)
- unlink(portfile);
+ if(wroteportfile)
+ unlink(portname);
if(serverlogslocked) {
serverlogslocked = 0;