Skip to content

Commit d59dc50

Browse files
committed
Fix custom_socket test failure under Valgrind on Ubuntu 24.04
Set SO_REUSEADDR before bind() so the port can be reused when still in TIME_WAIT from prior tests, and connect to 127.0.0.1 instead of localhost to avoid IPv6 resolution mismatch with the IPv4-only socket.
1 parent 8db55fe commit d59dc50

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

test/integ/ws_start_stop.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,9 @@ LT_END_AUTO_TEST(enable_options)
337337
LT_BEGIN_AUTO_TEST(ws_start_stop_suite, custom_socket)
338338
int fd = socket(AF_INET, SOCK_STREAM, 0);
339339

340+
int one = 1;
341+
setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one));
342+
340343
struct sockaddr_in address;
341344
address.sin_family = AF_INET;
342345
address.sin_addr.s_addr = inet_addr("127.0.0.1");
@@ -353,7 +356,7 @@ LT_BEGIN_AUTO_TEST(ws_start_stop_suite, custom_socket)
353356
std::string s;
354357
CURL *curl = curl_easy_init();
355358
CURLcode res;
356-
curl_easy_setopt(curl, CURLOPT_URL, "localhost:" PORT_STRING "/base");
359+
curl_easy_setopt(curl, CURLOPT_URL, "127.0.0.1:" PORT_STRING "/base");
357360
curl_easy_setopt(curl, CURLOPT_HTTPGET, 1L);
358361
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, writefunc);
359362
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &s);

0 commit comments

Comments
 (0)