[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [gnurl] 21/254: transfer: remove 'uploadbuf' pointer and cl
From: |
gnunet |
Subject: |
[GNUnet-SVN] [gnurl] 21/254: transfer: remove 'uploadbuf' pointer and cleanup readwrite_upload() |
Date: |
Sat, 17 Jun 2017 16:50:53 +0200 |
This is an automated email from the git hooks/post-receive script.
ng0 pushed a commit to annotated tag gnurl-7.54.1
in repository gnurl.
commit e698b822877898c44f0ee809b17aff8437674128
Author: Daniel Stenberg <address@hidden>
AuthorDate: Tue Apr 25 10:49:53 2017 +0200
transfer: remove 'uploadbuf' pointer and cleanup readwrite_upload()
The data->req.uploadbuf struct member served no good purpose, instead we
use ->state.uploadbuffer directly. It makes it clearer in the code which
buffer that's being used.
Removed the 'SingleRequest *' argument from the readwrite_upload() proto
as it can be derived from the Curl_easy struct. Also made the code in
the readwrite_upload() function use the 'k->' shortcut to all references
to struct fields in 'data->req', which previously was made with a mix of
both.
---
lib/transfer.c | 52 +++++++++++++++++++++++++---------------------------
lib/url.c | 1 -
lib/urldata.h | 1 -
3 files changed, 25 insertions(+), 29 deletions(-)
diff --git a/lib/transfer.c b/lib/transfer.c
index 1f6d26d7f..72ab5446c 100644
--- a/lib/transfer.c
+++ b/lib/transfer.c
@@ -853,7 +853,6 @@ static CURLcode done_sending(struct connectdata *conn,
*/
static CURLcode readwrite_upload(struct Curl_easy *data,
struct connectdata *conn,
- struct SingleRequest *k,
int *didwhat)
{
ssize_t i, si;
@@ -861,6 +860,7 @@ static CURLcode readwrite_upload(struct Curl_easy *data,
CURLcode result;
ssize_t nread; /* number of bytes read */
bool sending_http_headers = FALSE;
+ struct SingleRequest *k = &data->req;
if((k->bytecount == 0) && (k->writebytecount == 0))
Curl_pgrsTime(data, TIMER_STARTTRANSFER);
@@ -871,15 +871,15 @@ static CURLcode readwrite_upload(struct Curl_easy *data,
/* only read more data if there's no upload data already
present in the upload buffer */
- if(0 == data->req.upload_present) {
+ if(0 == k->upload_present) {
/* init the "upload from here" pointer */
- data->req.upload_fromhere = k->uploadbuf;
+ k->upload_fromhere = data->state.uploadbuffer;
if(!k->upload_done) {
/* HTTP pollution, this should be written nicer to become more
protocol agnostic. */
int fillcount;
- struct HTTP *http = data->req.protop;
+ struct HTTP *http = k->protop;
if((k->exp100 == EXP100_SENDING_REQUEST) &&
(http->sending == HTTPSEND_BODY)) {
@@ -926,7 +926,7 @@ static CURLcode readwrite_upload(struct Curl_easy *data,
}
/* store number of bytes available for upload */
- data->req.upload_present = nread;
+ k->upload_present = nread;
/* convert LF to CRLF if so asked */
if((!sending_http_headers) && (
@@ -952,7 +952,7 @@ static CURLcode readwrite_upload(struct Curl_easy *data,
* must be used instead of the escape sequences \r & \n.
*/
for(i = 0, si = 0; i < nread; i++, si++) {
- if(data->req.upload_fromhere[i] == 0x0a) {
+ if(k->upload_fromhere[i] == 0x0a) {
data->state.scratch[si++] = 0x0d;
data->state.scratch[si] = 0x0a;
if(!data->set.crlf) {
@@ -963,7 +963,7 @@ static CURLcode readwrite_upload(struct Curl_easy *data,
}
}
else
- data->state.scratch[si] = data->req.upload_fromhere[i];
+ data->state.scratch[si] = k->upload_fromhere[i];
}
if(si != nread) {
@@ -972,10 +972,10 @@ static CURLcode readwrite_upload(struct Curl_easy *data,
nread = si;
/* upload from the new (replaced) buffer instead */
- data->req.upload_fromhere = data->state.scratch;
+ k->upload_fromhere = data->state.scratch;
/* set the new amount too */
- data->req.upload_present = nread;
+ k->upload_present = nread;
}
}
@@ -986,7 +986,7 @@ static CURLcode readwrite_upload(struct Curl_easy *data,
return result;
}
#endif /* CURL_DISABLE_SMTP */
- } /* if 0 == data->req.upload_present */
+ } /* if 0 == k->upload_present */
else {
/* We have a partial buffer left from a previous "round". Use
that instead of reading more data */
@@ -994,17 +994,17 @@ static CURLcode readwrite_upload(struct Curl_easy *data,
/* write to socket (send away data) */
result = Curl_write(conn,
- conn->writesockfd, /* socket to send to */
- data->req.upload_fromhere, /* buffer pointer */
- data->req.upload_present, /* buffer size */
- &bytes_written); /* actually sent */
+ conn->writesockfd, /* socket to send to */
+ k->upload_fromhere, /* buffer pointer */
+ k->upload_present, /* buffer size */
+ &bytes_written); /* actually sent */
if(result)
return result;
if(data->set.verbose)
/* show the data before we change the pointer upload_fromhere */
- Curl_debug(data, CURLINFO_DATA_OUT, data->req.upload_fromhere,
+ Curl_debug(data, CURLINFO_DATA_OUT, k->upload_fromhere,
(size_t)bytes_written, conn);
k->writebytecount += bytes_written;
@@ -1015,20 +1015,20 @@ static CURLcode readwrite_upload(struct Curl_easy *data,
infof(data, "We are completely uploaded and fine\n");
}
- if(data->req.upload_present != bytes_written) {
+ if(k->upload_present != bytes_written) {
/* we only wrote a part of the buffer (if anything), deal with it! */
/* store the amount of bytes left in the buffer to write */
- data->req.upload_present -= bytes_written;
+ k->upload_present -= bytes_written;
/* advance the pointer where to find the buffer when the next send
is to happen */
- data->req.upload_fromhere += bytes_written;
+ k->upload_fromhere += bytes_written;
}
else {
/* we've uploaded that buffer now */
- data->req.upload_fromhere = k->uploadbuf;
- data->req.upload_present = 0; /* no more bytes left */
+ k->upload_fromhere = data->state.uploadbuffer;
+ k->upload_present = 0; /* no more bytes left */
if(k->upload_done) {
result = done_sending(conn, k);
@@ -1108,7 +1108,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
if((k->keepon & KEEP_SEND) && (select_res & CURL_CSELECT_OUT)) {
/* write */
- result = readwrite_upload(data, conn, k, &didwhat);
+ result = readwrite_upload(data, conn, &didwhat);
if(result)
return result;
}
@@ -1186,15 +1186,13 @@ CURLcode Curl_readwrite(struct connectdata *conn,
*/
(k->bytecount != (k->size + data->state.crlf_conversions)) &&
#endif /* CURL_DO_LINEEND_CONV */
- !data->req.newurl) {
+ !k->newurl) {
failf(data, "transfer closed with %" CURL_FORMAT_CURL_OFF_T
- " bytes remaining to read",
- k->size - k->bytecount);
+ " bytes remaining to read", k->size - k->bytecount);
return CURLE_PARTIAL_FILE;
}
- if(!(data->set.opt_no_body) &&
- k->chunk &&
- (conn->chunk.state != CHUNK_STOP)) {
+ if(!(data->set.opt_no_body) && k->chunk &&
+ (conn->chunk.state != CHUNK_STOP)) {
/*
* In chunked mode, return an error if the connection is closed prior to
* the empty (terminating) chunk is read.
diff --git a/lib/url.c b/lib/url.c
index caa28f5d4..19388437a 100644
--- a/lib/url.c
+++ b/lib/url.c
@@ -6961,7 +6961,6 @@ CURLcode Curl_init_do(struct Curl_easy *data, struct
connectdata *conn)
k->bytecount = 0;
k->buf = data->state.buffer;
- k->uploadbuf = data->state.uploadbuffer;
k->hbufp = data->state.headerbuff;
k->ignorebody=FALSE;
diff --git a/lib/urldata.h b/lib/urldata.h
index d4a4a2306..f7a55e15e 100644
--- a/lib/urldata.h
+++ b/lib/urldata.h
@@ -721,7 +721,6 @@ struct SingleRequest {
long bodywrites;
char *buf;
- char *uploadbuf;
curl_socket_t maxfd;
int keepon;
--
To stop receiving notification emails like this one, please contact
address@hidden
- [GNUnet-SVN] [gnurl] 25/254: nss: factorize out nss_{un, }load_module to separate fncs, (continued)
- [GNUnet-SVN] [gnurl] 25/254: nss: factorize out nss_{un, }load_module to separate fncs, gnunet, 2017/06/17
- [GNUnet-SVN] [gnurl] 138/254: curl: show the libcurl release date in --version output, gnunet, 2017/06/17
- [GNUnet-SVN] [gnurl] 88/254: schannel: return a more specific error code for SEC_E_UNTRUSTED_ROOT, gnunet, 2017/06/17
- [GNUnet-SVN] [gnurl] 76/254: Telnet: Write full buffer instead of byte-by-byte, gnunet, 2017/06/17
- [GNUnet-SVN] [gnurl] 146/254: darwinssl: Fix exception when processing a client-side certificate file if no error was raised by the API but the SecIdentityRef was null, gnunet, 2017/06/17
- [GNUnet-SVN] [gnurl] 101/254: opts: examples added to 8 more libcurl option man pages, gnunet, 2017/06/17
- [GNUnet-SVN] [gnurl] 130/254: pipeline: fix mistakenly trying to pipeline POSTs, gnunet, 2017/06/17
- [GNUnet-SVN] [gnurl] 165/254: LDAP: fixed checksrc issue, gnunet, 2017/06/17
- [GNUnet-SVN] [gnurl] 90/254: sockfilt.c: shortened too long line, gnunet, 2017/06/17
- [GNUnet-SVN] [gnurl] 136/254: lib510: don't write past the end of the buffer if it's too small, gnunet, 2017/06/17
- [GNUnet-SVN] [gnurl] 21/254: transfer: remove 'uploadbuf' pointer and cleanup readwrite_upload(),
gnunet <=
- [GNUnet-SVN] [gnurl] 96/254: docs/opts: 23 more man pages now have examples, gnunet, 2017/06/17
- [GNUnet-SVN] [gnurl] 110/254: RELEASE-NOTES: synced with e3f84efc32d6b01a, gnunet, 2017/06/17
- [GNUnet-SVN] [gnurl] 117/254: tests: updated for modified fake random, gnunet, 2017/06/17
- [GNUnet-SVN] [gnurl] 194/254: CURLOPT_STREAM_DEPENDS.3: typo, gnunet, 2017/06/17
- [GNUnet-SVN] [gnurl] 124/254: tests: remove superfluous test 1399, gnunet, 2017/06/17
- [GNUnet-SVN] [gnurl] 131/254: multi: remove leftover debug infof() calls from e9fd794a6, gnunet, 2017/06/17
- [GNUnet-SVN] [gnurl] 51/254: tool: Fix missing prototype warnings for CURL_DOES_CONVERSIONS, gnunet, 2017/06/17
- [GNUnet-SVN] [gnurl] 43/254: unit1604: fixed indentation, gnunet, 2017/06/17
- [GNUnet-SVN] [gnurl] 220/254: CONTRIBUTE.md: mention tests done on pull requests, gnunet, 2017/06/17
- [GNUnet-SVN] [gnurl] 141/254: man pages: fix example syntax errors, gnunet, 2017/06/17