diff options
Diffstat (limited to 'tests/server')
-rw-r--r-- | tests/server/sockfilt.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/tests/server/sockfilt.c b/tests/server/sockfilt.c index 82bc7b8cf..84c72f960 100644 --- a/tests/server/sockfilt.c +++ b/tests/server/sockfilt.c @@ -1304,6 +1304,7 @@ int main(int argc, char *argv[]) curl_socket_t msgsock = CURL_SOCKET_BAD; int wrotepidfile = 0; const char *pidname = ".sockfilt.pid"; + const char *portfile = NULL; /* none by default */ bool juggle_again; int rc; int error; @@ -1331,6 +1332,11 @@ int main(int argc, char *argv[]) if(argc>arg) pidname = argv[arg++]; } + else if(!strcmp("--portfile", argv[arg])) { + arg++; + if(argc > arg) + portfile = argv[arg++]; + } else if(!strcmp("--logfile", argv[arg])) { arg++; if(argc>arg) @@ -1360,12 +1366,6 @@ int main(int argc, char *argv[]) if(argc>arg) { char *endptr; unsigned long ulnum = strtoul(argv[arg], &endptr, 10); - if((endptr != argv[arg] + strlen(argv[arg])) || - ((ulnum != 0UL) && ((ulnum < 1025UL) || (ulnum > 65535UL)))) { - fprintf(stderr, "sockfilt: invalid --port argument (%s)\n", - argv[arg]); - return 0; - } port = curlx_ultous(ulnum); arg++; } @@ -1501,6 +1501,13 @@ int main(int argc, char *argv[]) write_stdout("FAIL\n", 5); goto sockfilt_cleanup; } + if(portfile) { + wrotepidfile = write_portfile(portfile, port); + if(!wrotepidfile) { + write_stdout("FAIL\n", 5); + goto sockfilt_cleanup; + } + } do { juggle_again = juggle(&msgsock, sock, &mode); |