|
|
cURL Mailing List Monthly Index Single Mail
curl-library Archives
RE: Libcurl stops when sending lots of https messages
From: L S <zorkulus_at_hotmail.com>
Date: Fri, 6 Nov 2009 16:56:48 +0100
Hi again!
I believe I found the answer to why I had problems yesterday. Keep on reading for more information.
>Hi
>Everything works just fine until i raise the number of messages sent per second. Then it sometimes stops in the middle of a send. The progress callback tells me that libcurl is finished sending the message to the server and waits for it's response which never occur. At this point one might blame the server for not responding the client correctly. But the server works just fine when using an old version of the application that doesn't use libcurl ( but still uses openSSL ).
>After investigating the problem with wireshark it seems that the server sends an "Encrypted handshake message" to the client after the client is done sending. When everything works out ok libcurl responds with another "Encrypted handshake message" >and the server starts sending a response.
I beleve that my problem is found in the Curl_ossl_recv function (found in ssluse.c) and I believe that it might be an error in how libcurl handle the SSL_ERROR_WANT_WRITE. Everytime I recieve that response code from SSL_get_error the comunication fails. According to "Network security with openssl", (O'reilly, page 158) the response code SSL_ERROR_WANT_WRITE means that we should retry the command that gave the response ( in this example SSL_read ). (Do libcurl use a blocking or nonblocking socket?) This is done correctly for return code SSL_ERROR_WANT_READ. The function Curl_ossl_recv is called again and with that SSL_read. But this never happends when SSL_ERROR_WANT_WRITE occur.
The reason for this is this code ( found in transfer.c ):
/* We go ahead and do a read if we have a readable socket or if
result = readwrite_data(data, conn, k, &didwhat, done);
The upper if statement isn't fulfilled after a SSL_ERROR_WANT_WRITE and thereby the readwrite_data function isn't called again. This results in a loop doing nothing until libcurl timeouts.
If this is considered to be an bug and not a feature ( there might be some reason for this that isn't libcurls fault. There are winsock calls involved that I don't know what they do ) then this little fix seems to work out for me.
Change
/* subzero, this would've blocked */
To
/* subzero, this would've blocked */
}
I haven't this fix on a grander scheme. But for my application it seems to work.
If you want to reproduce the bug i suggest that you sent a couple of thousand https messages to a server running on a VMWare running on the same computer. I believe that SSL_ERROR_WANT_WRITE only occur from SSL_read when using a very fast connection.
If you have any better solutions please let me know
Hope that this is of any help to you. Just ask if you have any questions.
Best regards / Med vänliga hälsningar
-------------------------------------------------------------------
These mail archives are generated by hypermail. |
Page updated November 16, 2009.
web site info