SylphiaWindy / fhscanhttplibrary

Automatically exported from code.google.com/p/fhscanhttplibrary
0 stars 0 forks source link

performance issues #3

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Lets see the following function all tree:

1- SendHttpRequest()
2- DispatchHTTPRequest()
3- response = conexion->ReadHTTPResponseData((ConnectionHandling*)
HTTPHandleTable[HTTPHandle]->GetClientConnection(),request,&lock);

Inside ReadHTTPResponseData the "lock" mutex, named as "ExternalMutex",
which is part of the HTTPAPI instance , is called several times:

 ExternalMutex->LockMutex();
  FreeConnection();
 ExternalMutex->UnLockMutex();

and again at: 

ExternalMutex->LockMutex();
shutdown(datasock,2);
closesocket(datasock);
i = StablishConnection();
if (!i)
{
    FreeConnection();
    ExternalMutex->UnLockMutex();
    //UnLockMutex(lock);
    return (NULL);
}
for (i = 0; i <= PENDING_PIPELINE_REQUESTS - 1; i++)
{
    SendHTTPRequest(PIPELINE_Request[i]);
}

ExternalMutex->UnLockMutex();

Each time that more than one thread needs to reestablish an HTTP
connection, they should wait until all previous connection attempts ends.
This feature was added to mantain compatibility with the old C code and
should be modified to increase the speed of the http core.
Its known to be the main speed problem with the http proxy when several
threads attempt to reconnect to a host that issued several "connection:
close" messages.

TODO: 
- Identify if an external global mutex is still required to avoid problems
with the connection table.
- Check if the internal ::ConnectionHandling "lock" mutex is enough.

Original issue reported on code.google.com by atarasco@gmail.com on 18 Nov 2009 at 1:12

GoogleCodeExporter commented 8 years ago
The httpapi "lock" mutex have been renamed to "ConnectionTablelock". This mutex 
is
only called from:
CancelHttpRequest();
GetSocketConnection();
CleanConnectionTable();

The connection "lock" mutex have been renamed to "IoOperationLock". This mutex 
is
only called from:
ConnectionHandling::AddPipeLineRequest()
ConnectionHandling::RemovePipeLineRequest()
HTTPAPI::GetSocketConnection()

The "ExternalMutex" called by ReadHTTPResponseData() isnt used anymore.

Original comment by atarasco@gmail.com on 22 Nov 2009 at 5:09