Browse Source

Discarding libs3 request stack (its pointless and caused destroying of request to be postponed - including its logging - until a new request is created)

Source commit: 62ff19d081511d390297e8639d2bc7aca708747a
Martin Prikryl 8 years ago
parent
commit
d6c8e33284
1 changed files with 14 additions and 0 deletions
  1. 14 0
      libs/libs3/src/request.c

+ 14 - 0
libs/libs3/src/request.c

@@ -51,11 +51,13 @@
 
 static char userAgentG[USER_AGENT_SIZE];
 
+#ifndef WINSCP
 static pthread_mutex_t requestStackMutexG;
 
 static Request *requestStackG[REQUEST_STACK_SIZE];
 
 static int requestStackCountG;
+#endif
 
 char defaultHostNameG[S3_MAX_HOSTNAME_SIZE];
 
@@ -1288,6 +1290,7 @@ static S3Status request_get(const RequestParams *params,
 {
     Request *request = 0;
 
+    #ifndef WINSCP
     // Try to get one from the request stack.  We hold the lock for the
     // shortest time possible here.
     pthread_mutex_lock(&requestStackMutexG);
@@ -1304,11 +1307,14 @@ static S3Status request_get(const RequestParams *params,
     }
     // Else there wasn't one available in the request stack, so create one
     else {
+    #endif
         if ((request = (Request *) malloc(sizeof(Request))) == NULL) {
             return S3StatusOutOfMemory;
         }
         request->NeonSession = NULL;
+    #ifndef WINSCP
     }
+    #endif
 
     // Initialize the request
     #ifndef WINSCP
@@ -1372,12 +1378,15 @@ static void request_destroy(Request *request)
 
 static void request_release(Request *request)
 {
+    #ifndef WINSCP
     pthread_mutex_lock(&requestStackMutexG);
 
     // If the request stack is full, destroy this one
     if (requestStackCountG == REQUEST_STACK_SIZE) {
         pthread_mutex_unlock(&requestStackMutexG);
+    #endif
         request_destroy(request);
+    #ifndef WINSCP
     }
     // Else put this one at the front of the request stack; we do this because
     // we want the most-recently-used curl handle to be re-used on the next
@@ -1387,6 +1396,7 @@ static void request_release(Request *request)
         requestStackG[requestStackCountG++] = request;
         pthread_mutex_unlock(&requestStackMutexG);
     }
+    #endif
 }
 
 
@@ -1404,9 +1414,11 @@ S3Status request_api_initialize(const char *userAgentInfo, int flags,
         return S3StatusUriTooLong;
     }
 
+    #ifndef WINSCP
     pthread_mutex_init(&requestStackMutexG, 0);
 
     requestStackCountG = 0;
+    #endif
 
     if (!userAgentInfo || !*userAgentInfo) {
         userAgentInfo = "Unknown";
@@ -1433,12 +1445,14 @@ S3Status request_api_initialize(const char *userAgentInfo, int flags,
 
 void request_api_deinitialize()
 {
+    #ifndef WINSCP
     pthread_mutex_destroy(&requestStackMutexG);
 
     // WINSCP (Expat does not need global initialization)
     while (requestStackCountG--) {
         request_destroy(requestStackG[requestStackCountG]);
     }
+    #endif
 }
 
 static S3Status setup_request(const RequestParams *params,