Skip to content

Commit 3733f81

Browse files
committed
Fix Windows build: replace rand_r with portable rand()
rand_r is POSIX-specific and not available on Windows. Since this is just a stress test where thread-safe randomness isn't critical, use the portable rand() function instead.
1 parent 399f525 commit 3733f81

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

test/integ/basic.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1644,12 +1644,10 @@ LT_BEGIN_AUTO_TEST(basic_suite, thread_safety)
16441644
});
16451645

16461646
auto get_thread = std::thread([&](){
1647-
unsigned int seed = 42;
16481647
while (!done) {
16491648
CURL *curl = curl_easy_init();
16501649
std::string s;
1651-
std::string url = "localhost:" PORT_STRING "/route" + std::to_string(
1652-
static_cast<int>((rand_r(&seed) * 10000000.0) / RAND_MAX));
1650+
std::string url = "localhost:" PORT_STRING "/route" + std::to_string(rand() % 10000000); // NOLINT(runtime/threadsafe_fn)
16531651
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
16541652
curl_easy_setopt(curl, CURLOPT_HTTPGET, 1L);
16551653
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, writefunc);

0 commit comments

Comments
 (0)