Skip to content

Commit 770d50c

Browse files
authored
DPL: check for bind result as well. (#5432)
Apparently due to different OS / kernel behaviors, there might be cases in which bind can fail as well.
1 parent 7642035 commit 770d50c

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

Framework/Core/src/runDataProcessing.cxx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1152,15 +1152,20 @@ int runStateMachine(DataProcessorSpecs const& workflow,
11521152
if (serverAddr) {
11531153
free(serverAddr);
11541154
}
1155+
if (driverInfo.port > 64000) {
1156+
throw runtime_error_f("Unable to find a free port for the driver. Last attempt returned %d", result);
1157+
}
11551158
serverAddr = (sockaddr_in*)malloc(sizeof(sockaddr_in));
11561159
uv_ip4_addr("0.0.0.0", driverInfo.port, serverAddr);
1157-
uv_tcp_bind(&serverHandle, (const struct sockaddr*)serverAddr, 0);
1160+
auto bindResult = uv_tcp_bind(&serverHandle, (const struct sockaddr*)serverAddr, 0);
1161+
if (bindResult != 0) {
1162+
driverInfo.port++;
1163+
continue;
1164+
}
11581165
result = uv_listen((uv_stream_t*)&serverHandle, 100, ws_connect_callback);
11591166
if (result != 0) {
11601167
driverInfo.port++;
1161-
}
1162-
if (driverInfo.port > 64000) {
1163-
throw runtime_error_f("Unable to find a free port for the driver. Last attempt returned %d", result);
1168+
continue;
11641169
}
11651170
} while (result != 0);
11661171
}

0 commit comments

Comments
 (0)