]> granicus.if.org Git - curl/commitdiff
BUFSIZE: rename to READBUFFER_*, make separate MASTERBUF_SIZE
authorDaniel Stenberg <daniel@haxx.se>
Tue, 25 Apr 2017 13:31:14 +0000 (15:31 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Mon, 1 May 2017 20:55:29 +0000 (22:55 +0200)
lib/sendf.c
lib/url.c
lib/urldata.h

index 0c44224bb7cb32726df6ae525ae975baa3db464b..595c361776c3741da3420918e6f9b1fb6b92372a 100644 (file)
@@ -722,7 +722,7 @@ CURLcode 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 = CURLMIN(sizerequested, (size_t)data->set.buffer_size);
+    bytesfromsocket = CURLMIN(sizerequested, MASTERBUF_SIZE);
     buffertofill = conn->master_buffer;
   }
   else {
index e28acf5f976d62092d64cac85f7b3b69734fea86..e018927c056959458189e2d0fb6d01a015cbd48e 100644 (file)
--- a/lib/url.c
+++ b/lib/url.c
@@ -140,6 +140,10 @@ static CURLcode parse_login_details(const char *login, const size_t len,
                                     char **optionsptr);
 static unsigned int get_protocol_family(unsigned int protocol);
 
+#define READBUFFER_SIZE CURL_MAX_WRITE_SIZE
+#define READBUFFER_MAX  CURL_MAX_READ_SIZE
+#define READBUFFER_MIN  1024
+
 /*
  * Protocol table.
  */
@@ -607,7 +611,7 @@ CURLcode Curl_init_userdefined(struct UserDefined *set)
 
   set->expect_100_timeout = 1000L; /* Wait for a second by default. */
   set->sep_headers = TRUE; /* separated header lists by default */
-  set->buffer_size = BUFSIZE;
+  set->buffer_size = READBUFFER_SIZE;
 
   Curl_http2_init_userset(set);
   return result;
@@ -645,7 +649,7 @@ CURLcode Curl_open(struct Curl_easy **curl)
 
   /* We do some initial setup here, all those fields that can't be just 0 */
 
-  data->state.buffer = malloc(BUFSIZE + 1);
+  data->state.buffer = malloc(READBUFFER_SIZE + 1);
   if(!data->state.buffer) {
     DEBUGF(fprintf(stderr, "Error: malloc of buffer failed\n"));
     result = CURLE_OUT_OF_MEMORY;
@@ -2287,16 +2291,16 @@ CURLcode Curl_setopt(struct Curl_easy *data, CURLoption option,
      */
     arg = va_arg(param, long);
 
-    if(arg > MAX_BUFSIZE)
-      arg = MAX_BUFSIZE; /* huge internal default */
+    if(arg > READBUFFER_MAX)
+      arg = READBUFFER_MAX;
     else if(arg < 1)
-      arg = BUFSIZE;
-    else if(arg < MIN_BUFSIZE)
-      arg = BUFSIZE;
+      arg = READBUFFER_SIZE;
+    else if(arg < READBUFFER_MIN)
+      arg = READBUFFER_MIN;
 
     /* Resize only if larger than default buffer size. */
-    if(arg > BUFSIZE) {
-      char *newbuff = realloc(data->state.buffer, data->set.buffer_size + 1);
+    if(arg > READBUFFER_SIZE) {
+      char *newbuff = realloc(data->state.buffer, arg + 1);
       if(!newbuff) {
         DEBUGF(fprintf(stderr, "Error: realloc of buffer failed\n"));
         result = CURLE_OUT_OF_MEMORY;
@@ -4208,7 +4212,7 @@ static struct connectdata *allocate_conn(struct Curl_easy *data)
   if(Curl_pipeline_wanted(data->multi, CURLPIPE_HTTP1) &&
      !conn->master_buffer) {
     /* Allocate master_buffer to be used for HTTP/1 pipelining */
-    conn->master_buffer = calloc(BUFSIZE, sizeof(char));
+    conn->master_buffer = calloc(MASTERBUF_SIZE, sizeof(char));
     if(!conn->master_buffer)
       goto error;
   }
index 22b0f81957c82f073308af27e23a955c9df5638a..56430122faf979096c060f265753c7c7574c071d 100644 (file)
 #include <libssh2_sftp.h>
 #endif /* HAVE_LIBSSH2_H */
 
-/* Download buffer size, keep it fairly big for speed reasons */
-#undef BUFSIZE
-#define BUFSIZE CURL_MAX_WRITE_SIZE
-#undef MAX_BUFSIZE
-#define MAX_BUFSIZE CURL_MAX_READ_SIZE
-#define MIN_BUFSIZE 1024
-
 /* The upload buffer size, should not be smaller than CURL_MAX_WRITE_SIZE, as
    it needs to hold a full buffer as could be sent in a write callback */
 #define UPLOAD_BUFSIZE CURL_MAX_WRITE_SIZE
 
+/* The "master buffer" is for HTTP pipelining */
+#define MASTERBUF_SIZE 16384
+
 /* Initial size of the buffer to store headers in, it'll be enlarged in case
    of need. */
 #define HEADERSIZE 256