Skip to content
Snippets Groups Projects
Commit 038ae0e6 authored by Henrik (Grubba) Grubbström's avatar Henrik (Grubba) Grubbström
Browse files

Protocols.HTTP.Query [Solaris]: Survive EADDRINUSE.

On Solaris 11 Stdio.File()->connect() often fails with EADDRINUSE.
If this happens, retry the connection.

Potential fix for [PIKE-136].
parent 662c74d5
Branches
Tags
No related merge requests found
......@@ -278,20 +278,42 @@ protected void connect(string server,int port,int blocking)
{
DBG("<- (connect %O:%d)\n",server,port);
int count;
while(1) {
int success;
if(con->_fd)
success = con->connect(server, port);
else
// What is this supposed to do? /mast
// SSL.File?
success = con->connect(server, port, blocking);
if(!success) {
if (success) {
if (count) DBG("<- (connect success)\n");
break;
}
errno = con->errno();
DBG("<- (connect error: %s)\n", strerror (errno));
count++;
if ((count > 10) || (errno != System.EADDRINUSE)) {
DBG("<- (connect fail)\n");
close_connection();
ok = 0;
return;
}
// EADDRINUSE: All tuples hostip:hport:serverip:sport are busy.
// Wait for a bit to allow the OS to recycle some ports.
sleep(0.1);
if (con->_fd) {
// Normal file. Close and reopen.
// NB: This seems to be needed on Solaris 11 as otherwise
// the connect() above instead will fail with ETIMEDOUT.
close_connection();
con = Stdio.File();
con->open_socket(-1, 0, server);
}
}
DBG("<- %O\n",request);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment