mirror of
https://github.com/curl/curl.git
synced 2025-01-18 14:04:30 +08:00
tests/servers: use our platform-aware pid for server verification
The pid used for server verification is later stored as pid2 in the hash of running test servers and therefore used for shutdown. The pid used for shutdown must be the platform-aware (Win32) pid to avoid leaking test servers while running them using Cygwin/msys. Reviewed-by: Jay Satiro Closes #7481
This commit is contained in:
parent
893f39c596
commit
d9d26a6b2c
@ -810,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",
|
||||
|
@ -994,7 +994,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), "WE ROOLZ: %ld\r\n", (long)getpid());
|
||||
msnprintf(msgbuf, sizeof(msgbuf), "WE ROOLZ: %"
|
||||
CURL_FORMAT_CURL_OFF_T "\r\n", our_getpid());
|
||||
msglen = strlen(msgbuf);
|
||||
if(use_gopher)
|
||||
msnprintf(weare, sizeof(weare), "%s", msgbuf);
|
||||
|
@ -1065,8 +1065,8 @@ static int validate_access(struct testcase *test,
|
||||
|
||||
if(!strncmp("verifiedserver", filename, 14)) {
|
||||
char weare[128];
|
||||
size_t count = msnprintf(weare, sizeof(weare),
|
||||
"WE ROOLZ: %ld\r\n", (long)getpid());
|
||||
size_t count = msnprintf(weare, sizeof(weare), "WE ROOLZ: %"
|
||||
CURL_FORMAT_CURL_OFF_T "\r\n", our_getpid());
|
||||
|
||||
logmsg("Are-we-friendly question received");
|
||||
test->buffer = strdup(weare);
|
||||
|
@ -269,17 +269,11 @@ int wait_ms(int timeout_ms)
|
||||
return r;
|
||||
}
|
||||
|
||||
int write_pidfile(const char *filename)
|
||||
curl_off_t our_getpid(void)
|
||||
{
|
||||
FILE *pidfile;
|
||||
curl_off_t pid;
|
||||
|
||||
pid = (curl_off_t)getpid();
|
||||
pidfile = fopen(filename, "wb");
|
||||
if(!pidfile) {
|
||||
logmsg("Couldn't write pid file: %s %s", filename, strerror(errno));
|
||||
return 0; /* fail */
|
||||
}
|
||||
#if defined(WIN32) || defined(_WIN32)
|
||||
/* store pid + 65536 to avoid conflict with Cygwin/msys PIDs, see also:
|
||||
* - https://cygwin.com/git/?p=newlib-cygwin.git;a=commit; ↵
|
||||
@ -289,6 +283,20 @@ int write_pidfile(const char *filename)
|
||||
*/
|
||||
pid += 65536;
|
||||
#endif
|
||||
return pid;
|
||||
}
|
||||
|
||||
int write_pidfile(const char *filename)
|
||||
{
|
||||
FILE *pidfile;
|
||||
curl_off_t pid;
|
||||
|
||||
pid = our_getpid();
|
||||
pidfile = fopen(filename, "wb");
|
||||
if(!pidfile) {
|
||||
logmsg("Couldn't write pid file: %s %s", filename, strerror(errno));
|
||||
return 0; /* fail */
|
||||
}
|
||||
fprintf(pidfile, "%" CURL_FORMAT_CURL_OFF_T "\n", pid);
|
||||
fclose(pidfile);
|
||||
logmsg("Wrote pid %" CURL_FORMAT_CURL_OFF_T " to %s", pid, filename);
|
||||
|
@ -60,6 +60,7 @@ void win32_cleanup(void);
|
||||
FILE *test2fopen(long testno);
|
||||
|
||||
int wait_ms(int timeout_ms);
|
||||
curl_off_t our_getpid(void);
|
||||
int write_pidfile(const char *filename);
|
||||
int write_portfile(const char *filename, int port);
|
||||
void set_advisor_read_lock(const char *filename);
|
||||
|
Loading…
Reference in New Issue
Block a user