Juan Lang : cryptnet: Set timeout on http connections when a timeout is specified.

Alexandre Julliard julliard at winehq.org
Wed Oct 24 11:04:40 CDT 2007


Module: wine
Branch: master
Commit: 6c5f759d5ac3d66203844a22ad618443b3c3d6f7
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=6c5f759d5ac3d66203844a22ad618443b3c3d6f7

Author: Juan Lang <juan.lang at gmail.com>
Date:   Tue Oct 23 12:50:29 2007 -0700

cryptnet: Set timeout on http connections when a timeout is specified.

---

 dlls/cryptnet/cryptnet_main.c |   20 ++++++++++++++++----
 1 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/dlls/cryptnet/cryptnet_main.c b/dlls/cryptnet/cryptnet_main.c
index 603185d..21489ff 100644
--- a/dlls/cryptnet/cryptnet_main.c
+++ b/dlls/cryptnet/cryptnet_main.c
@@ -785,6 +785,14 @@ static BOOL WINAPI HTTP_RetrieveEncodedObjectW(LPCWSTR pszURL,
 
                 if (hHttp)
                 {
+                    if (dwTimeout)
+                    {
+                        InternetSetOptionW(hHttp,
+                         INTERNET_OPTION_RECEIVE_TIMEOUT, &dwTimeout,
+                         sizeof(dwTimeout));
+                        InternetSetOptionW(hHttp, INTERNET_OPTION_SEND_TIMEOUT,
+                         &dwTimeout, sizeof(dwTimeout));
+                    }
                     ret = HttpSendRequestExW(hHttp, NULL, NULL, 0,
                      (DWORD_PTR)context);
                     if (!ret && GetLastError() == ERROR_IO_PENDING)
@@ -795,14 +803,18 @@ static BOOL WINAPI HTTP_RetrieveEncodedObjectW(LPCWSTR pszURL,
                         else
                             ret = TRUE;
                     }
-                    ret = HttpEndRequestW(hHttp, NULL, 0, (DWORD_PTR)context);
-                    if (!ret && GetLastError() == ERROR_IO_PENDING)
+                    /* We don't set ret to TRUE in this block to avoid masking
+                     * an error from HttpSendRequestExW.
+                     */
+                    if (!HttpEndRequestW(hHttp, NULL, 0, (DWORD_PTR)context) &&
+                     GetLastError() == ERROR_IO_PENDING)
                     {
                         if (WaitForSingleObject(context->event,
                          context->timeout) == WAIT_TIMEOUT)
+                        {
                             SetLastError(ERROR_TIMEOUT);
-                        else
-                            ret = TRUE;
+                            ret = FALSE;
+                        }
                     }
                     if (ret)
                         ret = CRYPT_DownloadObject(dwRetrievalFlags, hHttp,




More information about the wine-cvs mailing list