Loading tests/server/sockfilt.c +12 −24 Original line number Diff line number Diff line Loading @@ -98,6 +98,17 @@ static volatile int sigpipe; /* Why? It's not used */ const char *serverlogfile = (char *)DEFAULT_LOGFILE; bool use_ipv6 = FALSE; unsigned short port = DEFAULT_PORT; unsigned short connectport = 0; /* if non-zero, we activate this mode */ enum sockmode { PASSIVE_LISTEN, /* as a server waiting for connections */ PASSIVE_CONNECT, /* as a server, connected to a client */ ACTIVE, /* as a client, connected to a server */ ACTIVE_DISCONNECT /* as a client, disconnected from server */ }; static void lograw(unsigned char *buffer, ssize_t len) { char data[120]; Loading Loading @@ -143,17 +154,6 @@ static void sigpipe_handler(int sig) } #endif bool use_ipv6=FALSE; unsigned short port = DEFAULT_PORT; unsigned short connectport = 0; /* if non-zero, we activate this mode */ enum sockmode { PASSIVE_LISTEN, /* as a server waiting for connections */ PASSIVE_CONNECT, /* as a server, connected to a client */ ACTIVE, /* as a client, connected to a server */ ACTIVE_DISCONNECT /* as a client, disconnected from server */ }; /* sockfdp is a pointer to an established stream or CURL_SOCKET_BAD Loading Loading @@ -519,7 +519,6 @@ int main(int argc, char *argv[]) #endif /* ENABLE_IPV6 */ curl_socket_t sock; curl_socket_t msgsock; FILE *pidfile; char *pidname= (char *)".sockfilt.pid"; int rc; int error; Loading Loading @@ -682,18 +681,7 @@ int main(int argc, char *argv[]) else logmsg("Listening on port %d", port); pidfile = fopen(pidname, "w"); if(pidfile) { long pid = (long)getpid(); fprintf(pidfile, "%ld\n", pid); fclose(pidfile); logmsg("Wrote pid %ld to %s", pid, pidname); } else { error = ERRNO; logmsg("fopen() failed with error: %d %s", error, strerror(error)); logmsg("Error opening file: %s", pidname); logmsg("Couldn't write pid file"); if(!write_pidfile(pidname)) { sclose(sock); return 1; } Loading tests/server/sws.c +1 −14 Original line number Diff line number Diff line Loading @@ -832,11 +832,9 @@ int main(int argc, char *argv[]) curl_socket_t sock, msgsock; int flag; unsigned short port = DEFAULT_PORT; FILE *pidfile; char *pidname= (char *)".http.pid"; struct httprequest req; int rc; int error; int arg=1; #ifdef CURL_SWS_FORK_ENABLED bool use_fork = FALSE; Loading Loading @@ -946,18 +944,7 @@ int main(int argc, char *argv[]) return 1; } pidfile = fopen(pidname, "w"); if(pidfile) { long pid = (long)getpid(); fprintf(pidfile, "%ld\n", pid); fclose(pidfile); logmsg("Wrote pid %ld to %s", pid, pidname); } else { error = ERRNO; logmsg("fopen() failed with error: %d %s", error, strerror(error)); logmsg("Error opening file: %s", pidname); logmsg("Couldn't write pid file"); if(!write_pidfile(pidname)) { sclose(sock); return 1; } Loading tests/server/tftpd.c +1 −14 Original line number Diff line number Diff line Loading @@ -417,13 +417,11 @@ int main(int argc, char **argv) struct tftphdr *tp; int n = 0; int arg = 1; FILE *pidfile; char *pidname= (char *)".tftpd.pid"; unsigned short port = DEFAULT_PORT; curl_socket_t sock; int flag; int rc; int error; struct testcase test; while(argc>arg) { Loading Loading @@ -509,18 +507,7 @@ int main(int argc, char **argv) return 1; } pidfile = fopen(pidname, "w"); if(pidfile) { long pid = (long)getpid(); fprintf(pidfile, "%ld\n", pid); fclose(pidfile); logmsg("Wrote pid %ld to %s", pid, pidname); } else { error = ERRNO; logmsg("fopen() failed with error: %d %s", error, strerror(error)); logmsg("Error opening file: %s", pidname); logmsg("Couldn't write pid file"); if(!write_pidfile(pidname)) { sclose(sock); return 1; } Loading tests/server/util.c +16 −0 Original line number Diff line number Diff line Loading @@ -222,3 +222,19 @@ int wait_ms(int timeout_ms) return r; } bool write_pidfile(const char *filename) { FILE *pidfile; long pid; pid = (long)getpid(); pidfile = fopen(filename, "w"); if(!pidfile) { logmsg("Couldn't write pid file: %s %s", filename, strerror(ERRNO)); return FALSE; } fprintf(pidfile, "%ld\n", pid); fclose(pidfile); logmsg("Wrote pid %ld to %s", pid, filename); return true; } tests/server/util.h +2 −0 Original line number Diff line number Diff line Loading @@ -51,4 +51,6 @@ char *test2file(long testno); int wait_ms(int timeout_ms); bool write_pidfile(const char *filename); #endif /* __SERVER_UTIL_H */ Loading
tests/server/sockfilt.c +12 −24 Original line number Diff line number Diff line Loading @@ -98,6 +98,17 @@ static volatile int sigpipe; /* Why? It's not used */ const char *serverlogfile = (char *)DEFAULT_LOGFILE; bool use_ipv6 = FALSE; unsigned short port = DEFAULT_PORT; unsigned short connectport = 0; /* if non-zero, we activate this mode */ enum sockmode { PASSIVE_LISTEN, /* as a server waiting for connections */ PASSIVE_CONNECT, /* as a server, connected to a client */ ACTIVE, /* as a client, connected to a server */ ACTIVE_DISCONNECT /* as a client, disconnected from server */ }; static void lograw(unsigned char *buffer, ssize_t len) { char data[120]; Loading Loading @@ -143,17 +154,6 @@ static void sigpipe_handler(int sig) } #endif bool use_ipv6=FALSE; unsigned short port = DEFAULT_PORT; unsigned short connectport = 0; /* if non-zero, we activate this mode */ enum sockmode { PASSIVE_LISTEN, /* as a server waiting for connections */ PASSIVE_CONNECT, /* as a server, connected to a client */ ACTIVE, /* as a client, connected to a server */ ACTIVE_DISCONNECT /* as a client, disconnected from server */ }; /* sockfdp is a pointer to an established stream or CURL_SOCKET_BAD Loading Loading @@ -519,7 +519,6 @@ int main(int argc, char *argv[]) #endif /* ENABLE_IPV6 */ curl_socket_t sock; curl_socket_t msgsock; FILE *pidfile; char *pidname= (char *)".sockfilt.pid"; int rc; int error; Loading Loading @@ -682,18 +681,7 @@ int main(int argc, char *argv[]) else logmsg("Listening on port %d", port); pidfile = fopen(pidname, "w"); if(pidfile) { long pid = (long)getpid(); fprintf(pidfile, "%ld\n", pid); fclose(pidfile); logmsg("Wrote pid %ld to %s", pid, pidname); } else { error = ERRNO; logmsg("fopen() failed with error: %d %s", error, strerror(error)); logmsg("Error opening file: %s", pidname); logmsg("Couldn't write pid file"); if(!write_pidfile(pidname)) { sclose(sock); return 1; } Loading
tests/server/sws.c +1 −14 Original line number Diff line number Diff line Loading @@ -832,11 +832,9 @@ int main(int argc, char *argv[]) curl_socket_t sock, msgsock; int flag; unsigned short port = DEFAULT_PORT; FILE *pidfile; char *pidname= (char *)".http.pid"; struct httprequest req; int rc; int error; int arg=1; #ifdef CURL_SWS_FORK_ENABLED bool use_fork = FALSE; Loading Loading @@ -946,18 +944,7 @@ int main(int argc, char *argv[]) return 1; } pidfile = fopen(pidname, "w"); if(pidfile) { long pid = (long)getpid(); fprintf(pidfile, "%ld\n", pid); fclose(pidfile); logmsg("Wrote pid %ld to %s", pid, pidname); } else { error = ERRNO; logmsg("fopen() failed with error: %d %s", error, strerror(error)); logmsg("Error opening file: %s", pidname); logmsg("Couldn't write pid file"); if(!write_pidfile(pidname)) { sclose(sock); return 1; } Loading
tests/server/tftpd.c +1 −14 Original line number Diff line number Diff line Loading @@ -417,13 +417,11 @@ int main(int argc, char **argv) struct tftphdr *tp; int n = 0; int arg = 1; FILE *pidfile; char *pidname= (char *)".tftpd.pid"; unsigned short port = DEFAULT_PORT; curl_socket_t sock; int flag; int rc; int error; struct testcase test; while(argc>arg) { Loading Loading @@ -509,18 +507,7 @@ int main(int argc, char **argv) return 1; } pidfile = fopen(pidname, "w"); if(pidfile) { long pid = (long)getpid(); fprintf(pidfile, "%ld\n", pid); fclose(pidfile); logmsg("Wrote pid %ld to %s", pid, pidname); } else { error = ERRNO; logmsg("fopen() failed with error: %d %s", error, strerror(error)); logmsg("Error opening file: %s", pidname); logmsg("Couldn't write pid file"); if(!write_pidfile(pidname)) { sclose(sock); return 1; } Loading
tests/server/util.c +16 −0 Original line number Diff line number Diff line Loading @@ -222,3 +222,19 @@ int wait_ms(int timeout_ms) return r; } bool write_pidfile(const char *filename) { FILE *pidfile; long pid; pid = (long)getpid(); pidfile = fopen(filename, "w"); if(!pidfile) { logmsg("Couldn't write pid file: %s %s", filename, strerror(ERRNO)); return FALSE; } fprintf(pidfile, "%ld\n", pid); fclose(pidfile); logmsg("Wrote pid %ld to %s", pid, filename); return true; }
tests/server/util.h +2 −0 Original line number Diff line number Diff line Loading @@ -51,4 +51,6 @@ char *test2file(long testno); int wait_ms(int timeout_ms); bool write_pidfile(const char *filename); #endif /* __SERVER_UTIL_H */