aboutsummaryrefslogtreecommitdiff
path: root/tests/server/rtspd.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/server/rtspd.c')
-rw-r--r--tests/server/rtspd.c35
1 files changed, 17 insertions, 18 deletions
diff --git a/tests/server/rtspd.c b/tests/server/rtspd.c
index 6ee7787b1..88f96a08f 100644
--- a/tests/server/rtspd.c
+++ b/tests/server/rtspd.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2021, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
- * are also available at https://curl.haxx.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -369,7 +369,7 @@ static int ProcessRequest(struct httprequest *req)
memcpy(rtp_scratch + 4 + i, RTP_DATA, RTP_DATA_SIZE);
}
- if(req->rtp_buffer == NULL) {
+ if(!req->rtp_buffer) {
req->rtp_buffer = rtp_scratch;
req->rtp_buffersize = rtp_size + 4;
}
@@ -552,7 +552,6 @@ static int ProcessRequest(struct httprequest *req)
if(!req->pipe &&
req->open &&
req->prot_version >= 11 &&
- end &&
req->reqbuf + req->offset > end + strlen(END_OF_HEADERS) &&
(!strncmp(req->reqbuf, "GET", strlen("GET")) ||
!strncmp(req->reqbuf, "HEAD", strlen("HEAD")))) {
@@ -600,15 +599,15 @@ static void storerequest(char *reqbuf, size_t totalsize)
size_t writeleft;
FILE *dump;
- if(reqbuf == NULL)
+ if(!reqbuf)
return;
if(totalsize == 0)
return;
do {
dump = fopen(REQUEST_DUMP, "ab");
- } while((dump == NULL) && ((error = errno) == EINTR));
- if(dump == NULL) {
+ } while(!dump && ((error = errno) == EINTR));
+ if(!dump) {
logmsg("Error opening file %s error: %d %s",
REQUEST_DUMP, error, strerror(error));
logmsg("Failed to write request input to " REQUEST_DUMP);
@@ -811,8 +810,8 @@ static int send_doc(curl_socket_t sock, struct httprequest *req)
case DOCNUMBER_WERULEZ:
/* we got a "friends?" question, reply back that we sure are */
logmsg("Identifying ourselves as friends");
- msnprintf(msgbuf, sizeof(msgbuf), "RTSP_SERVER WE ROOLZ: %ld\r\n",
- (long)getpid());
+ msnprintf(msgbuf, sizeof(msgbuf), "RTSP_SERVER WE ROOLZ: %"
+ CURL_FORMAT_CURL_OFF_T "\r\n", our_getpid());
msglen = strlen(msgbuf);
msnprintf(weare, sizeof(weare),
"HTTP/1.1 200 OK\r\nContent-Length: %zu\r\n\r\n%s",
@@ -1046,15 +1045,15 @@ int main(int argc, char *argv[])
curl_socket_t sock = CURL_SOCKET_BAD;
curl_socket_t msgsock = CURL_SOCKET_BAD;
int wrotepidfile = 0;
+ int wroteportfile = 0;
int flag;
unsigned short port = DEFAULT_PORT;
const char *pidname = ".rtsp.pid";
- const char *portfile = NULL;
+ const char *portname = NULL; /* none by default */
struct httprequest req;
int rc;
int error;
int arg = 1;
- long pid;
memset(&req, 0, sizeof(req));
@@ -1079,7 +1078,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++;
@@ -1137,8 +1136,6 @@ int main(int argc, char *argv[])
install_signal_handlers(false);
- pid = (long)getpid();
-
#ifdef ENABLE_IPV6
if(!use_ipv6)
#endif
@@ -1252,9 +1249,9 @@ int main(int argc, char *argv[])
if(!wrotepidfile)
goto server_cleanup;
- if(portfile) {
- wrotepidfile = write_portfile(portfile, port);
- if(!wrotepidfile)
+ if(portname) {
+ wroteportfile = write_portfile(portname, port);
+ if(!wroteportfile)
goto server_cleanup;
}
@@ -1368,6 +1365,8 @@ server_cleanup:
if(wrotepidfile)
unlink(pidname);
+ if(wroteportfile)
+ unlink(portname);
if(serverlogslocked) {
serverlogslocked = 0;
@@ -1378,7 +1377,7 @@ server_cleanup:
if(got_exit_signal) {
logmsg("========> %s rtspd (port: %d pid: %ld) exits with signal (%d)",
- ipv_inuse, (int)port, pid, exit_signal);
+ ipv_inuse, (int)port, (long)getpid(), exit_signal);
/*
* To properly set the return status of the process we
* must raise the same signal SIGINT or SIGTERM that we