]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
Robert Iakobashvili made the 'master_buffer' get allocated first once it is
authorDaniel Stenberg <daniel@haxx.se>
Tue, 24 Apr 2007 10:18:06 +0000 (10:18 +0000)
committerDaniel Stenberg <daniel@haxx.se>
Tue, 24 Apr 2007 10:18:06 +0000 (10:18 +0000)
can/will be used as it then makes the common cases save 16KB of data for each
easy handle that isn't used for pipelining.

CHANGES
RELEASE-NOTES
lib/sendf.c
lib/transfer.c
lib/url.c
lib/urldata.h

diff --git a/CHANGES b/CHANGES
index cc224be03c516a71f8cc7d7e97c341195aeb8240..2c07187bb710ff9219edaf689cfcf975a28470af 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -6,6 +6,11 @@
 
                                   Changelog
 
+Daniel S (24 April 2007)
+- Robert Iakobashvili made the 'master_buffer' get allocated first once it is
+  can/will be used as it then makes the common cases save 16KB of data for each
+  easy handle that isn't used for pipelining.
+
 Dan F (23 April 2007)
 - Added <postcheck> support to the test harness.
 
index 1ce8d70122aecd9dc7c87154ccf799327c91deb7..863ed8fbf7eac384e321799cbed1761bb4b079e2 100644 (file)
@@ -11,8 +11,9 @@ Curl and libcurl 7.16.3
 
 This release includes the following changes:
  
- o Added curl_multi_socket_action()
- o Deprecated curl_multi_socket()
+ o added curl_multi_socket_action()
+ o deprecated curl_multi_socket()
+ o uses less memory in non-pipelined use cases
 
 This release includes the following bugfixes:
 
@@ -34,7 +35,7 @@ This release includes the following known bugs:
 
 Other curl-related news:
 
- o PycURL 7.16.2 was released: http://pycurl.sf.net/
+ o PycURL 7.16.2.1 was released: http://pycurl.sf.net/
  o TclCurl 7.16.2 was released:
    http://personal1.iddeo.es/andresgarci/tclcurl/english/
 
index bf9ee490a77cef0eed1228a47f3bc5e6c6f3fd34..922550b00a7ccc928b7f2943bb4c45ec5ab83003 100644 (file)
@@ -495,7 +495,7 @@ int Curl_read(struct connectdata *conn, /* connection data */
     }
     /* If we come here, it means that there is no data to read from the buffer,
      * so we read from the socket */
-    bytesfromsocket = MIN(sizerequested, sizeof(conn->master_buffer));
+    bytesfromsocket = MIN(sizerequested, BUFSIZE * sizeof (char));
     buffertofill = conn->master_buffer;
   }
   else {
index 52b4c8966b9604866c8db5f60f3180491733ba07..d007e881429b123baab6d28852efc1cc82f39252 100644 (file)
@@ -289,8 +289,13 @@ static void read_rewind(struct connectdata *conn,
     size_t show;
 
     show = MIN(conn->buf_len - conn->read_pos, sizeof(buf)-1);
-    memcpy(buf, conn->master_buffer + conn->read_pos, show);
-    buf[show] = '\0';
+    if (conn->master_buffer) {
+        memcpy(buf, conn->master_buffer + conn->read_pos, show);
+        buf[show] = '\0';
+    }
+    else {
+        buf[0] = '\0';
+    }
 
     DEBUGF(infof(conn->data,
                  "Buffer after stream rewind (read_pos = %d): [%s]",
index ddb214d20c598852c0e80434599c34551e281692..659b977d87616964b84ddd5624c7e77c278c9fb0 100644 (file)
--- a/lib/url.c
+++ b/lib/url.c
@@ -1789,6 +1789,7 @@ static void conn_free(struct connectdata *conn)
   Curl_safefree(conn->trailer);
   Curl_safefree(conn->host.rawalloc); /* host name buffer */
   Curl_safefree(conn->proxy.rawalloc); /* proxy name buffer */
+  Curl_safefree(conn->master_buffer);
 
   Curl_llist_destroy(conn->send_pipe, NULL);
   Curl_llist_destroy(conn->recv_pipe, NULL);
@@ -2825,7 +2826,7 @@ static CURLcode CreateConnection(struct SessionHandle *data,
      to not have to modify everything at once, we allocate a temporary
      connection data struct and fill in for comparison purposes. */
 
-  conn = (struct connectdata *)calloc(sizeof(struct connectdata), 1);
+  conn = (struct connectdata *)calloc(1, sizeof(struct connectdata));
   if(!conn) {
     *in_connect = NULL; /* clear the pointer */
     return CURLE_OUT_OF_MEMORY;
@@ -2835,6 +2836,14 @@ static CURLcode CreateConnection(struct SessionHandle *data,
      any failure */
   *in_connect = conn;
 
+  if (data->multi && Curl_multi_canPipeline(data->multi) &&
+      !conn->master_buffer) {
+    /* Allocate master_buffer to be used for pipelining */
+    conn->master_buffer = calloc(BUFSIZE, sizeof (char));
+    if (!conn->master_buffer)
+      return CURLE_OUT_OF_MEMORY;
+  }
+
   /* and we setup a few fields in case we end up actually using this struct */
 
   conn->data = data; /* Setup the association between this connection
@@ -3803,6 +3812,7 @@ else {
     Curl_safefree(old_conn->proxypasswd);
     Curl_llist_destroy(old_conn->send_pipe, NULL);
     Curl_llist_destroy(old_conn->recv_pipe, NULL);
+    Curl_safefree(old_conn->master_buffer);
 
     free(old_conn);          /* we don't need this anymore */
 
index b129ca7081146fdf80926ac2645eb5c917149371..023bc3ca35fc1ec078b847701c82561eed9f125a 100644 (file)
@@ -868,7 +868,8 @@ struct connectdata {
   struct curl_llist *recv_pipe; /* List of handles waiting to read
                                    their responses on this pipeline */
 
-  char master_buffer[BUFSIZE]; /* The master buffer for this connection. */
+  char* master_buffer; /* The master buffer allocated on-demand; 
+                          used for pipelining. */
   size_t read_pos; /* Current read position in the master buffer */
   size_t buf_len; /* Length of the buffer?? */