Skip to content
Snippets Groups Projects
Commit bc02dbdf authored by rswindell's avatar rswindell
Browse files

Attempts to re-bind the UDP port with port 0 if a re-bind w/server port fails.

parent 0c8735c0
No related branches found
No related tags found
No related merge requests found
...@@ -1306,12 +1306,15 @@ void DLLCALL services_thread(void* arg) ...@@ -1306,12 +1306,15 @@ void DLLCALL services_thread(void* arg)
addr.sin_family = AF_INET; addr.sin_family = AF_INET;
addr.sin_port = htons(service[i].port); addr.sin_port = htons(service[i].port);
if(startup->seteuid!=NULL && !startup->seteuid(FALSE))
addr.sin_port=0;
result=bind(client_socket, (struct sockaddr *) &addr, sizeof(addr)); result=bind(client_socket, (struct sockaddr *) &addr, sizeof(addr));
if(startup->seteuid!=NULL) if(result==SOCKET_ERROR) {
startup->seteuid(TRUE); /* Failed to re-bind to same port number, use user port */
lprintf("%04d %s ERROR %d re-binding socket to port %u failed, "
"using user port"
,client_socket, service[i].protocol, ERROR_VALUE, service[i].port);
addr.sin_port=0;
result=bind(client_socket, (struct sockaddr *) &addr, sizeof(addr));
}
if(result!=0) { if(result!=0) {
FREE_AND_NULL(udp_buf); FREE_AND_NULL(udp_buf);
lprintf("%04d %s !ERROR %d re-binding socket to port %u" lprintf("%04d %s !ERROR %d re-binding socket to port %u"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment