version 1.32, 2008/06/19 17:57:01
|
version 1.32.4.2, 2008/10/01 17:03:46
|
|
|
#include <Pegasus/Common/Logger.h> | #include <Pegasus/Common/Logger.h> |
#include <Pegasus/Common/System.h> | #include <Pegasus/Common/System.h> |
#include <Pegasus/Common/Tracer.h> | #include <Pegasus/Common/Tracer.h> |
|
#include <Pegasus/Common/Threads.h> |
| |
PEGASUS_NAMESPACE_BEGIN | PEGASUS_NAMESPACE_BEGIN |
| |
|
|
Uint32 timeoutMilliseconds) | Uint32 timeoutMilliseconds) |
{ | { |
int connectResult; | int connectResult; |
PEGASUS_RETRY_SYSTEM_CALL( |
#ifdef PEGASUS_OS_TYPE_WINDOWS |
::connect(socket, address, addressLength), connectResult); |
connectResult = ::connect(socket, address, addressLength); |
|
#else |
|
Boolean connectionAlreadyRefused = false; |
|
Uint32 maxConnectAttempts = 100; |
|
// Retry the connect() until it succeeds or it fails with an error other |
|
// than EINTR, EAGAIN (for Linux), or the first ECONNREFUSED (for HP-UX). |
|
while (((connectResult = ::connect(socket, address, addressLength)) == -1) |
|
&& (maxConnectAttempts-- > 0) |
|
&& ((errno == EINTR) || (errno == EAGAIN) || |
|
((errno == ECONNREFUSED) && !connectionAlreadyRefused))) |
|
{ |
|
if (errno == ECONNREFUSED) |
|
{ |
|
connectionAlreadyRefused = true; |
|
} |
|
Threads::sleep(1); |
|
} |
|
#endif |
| |
if (connectResult == 0) | if (connectResult == 0) |
{ | { |
|
|
{ timeoutMilliseconds/1000, timeoutMilliseconds%1000*1000 }; | { timeoutMilliseconds/1000, timeoutMilliseconds%1000*1000 }; |
int selectResult = -1; | int selectResult = -1; |
| |
|
#ifdef PEGASUS_OS_TYPE_WINDOWS |
|
PEGASUS_RETRY_SYSTEM_CALL( |
|
select(FD_SETSIZE, NULL, &fdwrite, &fdwrite, &timeoutValue), |
|
selectResult); |
|
#else |
PEGASUS_RETRY_SYSTEM_CALL( | PEGASUS_RETRY_SYSTEM_CALL( |
select(FD_SETSIZE, NULL, &fdwrite, NULL, &timeoutValue), | select(FD_SETSIZE, NULL, &fdwrite, NULL, &timeoutValue), |
selectResult); | selectResult); |
|
#endif |
if (selectResult == 0) | if (selectResult == 0) |
{ | { |
PEG_TRACE_CSTRING(TRC_HTTP, Tracer::LEVEL1, | PEG_TRACE_CSTRING(TRC_HTTP, Tracer::LEVEL1, |