diff options
author | Jay Satiro <raysatiro@yahoo.com> | 2021-08-01 23:15:37 -0400 |
---|---|---|
committer | Jay Satiro <raysatiro@yahoo.com> | 2021-08-10 03:29:40 -0400 |
commit | 26f93cf0388c36b78fda93353f9b76068308bbd8 (patch) | |
tree | 623d0e6420382cc1fd219647c4d21bb4082e7692 | |
parent | 86c9146209b7be2078672fa715926ae734374558 (diff) | |
download | curl-26f93cf0388c36b78fda93353f9b76068308bbd8.tar.gz |
test1565: fix windows build errors
- Use our wait_ms() instead of sleep() since Windows doesn't have the
latter.
- Use a separate variable to keep track of whether the pthread_t thread
id is valid.
On Windows pthread_t is not an integer type. pthread offers no macro for
invalid pthread_t thread id, so validity is kept track of separately.
Closes https://github.com/curl/curl/pull/7527
-rw-r--r-- | tests/libtest/lib1565.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/tests/libtest/lib1565.c b/tests/libtest/lib1565.c index 6ea7d4e0c..ba0bd1382 100644 --- a/tests/libtest/lib1565.c +++ b/tests/libtest/lib1565.c @@ -50,7 +50,7 @@ static void *run_thread(void *ptr) (void)ptr; for(i = 0; i < CONN_NUM; i++) { - sleep(TIME_BETWEEN_START_SECS); + wait_ms(TIME_BETWEEN_START_SECS * 1000); easy_init(easy); @@ -96,7 +96,8 @@ int test(char *URL) CURL *started_handles[CONN_NUM]; int started_num = 0; int finished_num = 0; - pthread_t tid = 0; + pthread_t tid; + bool tid_valid = false; struct CURLMsg *message; start_test_timing(); @@ -108,7 +109,9 @@ int test(char *URL) url = URL; res = pthread_create(&tid, NULL, run_thread, NULL); - if(0 != res) { + if(!res) + tid_valid = true; + else { fprintf(stderr, "%s:%d Couldn't create thread, errno %d\n", __FILE__, __LINE__, res); goto test_cleanup; @@ -182,7 +185,7 @@ test_cleanup: test_failure = res; pthread_mutex_unlock(&lock); - if(0 != tid) + if(tid_valid) pthread_join(tid, NULL); curl_multi_cleanup(multi); |