Commit e40e9d7f authored by Daniel Stenberg's avatar Daniel Stenberg
Browse files

buffer: use data->set.buffer_size instead of BUFSIZE

... to properly use the dynamically set buffer size!
parent c79f4908
Loading
Loading
Loading
Loading
+3 −4
Original line number Diff line number Diff line
@@ -558,12 +558,11 @@ static CURLcode file_do(struct connectdata *conn, bool *done)
    size_t bytestoread;

    if(size_known) {
      bytestoread =
        (expected_size < CURL_OFF_T_C(BUFSIZE) - CURL_OFF_T_C(1)) ?
        curlx_sotouz(expected_size) : BUFSIZE - 1;
      bytestoread = (expected_size < data->set.buffer_size) ?
        curlx_sotouz(expected_size) : (size_t)data->set.buffer_size;
    }
    else
      bytestoread = BUFSIZE-1;
      bytestoread = data->set.buffer_size-1;

    nread = read(fd, buf, bytestoread);

+3 −2
Original line number Diff line number Diff line
@@ -1681,8 +1681,9 @@ static CURLcode ftp_state_ul_setup(struct connectdata *conn,
      /* seekerr == CURL_SEEKFUNC_CANTSEEK (can't seek to offset) */
      do {
        size_t readthisamountnow =
          (data->state.resume_from - passed > CURL_OFF_T_C(BUFSIZE)) ?
          BUFSIZE : curlx_sotouz(data->state.resume_from - passed);
          (data->state.resume_from - passed > data->set.buffer_size) ?
          (size_t)data->set.buffer_size :
          curlx_sotouz(data->state.resume_from - passed);

        size_t actuallyread =
          data->state.fread_func(data->state.buffer, 1, readthisamountnow,
+4 −3
Original line number Diff line number Diff line
@@ -1117,7 +1117,7 @@ CURLcode Curl_add_buffer_send(Curl_send_buffer *in,
       buffer is using this size.
    */

    sendsize = (size > CURL_MAX_WRITE_SIZE) ? CURL_MAX_WRITE_SIZE : size;
    sendsize = CURLMIN(size, CURL_MAX_WRITE_SIZE);

    /* OpenSSL is very picky and we must send the SAME buffer pointer to the
       library when we attempt to re-send this buffer. Sending the same data
@@ -2172,8 +2172,9 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
        /* when seekerr == CURL_SEEKFUNC_CANTSEEK (can't seek to offset) */
        do {
          size_t readthisamountnow =
            (data->state.resume_from - passed > CURL_OFF_T_C(BUFSIZE)) ?
            BUFSIZE : curlx_sotouz(data->state.resume_from - passed);
            (data->state.resume_from - passed > data->set.buffer_size) ?
            (size_t)data->set.buffer_size :
            curlx_sotouz(data->state.resume_from - passed);

          size_t actuallyread =
            data->state.fread_func(data->state.buffer, 1, readthisamountnow,
+5 −6
Original line number Diff line number Diff line
@@ -149,7 +149,7 @@ static void pre_receive_plain(struct connectdata *conn, int num)
      /* Have some incoming data */
      if(!psnd->buffer) {
        /* Use buffer double default size for intermediate buffer */
        psnd->allocated_size = 2 * BUFSIZE;
        psnd->allocated_size = 2 * conn->data->set.buffer_size;
        psnd->buffer = malloc(psnd->allocated_size);
        psnd->recv_size = 0;
        psnd->recv_processed = 0;
@@ -693,9 +693,10 @@ CURLcode Curl_read(struct connectdata *conn, /* connection data */
  ssize_t nread = 0;
  size_t bytesfromsocket = 0;
  char *buffertofill = NULL;
  struct Curl_easy *data = conn->data;

  /* if HTTP/1 pipelining is both wanted and possible */
  bool pipelining = Curl_pipeline_wanted(conn->data->multi, CURLPIPE_HTTP1) &&
  bool pipelining = Curl_pipeline_wanted(data->multi, CURLPIPE_HTTP1) &&
    (conn->bundle->multiuse == BUNDLE_PIPELINING);

  /* Set 'num' to 0 or 1, depending on which socket that has been sent here.
@@ -721,13 +722,11 @@ 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, BUFSIZE * sizeof(char));
    bytesfromsocket = CURLMIN(sizerequested, (size_t)data->set.buffer_size);
    buffertofill = conn->master_buffer;
  }
  else {
    bytesfromsocket = CURLMIN((long)sizerequested,
                              conn->data->set.buffer_size ?
                              conn->data->set.buffer_size : BUFSIZE);
    bytesfromsocket = CURLMIN(sizerequested, (size_t)data->set.buffer_size);
    buffertofill = buf;
  }

+1 −1
Original line number Diff line number Diff line
@@ -1591,7 +1591,7 @@ CURLcode Curl_smtp_escape_eob(struct connectdata *conn, const ssize_t nread)
  if(!scratch || data->set.crlf) {
    oldscratch = scratch;

    scratch = newscratch = malloc(2 * BUFSIZE);
    scratch = newscratch = malloc(2 * data->set.buffer_size);
    if(!newscratch) {
      failf(data, "Failed to alloc scratch buffer!");

Loading