mirror of
https://github.com/moparisthebest/curl
synced 2024-11-11 12:05:06 -05:00
FILE: we don't support paused transfers using this protocol
Make sure that we detect such attempts and return a proper error code instead of silently handling this in problematic ways. Updated the documentation to mention this limitation. Bug: http://curl.haxx.se/bug/view.cgi?id=1286
This commit is contained in:
parent
f88f9bed00
commit
2a4ee0d221
@ -31,8 +31,8 @@ curl_easy_pause - pause and unpause a connection
|
|||||||
Using this function, you can explicitly mark a running connection to get
|
Using this function, you can explicitly mark a running connection to get
|
||||||
paused, and you can unpause a connection that was previously paused.
|
paused, and you can unpause a connection that was previously paused.
|
||||||
|
|
||||||
A connection can be paused by using this function or by letting the read
|
A connection can be paused by using this function or by letting the read or
|
||||||
or the write callbacks return the proper magic return code
|
the write callbacks return the proper magic return code
|
||||||
(\fICURL_READFUNC_PAUSE\fP and \fICURL_WRITEFUNC_PAUSE\fP). A write callback
|
(\fICURL_READFUNC_PAUSE\fP and \fICURL_WRITEFUNC_PAUSE\fP). A write callback
|
||||||
that returns pause signals to the library that it couldn't take care of any
|
that returns pause signals to the library that it couldn't take care of any
|
||||||
data at all, and that data will then be delivered again to the callback when
|
data at all, and that data will then be delivered again to the callback when
|
||||||
@ -68,6 +68,10 @@ Convenience define that unpauses both directions
|
|||||||
CURLE_OK (zero) means that the option was set properly, and a non-zero return
|
CURLE_OK (zero) means that the option was set properly, and a non-zero return
|
||||||
code means something wrong occurred after the new state was set. See the
|
code means something wrong occurred after the new state was set. See the
|
||||||
\fIlibcurl-errors(3)\fP man page for the full list with descriptions.
|
\fIlibcurl-errors(3)\fP man page for the full list with descriptions.
|
||||||
|
.SH LIMITATIONS
|
||||||
|
The pausing of transfers does not work with protocols that work without
|
||||||
|
network connectivity, like FILE://. Trying to pause such a transfer, in any
|
||||||
|
direction, will cause problems in the worst case or an error in the best case.
|
||||||
.SH AVAILABILITY
|
.SH AVAILABILITY
|
||||||
This function was added in libcurl 7.18.0. Before this version, there was no
|
This function was added in libcurl 7.18.0. Before this version, there was no
|
||||||
explicit support for pausing transfers.
|
explicit support for pausing transfers.
|
||||||
|
12
lib/sendf.c
12
lib/sendf.c
@ -444,10 +444,18 @@ CURLcode Curl_client_write(struct connectdata *conn,
|
|||||||
wrote = len;
|
wrote = len;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(CURL_WRITEFUNC_PAUSE == wrote)
|
if(conn->handler->flags & PROTOPT_NONETWORK) {
|
||||||
|
/* protocols that work without network cannot be paused. This is
|
||||||
|
actually only FILE:// just now, and it can't pause since the transfer
|
||||||
|
isn't done using the "normal" procedure. */
|
||||||
|
failf(data, "Write callback asked for PAUSE when not supported!");
|
||||||
|
return CURLE_WRITE_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
else if(CURL_WRITEFUNC_PAUSE == wrote)
|
||||||
return pausewrite(data, type, ptr, len);
|
return pausewrite(data, type, ptr, len);
|
||||||
|
|
||||||
if(wrote != len) {
|
else if(wrote != len) {
|
||||||
failf(data, "Failed writing body (%zu != %zu)", wrote, len);
|
failf(data, "Failed writing body (%zu != %zu)", wrote, len);
|
||||||
return CURLE_WRITE_ERROR;
|
return CURLE_WRITE_ERROR;
|
||||||
}
|
}
|
||||||
|
@ -128,6 +128,15 @@ CURLcode Curl_fillreadbuffer(struct connectdata *conn, int bytes, int *nreadp)
|
|||||||
return CURLE_ABORTED_BY_CALLBACK;
|
return CURLE_ABORTED_BY_CALLBACK;
|
||||||
}
|
}
|
||||||
else if(nread == CURL_READFUNC_PAUSE) {
|
else if(nread == CURL_READFUNC_PAUSE) {
|
||||||
|
|
||||||
|
if(conn->handler->flags & PROTOPT_NONETWORK) {
|
||||||
|
/* protocols that work without network cannot be paused. This is
|
||||||
|
actually only FILE:// just now, and it can't pause since the transfer
|
||||||
|
isn't done using the "normal" procedure. */
|
||||||
|
failf(data, "Read callback asked for PAUSE when not supported!");
|
||||||
|
return CURLE_READ_ERROR;
|
||||||
|
}
|
||||||
|
else {
|
||||||
struct SingleRequest *k = &data->req;
|
struct SingleRequest *k = &data->req;
|
||||||
/* CURL_READFUNC_PAUSE pauses read callbacks that feed socket writes */
|
/* CURL_READFUNC_PAUSE pauses read callbacks that feed socket writes */
|
||||||
k->keepon |= KEEP_SEND_PAUSE; /* mark socket send as paused */
|
k->keepon |= KEEP_SEND_PAUSE; /* mark socket send as paused */
|
||||||
@ -136,6 +145,7 @@ CURLcode Curl_fillreadbuffer(struct connectdata *conn, int bytes, int *nreadp)
|
|||||||
data->req.upload_fromhere -= (8 + 2);
|
data->req.upload_fromhere -= (8 + 2);
|
||||||
}
|
}
|
||||||
*nreadp = 0;
|
*nreadp = 0;
|
||||||
|
}
|
||||||
return CURLE_OK; /* nothing was read */
|
return CURLE_OK; /* nothing was read */
|
||||||
}
|
}
|
||||||
else if((size_t)nread > buffersize) {
|
else if((size_t)nread > buffersize) {
|
||||||
|
Loading…
Reference in New Issue
Block a user