1
0
mirror of https://github.com/moparisthebest/curl synced 2024-12-21 23:58:49 -05:00

- Dmitry Kurochkin cleaned up the pipelining code and removed the need for and

use of the "is_in_pipeline" struct field.
This commit is contained in:
Daniel Stenberg 2008-02-03 12:31:35 +00:00
parent 454e840590
commit ffae4f6b48
4 changed files with 33 additions and 50 deletions

View File

@ -6,6 +6,14 @@
Changelog Changelog
Daniel S (3 Feb 2008)
- Dmitry Kurochkin cleaned up the pipelining code and removed the need for and
use of the "is_in_pipeline" struct field.
- I wrote up and added the threaded-ssl.c example source code that shows how
to do multi-threaded downloads of HTTPS files with a libcurl that is built
with OpenSSL. It uses pthreads for the threading.
Daniel S (31 Jan 2008) Daniel S (31 Jan 2008)
- Niklas Angebrand made the cookie support in libcurl properly deal with the - Niklas Angebrand made the cookie support in libcurl properly deal with the
"HttpOnly" feature introduced by Microsoft and apparently also supported by "HttpOnly" feature introduced by Microsoft and apparently also supported by

View File

@ -585,7 +585,8 @@ CURLMcode curl_multi_remove_handle(CURLM *multi_handle,
multi->num_alive--; multi->num_alive--;
if(easy->easy_conn && if(easy->easy_conn &&
easy->easy_handle->state.is_in_pipeline && (easy->easy_conn->send_pipe->size +
easy->easy_conn->recv_pipe->size > 1) &&
easy->state > CURLM_STATE_WAITDO && easy->state > CURLM_STATE_WAITDO &&
easy->state < CURLM_STATE_COMPLETED) { easy->state < CURLM_STATE_COMPLETED) {
/* If the handle is in a pipeline and has started sending off its /* If the handle is in a pipeline and has started sending off its
@ -868,17 +869,12 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
infof(easy->easy_handle, "Pipe broke: handle 0x%x, url = %s\n", infof(easy->easy_handle, "Pipe broke: handle 0x%x, url = %s\n",
easy, easy->easy_handle->state.path); easy, easy->easy_handle->state.path);
if(easy->easy_handle->state.is_in_pipeline) { if(easy->state != CURLM_STATE_COMPLETED) {
/* Head back to the CONNECT state */ /* Head back to the CONNECT state */
multistate(easy, CURLM_STATE_CONNECT); multistate(easy, CURLM_STATE_CONNECT);
easy->easy_handle->state.is_in_pipeline = FALSE;
result = CURLM_CALL_MULTI_PERFORM; result = CURLM_CALL_MULTI_PERFORM;
easy->result = CURLE_OK; easy->result = CURLE_OK;
} }
else {
easy->result = CURLE_COULDNT_CONNECT;
multistate(easy, CURLM_STATE_COMPLETED);
}
easy->easy_handle->state.pipe_broke = FALSE; easy->easy_handle->state.pipe_broke = FALSE;
easy->easy_conn = NULL; easy->easy_conn = NULL;
@ -946,32 +942,24 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
easy->result = addHandleToSendOrPendPipeline(easy->easy_handle, easy->result = addHandleToSendOrPendPipeline(easy->easy_handle,
easy->easy_conn); easy->easy_conn);
if(CURLE_OK == easy->result) { if(CURLE_OK == easy->result) {
if (easy->easy_handle->state.is_in_pipeline) { if(async)
multistate(easy, CURLM_STATE_WAITDO); /* We're now waiting for an asynchronous name lookup */
if(isHandleAtHead(easy->easy_handle, multistate(easy, CURLM_STATE_WAITRESOLVE);
easy->easy_conn->send_pipe))
result = CURLM_CALL_MULTI_PERFORM;
}
else { else {
if(async) /* after the connect has been sent off, go WAITCONNECT unless the
/* We're now waiting for an asynchronous name lookup */ protocol connect is already done and we can go directly to
multistate(easy, CURLM_STATE_WAITRESOLVE); WAITDO! */
else { result = CURLM_CALL_MULTI_PERFORM;
/* after the connect has been sent off, go WAITCONNECT unless the
protocol connect is already done and we can go directly to
WAITDO! */
result = CURLM_CALL_MULTI_PERFORM;
if(protocol_connect) if(protocol_connect)
multistate(easy, CURLM_STATE_WAITDO); multistate(easy, CURLM_STATE_WAITDO);
else { else {
#ifndef CURL_DISABLE_HTTP #ifndef CURL_DISABLE_HTTP
if(easy->easy_conn->bits.tunnel_connecting) if(easy->easy_conn->bits.tunnel_connecting)
multistate(easy, CURLM_STATE_WAITPROXYCONNECT); multistate(easy, CURLM_STATE_WAITPROXYCONNECT);
else else
#endif #endif
multistate(easy, CURLM_STATE_WAITCONNECT); multistate(easy, CURLM_STATE_WAITCONNECT);
}
} }
} }
} }
@ -1287,7 +1275,6 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
easy->easy_conn->bits.close = TRUE; easy->easy_conn->bits.close = TRUE;
Curl_removeHandleFromPipeline(easy->easy_handle, Curl_removeHandleFromPipeline(easy->easy_handle,
easy->easy_conn->recv_pipe); easy->easy_conn->recv_pipe);
easy->easy_handle->state.is_in_pipeline = FALSE;
if(CURL_SOCKET_BAD != easy->easy_conn->sock[SECONDARYSOCKET]) { if(CURL_SOCKET_BAD != easy->easy_conn->sock[SECONDARYSOCKET]) {
/* if we failed anywhere, we must clean up the secondary socket if /* if we failed anywhere, we must clean up the secondary socket if
@ -1311,7 +1298,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
easy->easy_conn->recv_pipe); easy->easy_conn->recv_pipe);
/* Check if we can move pending requests to send pipe */ /* Check if we can move pending requests to send pipe */
checkPendPipeline(easy->easy_conn); checkPendPipeline(easy->easy_conn);
easy->easy_handle->state.is_in_pipeline = FALSE;
if(!retry) { if(!retry) {
/* if the URL is a follow-location and not just a retried request /* if the URL is a follow-location and not just a retried request
then figure out the URL here */ then figure out the URL here */
@ -1345,7 +1332,6 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
easy->easy_conn->recv_pipe); easy->easy_conn->recv_pipe);
/* Check if we can move pending requests to send pipe */ /* Check if we can move pending requests to send pipe */
checkPendPipeline(easy->easy_conn); checkPendPipeline(easy->easy_conn);
easy->easy_handle->state.is_in_pipeline = FALSE;
if(easy->easy_conn->bits.stream_was_rewound) { if(easy->easy_conn->bits.stream_was_rewound) {
/* This request read past its response boundary so we quickly /* This request read past its response boundary so we quickly
@ -1388,7 +1374,6 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
/* NOTE: no attempt to disconnect connections must be made /* NOTE: no attempt to disconnect connections must be made
in the case blocks above - cleanup happens only here */ in the case blocks above - cleanup happens only here */
easy->easy_handle->state.is_in_pipeline = FALSE;
easy->easy_handle->state.pipe_broke = FALSE; easy->easy_handle->state.pipe_broke = FALSE;
if(easy->easy_conn) { if(easy->easy_conn) {

View File

@ -387,9 +387,6 @@ CURLcode Curl_close(struct SessionHandle *data)
/* only for debugging, scan through all connections and see if there's a /* only for debugging, scan through all connections and see if there's a
pipe reference still identifying this handle */ pipe reference still identifying this handle */
if(data->state.is_in_pipeline)
fprintf(stderr, "CLOSED when in pipeline!\n");
if(data->state.connc && data->state.connc->type == CONNCACHE_MULTI) { if(data->state.connc && data->state.connc->type == CONNCACHE_MULTI) {
struct conncache *c = data->state.connc; struct conncache *c = data->state.connc;
long i; long i;
@ -2477,9 +2474,9 @@ ConnectionExists(struct SessionHandle *data,
} }
if(match) { if(match) {
if(!check->is_in_pipeline) { if(pipeLen == 0) {
/* The check for a dead socket makes sense only in the /* The check for a dead socket makes sense only if there
non-pipelining case */ are no handles in pipeline */
bool dead = SocketIsDead(check->sock[FIRSTSOCKET]); bool dead = SocketIsDead(check->sock[FIRSTSOCKET]);
if(dead) { if(dead) {
check->data = data; check->data = data;
@ -2494,10 +2491,6 @@ ConnectionExists(struct SessionHandle *data,
check->inuse = TRUE; /* mark this as being in use so that no other check->inuse = TRUE; /* mark this as being in use so that no other
handle in a multi stack may nick it */ handle in a multi stack may nick it */
if(canPipeline) {
/* Mark the connection as being in a pipeline */
check->is_in_pipeline = TRUE;
}
*usethis = check; *usethis = check;
return TRUE; /* yes, we found one to use! */ return TRUE; /* yes, we found one to use! */
@ -2560,8 +2553,6 @@ static void
ConnectionDone(struct connectdata *conn) ConnectionDone(struct connectdata *conn)
{ {
conn->inuse = FALSE; conn->inuse = FALSE;
if(!conn->send_pipe && !conn->recv_pipe && !conn->pend_pipe)
conn->is_in_pipeline = FALSE;
} }
/* /*
@ -4338,8 +4329,10 @@ CURLcode Curl_connect(struct SessionHandle *data,
if(CURLE_OK == code) { if(CURLE_OK == code) {
/* no error */ /* no error */
if((*in_connect)->is_in_pipeline) if((*in_connect)->send_pipe->size +
data->state.is_in_pipeline = TRUE; (*in_connect)->recv_pipe->size != 0)
/* pipelining */
*protocol_done = TRUE;
else { else {
if(dns || !*asyncp) if(dns || !*asyncp)
/* If an address is available it means that we already have the name /* If an address is available it means that we already have the name

View File

@ -950,7 +950,6 @@ struct connectdata {
handle */ handle */
bool writechannel_inuse; /* whether the write channel is in use by an easy bool writechannel_inuse; /* whether the write channel is in use by an easy
handle */ handle */
bool is_in_pipeline; /* TRUE if this connection is in a pipeline */
bool server_supports_pipelining; /* TRUE if server supports pipelining, bool server_supports_pipelining; /* TRUE if server supports pipelining,
set after first response */ set after first response */
@ -1135,8 +1134,6 @@ struct UrlState {
bytes / second */ bytes / second */
bool this_is_a_follow; /* this is a followed Location: request */ bool this_is_a_follow; /* this is a followed Location: request */
bool is_in_pipeline; /* Indicates whether this handle is part of a pipeline */
char *first_host; /* if set, this should be the host name that we will char *first_host; /* if set, this should be the host name that we will
sent authorization to, no else. Used to make Location: sent authorization to, no else. Used to make Location:
following not keep sending user+password... This is following not keep sending user+password... This is