Loading lib/easy.c +5 −5 Original line number Original line Diff line number Diff line Loading @@ -766,17 +766,17 @@ CURLcode curl_easy_pause(CURL *curl, int action) CURLcode result = CURLE_OK; CURLcode result = CURLE_OK; /* first switch off both pause bits */ /* first switch off both pause bits */ int newstate = k->keepon &~ (KEEP_READ_PAUSE| KEEP_WRITE_PAUSE); int newstate = k->keepon &~ (KEEP_RECV_PAUSE| KEEP_SEND_PAUSE); /* set the new desired pause bits */ /* set the new desired pause bits */ newstate |= ((action & CURLPAUSE_RECV)?KEEP_READ_PAUSE:0) | newstate |= ((action & CURLPAUSE_RECV)?KEEP_RECV_PAUSE:0) | ((action & CURLPAUSE_SEND)?KEEP_WRITE_PAUSE:0); ((action & CURLPAUSE_SEND)?KEEP_SEND_PAUSE:0); /* put it back in the keepon */ /* put it back in the keepon */ k->keepon = newstate; k->keepon = newstate; if(!(newstate & KEEP_READ_PAUSE) && data->state.tempwrite) { if(!(newstate & KEEP_RECV_PAUSE) && data->state.tempwrite) { /* we have a buffer for writing that we now seem to be able to deliver since /* we have a buffer for sending that we now seem to be able to deliver since the receive pausing is lifted! */ the receive pausing is lifted! */ /* get the pointer, type and length in local copies since the function may /* get the pointer, type and length in local copies since the function may Loading lib/multi.c +4 −4 Original line number Original line Diff line number Diff line Loading @@ -1299,13 +1299,13 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi, k = &easy->easy_handle->req; k = &easy->easy_handle->req; if(!(k->keepon & KEEP_READ)) { if(!(k->keepon & KEEP_RECV)) { /* We're done reading */ /* We're done receiving */ easy->easy_conn->readchannel_inuse = FALSE; easy->easy_conn->readchannel_inuse = FALSE; } } if(!(k->keepon & KEEP_WRITE)) { if(!(k->keepon & KEEP_SEND)) { /* We're done writing */ /* We're done sending */ easy->easy_conn->writechannel_inuse = FALSE; easy->easy_conn->writechannel_inuse = FALSE; } } Loading lib/sendf.c +2 −2 Original line number Original line Diff line number Diff line Loading @@ -341,7 +341,7 @@ static CURLcode pausewrite(struct SessionHandle *data, data->state.tempwritetype = type; data->state.tempwritetype = type; /* mark the connection as RECV paused */ /* mark the connection as RECV paused */ k->keepon |= KEEP_READ_PAUSE; k->keepon |= KEEP_RECV_PAUSE; DEBUGF(infof(data, "Pausing with %d bytes in buffer for type %02x\n", DEBUGF(infof(data, "Pausing with %d bytes in buffer for type %02x\n", (int)len, type)); (int)len, type)); Loading Loading @@ -373,7 +373,7 @@ CURLcode Curl_client_write(struct connectdata *conn, /* If reading is actually paused, we're forced to append this chunk of data /* If reading is actually paused, we're forced to append this chunk of data to the already held data, but only if it is the same type as otherwise it to the already held data, but only if it is the same type as otherwise it can't work and it'll return error instead. */ can't work and it'll return error instead. */ if(data->req.keepon & KEEP_READ_PAUSE) { if(data->req.keepon & KEEP_RECV_PAUSE) { size_t newlen; size_t newlen; char *newptr; char *newptr; if(type != data->state.tempwritetype) if(type != data->state.tempwritetype) Loading lib/ssh.c +4 −4 Original line number Original line Diff line number Diff line Loading @@ -2102,10 +2102,10 @@ static int ssh_perform_getsock(const struct connectdata *conn, sock[0] = conn->sock[FIRSTSOCKET]; sock[0] = conn->sock[FIRSTSOCKET]; if(conn->proto.sshc.waitfor & KEEP_READ) if(conn->proto.sshc.waitfor & KEEP_RECV) bitmap |= GETSOCK_READSOCK(FIRSTSOCKET); bitmap |= GETSOCK_READSOCK(FIRSTSOCKET); if(conn->proto.sshc.waitfor & KEEP_WRITE) if(conn->proto.sshc.waitfor & KEEP_SEND) bitmap |= GETSOCK_WRITESOCK(FIRSTSOCKET); bitmap |= GETSOCK_WRITESOCK(FIRSTSOCKET); return bitmap; return bitmap; Loading Loading @@ -2151,8 +2151,8 @@ static void ssh_block2waitfor(struct connectdata *conn, bool block) int dir; int dir; if(block && (dir = libssh2_session_block_directions(sshc->ssh_session))) { if(block && (dir = libssh2_session_block_directions(sshc->ssh_session))) { /* translate the libssh2 define bits into our own bit defines */ /* translate the libssh2 define bits into our own bit defines */ sshc->waitfor = ((dir&LIBSSH2_SESSION_BLOCK_INBOUND)?KEEP_READ:0) | sshc->waitfor = ((dir&LIBSSH2_SESSION_BLOCK_INBOUND)?KEEP_RECV:0) | ((dir&LIBSSH2_SESSION_BLOCK_OUTBOUND)?KEEP_WRITE:0); ((dir&LIBSSH2_SESSION_BLOCK_OUTBOUND)?KEEP_SEND:0); } } else else /* It didn't block or libssh2 didn't reveal in which direction, put back /* It didn't block or libssh2 didn't reveal in which direction, put back Loading lib/transfer.c +43 −43 Original line number Original line Diff line number Diff line Loading @@ -157,7 +157,7 @@ CURLcode Curl_fillreadbuffer(struct connectdata *conn, int bytes, int *nreadp) else if(nread == CURL_READFUNC_PAUSE) { else if(nread == CURL_READFUNC_PAUSE) { 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_WRITE_PAUSE; /* mark socket send as paused */ k->keepon |= KEEP_SEND_PAUSE; /* mark socket send as paused */ if(data->req.upload_chunky) { if(data->req.upload_chunky) { /* Back out the preallocation done above */ /* Back out the preallocation done above */ data->req.upload_fromhere -= (8 + 2); data->req.upload_fromhere -= (8 + 2); Loading Loading @@ -320,7 +320,7 @@ CURLcode Curl_readrewind(struct connectdata *conn) about to restart a new transfer and thus we want to avoid inadvertently about to restart a new transfer and thus we want to avoid inadvertently sending more data on the existing connection until the next transfer sending more data on the existing connection until the next transfer starts */ starts */ data->req.keepon &= ~KEEP_WRITE; data->req.keepon &= ~KEEP_SEND; /* We have sent away data. If not using CURLOPT_POSTFIELDS or /* We have sent away data. If not using CURLOPT_POSTFIELDS or CURLOPT_HTTPPOST, call app to rewind CURLOPT_HTTPPOST, call app to rewind Loading Loading @@ -465,7 +465,7 @@ static CURLcode readwrite_data(struct SessionHandle *data, k->start100 = Curl_tvnow(); k->start100 = Curl_tvnow(); } } *didwhat |= KEEP_READ; *didwhat |= KEEP_RECV; /* indicates data of zero size, i.e. empty file */ /* indicates data of zero size, i.e. empty file */ is_empty_data = (bool)((nread == 0) && (k->bodywrites == 0)); is_empty_data = (bool)((nread == 0) && (k->bodywrites == 0)); Loading @@ -477,7 +477,7 @@ static CURLcode readwrite_data(struct SessionHandle *data, /* if we receive 0 or less here, the server closed the connection /* if we receive 0 or less here, the server closed the connection and we bail out from this! */ and we bail out from this! */ DEBUGF(infof(data, "nread <= 0, server closed connection, bailing\n")); DEBUGF(infof(data, "nread <= 0, server closed connection, bailing\n")); k->keepon &= ~KEEP_READ; k->keepon &= ~KEEP_RECV; break; break; } } Loading Loading @@ -517,7 +517,7 @@ static CURLcode readwrite_data(struct SessionHandle *data, if(conn->bits.close) { if(conn->bits.close) { /* Abort after the headers if "follow Location" is set /* Abort after the headers if "follow Location" is set and we're set to close anyway. */ and we're set to close anyway. */ k->keepon &= ~KEEP_READ; k->keepon &= ~KEEP_RECV; *done = TRUE; *done = TRUE; return CURLE_OK; return CURLE_OK; } } Loading Loading @@ -610,7 +610,7 @@ static CURLcode readwrite_data(struct SessionHandle *data, else if(CHUNKE_STOP == res) { else if(CHUNKE_STOP == res) { size_t dataleft; size_t dataleft; /* we're done reading chunks! */ /* we're done reading chunks! */ k->keepon &= ~KEEP_READ; /* read no more */ k->keepon &= ~KEEP_RECV; /* read no more */ /* There are now possibly N number of bytes at the end of the /* There are now possibly N number of bytes at the end of the str buffer that weren't written to the client. str buffer that weren't written to the client. Loading Loading @@ -649,7 +649,7 @@ static CURLcode readwrite_data(struct SessionHandle *data, if(nread < 0 ) /* this should be unusual */ if(nread < 0 ) /* this should be unusual */ nread = 0; nread = 0; k->keepon &= ~KEEP_READ; /* we're done reading */ k->keepon &= ~KEEP_RECV; /* we're done reading */ } } k->bytecount += nread; k->bytecount += nread; Loading Loading @@ -721,18 +721,18 @@ static CURLcode readwrite_data(struct SessionHandle *data, if(is_empty_data) { if(is_empty_data) { /* if we received nothing, the server closed the connection and we /* if we received nothing, the server closed the connection and we are done */ are done */ k->keepon &= ~KEEP_READ; k->keepon &= ~KEEP_RECV; } } } while(data_pending(conn)); } while(data_pending(conn)); if(((k->keepon & (KEEP_READ|KEEP_WRITE)) == KEEP_WRITE) && if(((k->keepon & (KEEP_RECV|KEEP_SEND)) == KEEP_SEND) && conn->bits.close ) { conn->bits.close ) { /* When we've read the entire thing and the close bit is set, the server /* When we've read the entire thing and the close bit is set, the server may now close the connection. If there's now any kind of sending going may now close the connection. If there's now any kind of sending going on from our side, we need to stop that immediately. */ on from our side, we need to stop that immediately. */ infof(data, "we are done reading and this is set to close, stop send\n"); infof(data, "we are done reading and this is set to close, stop send\n"); k->keepon &= ~KEEP_WRITE; /* no writing anymore either */ k->keepon &= ~KEEP_SEND; /* no writing anymore either */ } } return CURLE_OK; return CURLE_OK; Loading Loading @@ -895,7 +895,7 @@ static CURLcode readwrite_http_headers(struct SessionHandle *data, /* if we did wait for this do enable write now! */ /* if we did wait for this do enable write now! */ if(k->exp100) { if(k->exp100) { k->exp100 = EXP100_SEND_DATA; k->exp100 = EXP100_SEND_DATA; k->keepon |= KEEP_WRITE; k->keepon |= KEEP_SEND; } } } } else { else { Loading @@ -922,7 +922,7 @@ static CURLcode readwrite_http_headers(struct SessionHandle *data, * (or prevent them from starting). * (or prevent them from starting). */ */ k->exp100 = EXP100_FAILED; k->exp100 = EXP100_FAILED; k->keepon &= ~KEEP_WRITE; k->keepon &= ~KEEP_SEND; } } /* /* Loading Loading @@ -975,7 +975,7 @@ static CURLcode readwrite_http_headers(struct SessionHandle *data, /* We rewind after a complete send, so thus we continue /* We rewind after a complete send, so thus we continue sending now */ sending now */ infof(data, "Keep sending data to get tossed away!\n"); infof(data, "Keep sending data to get tossed away!\n"); k->keepon |= KEEP_WRITE; k->keepon |= KEEP_SEND; } } } } Loading Loading @@ -1021,7 +1021,7 @@ static CURLcode readwrite_http_headers(struct SessionHandle *data, if(*stop_reading) { if(*stop_reading) { /* we make sure that this socket isn't read more now */ /* we make sure that this socket isn't read more now */ k->keepon &= ~KEEP_READ; k->keepon &= ~KEEP_RECV; } } if(data->set.verbose) if(data->set.verbose) Loading Loading @@ -1463,7 +1463,7 @@ static CURLcode readwrite_upload(struct SessionHandle *data, if((k->bytecount == 0) && (k->writebytecount == 0)) if((k->bytecount == 0) && (k->writebytecount == 0)) Curl_pgrsTime(data, TIMER_STARTTRANSFER); Curl_pgrsTime(data, TIMER_STARTTRANSFER); *didwhat |= KEEP_WRITE; *didwhat |= KEEP_SEND; /* /* * We loop here to do the READ and SEND loop until we run out of * We loop here to do the READ and SEND loop until we run out of Loading @@ -1488,9 +1488,9 @@ static CURLcode readwrite_upload(struct SessionHandle *data, We have sent off the full HTTP 1.1 request, and we shall now We have sent off the full HTTP 1.1 request, and we shall now go into the Expect: 100 state and await such a header */ go into the Expect: 100 state and await such a header */ k->exp100 = EXP100_AWAITING_CONTINUE; /* wait for the header */ k->exp100 = EXP100_AWAITING_CONTINUE; /* wait for the header */ k->keepon &= ~KEEP_WRITE; /* disable writing */ k->keepon &= ~KEEP_SEND; /* disable writing */ k->start100 = Curl_tvnow(); /* timeout count starts now */ k->start100 = Curl_tvnow(); /* timeout count starts now */ *didwhat &= ~KEEP_WRITE; /* we didn't write anything actually */ *didwhat &= ~KEEP_SEND; /* we didn't write anything actually */ break; break; } } Loading @@ -1512,13 +1512,13 @@ static CURLcode readwrite_upload(struct SessionHandle *data, else else nread = 0; /* we're done uploading/reading */ nread = 0; /* we're done uploading/reading */ if(!nread && (k->keepon & KEEP_WRITE_PAUSE)) { if(!nread && (k->keepon & KEEP_SEND_PAUSE)) { /* this is a paused transfer */ /* this is a paused transfer */ break; break; } } else if(nread<=0) { else if(nread<=0) { /* done */ /* done */ k->keepon &= ~KEEP_WRITE; /* we're done writing */ k->keepon &= ~KEEP_SEND; /* we're done writing */ if(conn->bits.rewindaftersend) { if(conn->bits.rewindaftersend) { result = Curl_readrewind(conn); result = Curl_readrewind(conn); Loading Loading @@ -1614,7 +1614,7 @@ static CURLcode readwrite_upload(struct SessionHandle *data, if(k->upload_done) { if(k->upload_done) { /* switch off writing, we're done! */ /* switch off writing, we're done! */ k->keepon &= ~KEEP_WRITE; /* we're done writing */ k->keepon &= ~KEEP_SEND; /* we're done writing */ } } } } Loading Loading @@ -1647,7 +1647,7 @@ CURLcode Curl_readwrite(struct connectdata *conn, /* only use the proper socket if the *_HOLD bit is not set simultaneously as /* only use the proper socket if the *_HOLD bit is not set simultaneously as then we are in rate limiting state in that transfer direction */ then we are in rate limiting state in that transfer direction */ if((k->keepon & KEEP_READBITS) == KEEP_READ) { if((k->keepon & KEEP_RECVBITS) == KEEP_RECV) { fd_read = conn->sockfd; fd_read = conn->sockfd; #if defined(USE_LIBSSH2) #if defined(USE_LIBSSH2) if(conn->protocol & (PROT_SCP|PROT_SFTP)) if(conn->protocol & (PROT_SCP|PROT_SFTP)) Loading @@ -1656,7 +1656,7 @@ CURLcode Curl_readwrite(struct connectdata *conn, } else } else fd_read = CURL_SOCKET_BAD; fd_read = CURL_SOCKET_BAD; if((k->keepon & KEEP_WRITEBITS) == KEEP_WRITE) if((k->keepon & KEEP_SENDBITS) == KEEP_SEND) fd_write = conn->writesockfd; fd_write = conn->writesockfd; else else fd_write = CURL_SOCKET_BAD; fd_write = CURL_SOCKET_BAD; Loading @@ -1674,7 +1674,7 @@ CURLcode Curl_readwrite(struct connectdata *conn, /* We go ahead and do a read if we have a readable socket or if /* We go ahead and do a read if we have a readable socket or if the stream was rewound (in which case we have data in a the stream was rewound (in which case we have data in a buffer) */ buffer) */ if((k->keepon & KEEP_READ) && if((k->keepon & KEEP_RECV) && ((select_res & CURL_CSELECT_IN) || conn->bits.stream_was_rewound)) { ((select_res & CURL_CSELECT_IN) || conn->bits.stream_was_rewound)) { result = readwrite_data(data, conn, k, &didwhat, done); result = readwrite_data(data, conn, k, &didwhat, done); Loading @@ -1683,7 +1683,7 @@ CURLcode Curl_readwrite(struct connectdata *conn, } } /* If we still have writing to do, we check if we have a writable socket. */ /* If we still have writing to do, we check if we have a writable socket. */ if((k->keepon & KEEP_WRITE) && (select_res & CURL_CSELECT_OUT)) { if((k->keepon & KEEP_SEND) && (select_res & CURL_CSELECT_OUT)) { /* write */ /* write */ result = readwrite_upload(data, conn, k, &didwhat); result = readwrite_upload(data, conn, k, &didwhat); Loading Loading @@ -1719,7 +1719,7 @@ CURLcode Curl_readwrite(struct connectdata *conn, if(ms > CURL_TIMEOUT_EXPECT_100) { if(ms > CURL_TIMEOUT_EXPECT_100) { /* we've waited long enough, continue anyway */ /* we've waited long enough, continue anyway */ k->exp100 = EXP100_SEND_DATA; k->exp100 = EXP100_SEND_DATA; k->keepon |= KEEP_WRITE; k->keepon |= KEEP_SEND; infof(data, "Done waiting for 100-continue\n"); infof(data, "Done waiting for 100-continue\n"); } } } } Loading Loading @@ -1787,8 +1787,8 @@ CURLcode Curl_readwrite(struct connectdata *conn, } } /* Now update the "done" boolean we return */ /* Now update the "done" boolean we return */ *done = (bool)(0 == (k->keepon&(KEEP_READ|KEEP_WRITE| *done = (bool)(0 == (k->keepon&(KEEP_RECV|KEEP_SEND| KEEP_READ_PAUSE|KEEP_WRITE_PAUSE))); KEEP_RECV_PAUSE|KEEP_SEND_PAUSE))); return CURLE_OK; return CURLE_OK; } } Loading Loading @@ -1817,7 +1817,7 @@ int Curl_single_getsock(const struct connectdata *conn, return GETSOCK_BLANK; return GETSOCK_BLANK; /* don't include HOLD and PAUSE connections */ /* don't include HOLD and PAUSE connections */ if((data->req.keepon & KEEP_READBITS) == KEEP_READ) { if((data->req.keepon & KEEP_RECVBITS) == KEEP_RECV) { DEBUGASSERT(conn->sockfd != CURL_SOCKET_BAD); DEBUGASSERT(conn->sockfd != CURL_SOCKET_BAD); Loading @@ -1826,13 +1826,13 @@ int Curl_single_getsock(const struct connectdata *conn, } } /* don't include HOLD and PAUSE connections */ /* don't include HOLD and PAUSE connections */ if((data->req.keepon & KEEP_WRITEBITS) == KEEP_WRITE) { if((data->req.keepon & KEEP_SENDBITS) == KEEP_SEND) { if((conn->sockfd != conn->writesockfd) || if((conn->sockfd != conn->writesockfd) || !(data->req.keepon & KEEP_READ)) { !(data->req.keepon & KEEP_RECV)) { /* only if they are not the same socket or we didn't have a readable /* only if they are not the same socket or we didn't have a readable one, we increase index */ one, we increase index */ if(data->req.keepon & KEEP_READ) if(data->req.keepon & KEEP_RECV) sockindex++; /* increase index if we need two entries */ sockindex++; /* increase index if we need two entries */ DEBUGASSERT(conn->writesockfd != CURL_SOCKET_BAD); DEBUGASSERT(conn->writesockfd != CURL_SOCKET_BAD); Loading Loading @@ -1887,34 +1887,34 @@ Transfer(struct connectdata *conn) /* limit-rate logic: if speed exceeds threshold, then do not include fd in /* limit-rate logic: if speed exceeds threshold, then do not include fd in select set. The current speed is recalculated in each Curl_readwrite() select set. The current speed is recalculated in each Curl_readwrite() call */ call */ if((k->keepon & KEEP_WRITE) && if((k->keepon & KEEP_SEND) && (!data->set.max_send_speed || (!data->set.max_send_speed || (data->progress.ulspeed < data->set.max_send_speed) )) { (data->progress.ulspeed < data->set.max_send_speed) )) { fd_write = conn->writesockfd; fd_write = conn->writesockfd; k->keepon &= ~KEEP_WRITE_HOLD; k->keepon &= ~KEEP_SEND_HOLD; } } else { else { fd_write = CURL_SOCKET_BAD; fd_write = CURL_SOCKET_BAD; if(k->keepon & KEEP_WRITE) if(k->keepon & KEEP_SEND) k->keepon |= KEEP_WRITE_HOLD; /* hold it */ k->keepon |= KEEP_SEND_HOLD; /* hold it */ } } if((k->keepon & KEEP_READ) && if((k->keepon & KEEP_RECV) && (!data->set.max_recv_speed || (!data->set.max_recv_speed || (data->progress.dlspeed < data->set.max_recv_speed)) ) { (data->progress.dlspeed < data->set.max_recv_speed)) ) { fd_read = conn->sockfd; fd_read = conn->sockfd; k->keepon &= ~KEEP_READ_HOLD; k->keepon &= ~KEEP_RECV_HOLD; } } else { else { fd_read = CURL_SOCKET_BAD; fd_read = CURL_SOCKET_BAD; if(k->keepon & KEEP_READ) if(k->keepon & KEEP_RECV) k->keepon |= KEEP_READ_HOLD; /* hold it */ k->keepon |= KEEP_RECV_HOLD; /* hold it */ } } /* pause logic. Don't check descriptors for paused connections */ /* pause logic. Don't check descriptors for paused connections */ if(k->keepon & KEEP_READ_PAUSE) if(k->keepon & KEEP_RECV_PAUSE) fd_read = CURL_SOCKET_BAD; fd_read = CURL_SOCKET_BAD; if(k->keepon & KEEP_WRITE_PAUSE) if(k->keepon & KEEP_SEND_PAUSE) fd_write = CURL_SOCKET_BAD; fd_write = CURL_SOCKET_BAD; /* The *_HOLD and *_PAUSE logic is necessary since even though there might /* The *_HOLD and *_PAUSE logic is necessary since even though there might Loading Loading @@ -2730,7 +2730,7 @@ Curl_setup_transfer( if(k->getheader || !data->set.opt_no_body) { if(k->getheader || !data->set.opt_no_body) { if(conn->sockfd != CURL_SOCKET_BAD) { if(conn->sockfd != CURL_SOCKET_BAD) { k->keepon |= KEEP_READ; k->keepon |= KEEP_RECV; } } if(conn->writesockfd != CURL_SOCKET_BAD) { if(conn->writesockfd != CURL_SOCKET_BAD) { Loading @@ -2756,7 +2756,7 @@ Curl_setup_transfer( k->exp100 = EXP100_SENDING_REQUEST; k->exp100 = EXP100_SENDING_REQUEST; /* enable the write bit when we're not waiting for continue */ /* enable the write bit when we're not waiting for continue */ k->keepon |= KEEP_WRITE; k->keepon |= KEEP_SEND; } } } /* if(conn->writesockfd != CURL_SOCKET_BAD) */ } /* if(conn->writesockfd != CURL_SOCKET_BAD) */ } /* if(k->getheader || !data->set.opt_no_body) */ } /* if(k->getheader || !data->set.opt_no_body) */ Loading Loading
lib/easy.c +5 −5 Original line number Original line Diff line number Diff line Loading @@ -766,17 +766,17 @@ CURLcode curl_easy_pause(CURL *curl, int action) CURLcode result = CURLE_OK; CURLcode result = CURLE_OK; /* first switch off both pause bits */ /* first switch off both pause bits */ int newstate = k->keepon &~ (KEEP_READ_PAUSE| KEEP_WRITE_PAUSE); int newstate = k->keepon &~ (KEEP_RECV_PAUSE| KEEP_SEND_PAUSE); /* set the new desired pause bits */ /* set the new desired pause bits */ newstate |= ((action & CURLPAUSE_RECV)?KEEP_READ_PAUSE:0) | newstate |= ((action & CURLPAUSE_RECV)?KEEP_RECV_PAUSE:0) | ((action & CURLPAUSE_SEND)?KEEP_WRITE_PAUSE:0); ((action & CURLPAUSE_SEND)?KEEP_SEND_PAUSE:0); /* put it back in the keepon */ /* put it back in the keepon */ k->keepon = newstate; k->keepon = newstate; if(!(newstate & KEEP_READ_PAUSE) && data->state.tempwrite) { if(!(newstate & KEEP_RECV_PAUSE) && data->state.tempwrite) { /* we have a buffer for writing that we now seem to be able to deliver since /* we have a buffer for sending that we now seem to be able to deliver since the receive pausing is lifted! */ the receive pausing is lifted! */ /* get the pointer, type and length in local copies since the function may /* get the pointer, type and length in local copies since the function may Loading
lib/multi.c +4 −4 Original line number Original line Diff line number Diff line Loading @@ -1299,13 +1299,13 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi, k = &easy->easy_handle->req; k = &easy->easy_handle->req; if(!(k->keepon & KEEP_READ)) { if(!(k->keepon & KEEP_RECV)) { /* We're done reading */ /* We're done receiving */ easy->easy_conn->readchannel_inuse = FALSE; easy->easy_conn->readchannel_inuse = FALSE; } } if(!(k->keepon & KEEP_WRITE)) { if(!(k->keepon & KEEP_SEND)) { /* We're done writing */ /* We're done sending */ easy->easy_conn->writechannel_inuse = FALSE; easy->easy_conn->writechannel_inuse = FALSE; } } Loading
lib/sendf.c +2 −2 Original line number Original line Diff line number Diff line Loading @@ -341,7 +341,7 @@ static CURLcode pausewrite(struct SessionHandle *data, data->state.tempwritetype = type; data->state.tempwritetype = type; /* mark the connection as RECV paused */ /* mark the connection as RECV paused */ k->keepon |= KEEP_READ_PAUSE; k->keepon |= KEEP_RECV_PAUSE; DEBUGF(infof(data, "Pausing with %d bytes in buffer for type %02x\n", DEBUGF(infof(data, "Pausing with %d bytes in buffer for type %02x\n", (int)len, type)); (int)len, type)); Loading Loading @@ -373,7 +373,7 @@ CURLcode Curl_client_write(struct connectdata *conn, /* If reading is actually paused, we're forced to append this chunk of data /* If reading is actually paused, we're forced to append this chunk of data to the already held data, but only if it is the same type as otherwise it to the already held data, but only if it is the same type as otherwise it can't work and it'll return error instead. */ can't work and it'll return error instead. */ if(data->req.keepon & KEEP_READ_PAUSE) { if(data->req.keepon & KEEP_RECV_PAUSE) { size_t newlen; size_t newlen; char *newptr; char *newptr; if(type != data->state.tempwritetype) if(type != data->state.tempwritetype) Loading
lib/ssh.c +4 −4 Original line number Original line Diff line number Diff line Loading @@ -2102,10 +2102,10 @@ static int ssh_perform_getsock(const struct connectdata *conn, sock[0] = conn->sock[FIRSTSOCKET]; sock[0] = conn->sock[FIRSTSOCKET]; if(conn->proto.sshc.waitfor & KEEP_READ) if(conn->proto.sshc.waitfor & KEEP_RECV) bitmap |= GETSOCK_READSOCK(FIRSTSOCKET); bitmap |= GETSOCK_READSOCK(FIRSTSOCKET); if(conn->proto.sshc.waitfor & KEEP_WRITE) if(conn->proto.sshc.waitfor & KEEP_SEND) bitmap |= GETSOCK_WRITESOCK(FIRSTSOCKET); bitmap |= GETSOCK_WRITESOCK(FIRSTSOCKET); return bitmap; return bitmap; Loading Loading @@ -2151,8 +2151,8 @@ static void ssh_block2waitfor(struct connectdata *conn, bool block) int dir; int dir; if(block && (dir = libssh2_session_block_directions(sshc->ssh_session))) { if(block && (dir = libssh2_session_block_directions(sshc->ssh_session))) { /* translate the libssh2 define bits into our own bit defines */ /* translate the libssh2 define bits into our own bit defines */ sshc->waitfor = ((dir&LIBSSH2_SESSION_BLOCK_INBOUND)?KEEP_READ:0) | sshc->waitfor = ((dir&LIBSSH2_SESSION_BLOCK_INBOUND)?KEEP_RECV:0) | ((dir&LIBSSH2_SESSION_BLOCK_OUTBOUND)?KEEP_WRITE:0); ((dir&LIBSSH2_SESSION_BLOCK_OUTBOUND)?KEEP_SEND:0); } } else else /* It didn't block or libssh2 didn't reveal in which direction, put back /* It didn't block or libssh2 didn't reveal in which direction, put back Loading
lib/transfer.c +43 −43 Original line number Original line Diff line number Diff line Loading @@ -157,7 +157,7 @@ CURLcode Curl_fillreadbuffer(struct connectdata *conn, int bytes, int *nreadp) else if(nread == CURL_READFUNC_PAUSE) { else if(nread == CURL_READFUNC_PAUSE) { 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_WRITE_PAUSE; /* mark socket send as paused */ k->keepon |= KEEP_SEND_PAUSE; /* mark socket send as paused */ if(data->req.upload_chunky) { if(data->req.upload_chunky) { /* Back out the preallocation done above */ /* Back out the preallocation done above */ data->req.upload_fromhere -= (8 + 2); data->req.upload_fromhere -= (8 + 2); Loading Loading @@ -320,7 +320,7 @@ CURLcode Curl_readrewind(struct connectdata *conn) about to restart a new transfer and thus we want to avoid inadvertently about to restart a new transfer and thus we want to avoid inadvertently sending more data on the existing connection until the next transfer sending more data on the existing connection until the next transfer starts */ starts */ data->req.keepon &= ~KEEP_WRITE; data->req.keepon &= ~KEEP_SEND; /* We have sent away data. If not using CURLOPT_POSTFIELDS or /* We have sent away data. If not using CURLOPT_POSTFIELDS or CURLOPT_HTTPPOST, call app to rewind CURLOPT_HTTPPOST, call app to rewind Loading Loading @@ -465,7 +465,7 @@ static CURLcode readwrite_data(struct SessionHandle *data, k->start100 = Curl_tvnow(); k->start100 = Curl_tvnow(); } } *didwhat |= KEEP_READ; *didwhat |= KEEP_RECV; /* indicates data of zero size, i.e. empty file */ /* indicates data of zero size, i.e. empty file */ is_empty_data = (bool)((nread == 0) && (k->bodywrites == 0)); is_empty_data = (bool)((nread == 0) && (k->bodywrites == 0)); Loading @@ -477,7 +477,7 @@ static CURLcode readwrite_data(struct SessionHandle *data, /* if we receive 0 or less here, the server closed the connection /* if we receive 0 or less here, the server closed the connection and we bail out from this! */ and we bail out from this! */ DEBUGF(infof(data, "nread <= 0, server closed connection, bailing\n")); DEBUGF(infof(data, "nread <= 0, server closed connection, bailing\n")); k->keepon &= ~KEEP_READ; k->keepon &= ~KEEP_RECV; break; break; } } Loading Loading @@ -517,7 +517,7 @@ static CURLcode readwrite_data(struct SessionHandle *data, if(conn->bits.close) { if(conn->bits.close) { /* Abort after the headers if "follow Location" is set /* Abort after the headers if "follow Location" is set and we're set to close anyway. */ and we're set to close anyway. */ k->keepon &= ~KEEP_READ; k->keepon &= ~KEEP_RECV; *done = TRUE; *done = TRUE; return CURLE_OK; return CURLE_OK; } } Loading Loading @@ -610,7 +610,7 @@ static CURLcode readwrite_data(struct SessionHandle *data, else if(CHUNKE_STOP == res) { else if(CHUNKE_STOP == res) { size_t dataleft; size_t dataleft; /* we're done reading chunks! */ /* we're done reading chunks! */ k->keepon &= ~KEEP_READ; /* read no more */ k->keepon &= ~KEEP_RECV; /* read no more */ /* There are now possibly N number of bytes at the end of the /* There are now possibly N number of bytes at the end of the str buffer that weren't written to the client. str buffer that weren't written to the client. Loading Loading @@ -649,7 +649,7 @@ static CURLcode readwrite_data(struct SessionHandle *data, if(nread < 0 ) /* this should be unusual */ if(nread < 0 ) /* this should be unusual */ nread = 0; nread = 0; k->keepon &= ~KEEP_READ; /* we're done reading */ k->keepon &= ~KEEP_RECV; /* we're done reading */ } } k->bytecount += nread; k->bytecount += nread; Loading Loading @@ -721,18 +721,18 @@ static CURLcode readwrite_data(struct SessionHandle *data, if(is_empty_data) { if(is_empty_data) { /* if we received nothing, the server closed the connection and we /* if we received nothing, the server closed the connection and we are done */ are done */ k->keepon &= ~KEEP_READ; k->keepon &= ~KEEP_RECV; } } } while(data_pending(conn)); } while(data_pending(conn)); if(((k->keepon & (KEEP_READ|KEEP_WRITE)) == KEEP_WRITE) && if(((k->keepon & (KEEP_RECV|KEEP_SEND)) == KEEP_SEND) && conn->bits.close ) { conn->bits.close ) { /* When we've read the entire thing and the close bit is set, the server /* When we've read the entire thing and the close bit is set, the server may now close the connection. If there's now any kind of sending going may now close the connection. If there's now any kind of sending going on from our side, we need to stop that immediately. */ on from our side, we need to stop that immediately. */ infof(data, "we are done reading and this is set to close, stop send\n"); infof(data, "we are done reading and this is set to close, stop send\n"); k->keepon &= ~KEEP_WRITE; /* no writing anymore either */ k->keepon &= ~KEEP_SEND; /* no writing anymore either */ } } return CURLE_OK; return CURLE_OK; Loading Loading @@ -895,7 +895,7 @@ static CURLcode readwrite_http_headers(struct SessionHandle *data, /* if we did wait for this do enable write now! */ /* if we did wait for this do enable write now! */ if(k->exp100) { if(k->exp100) { k->exp100 = EXP100_SEND_DATA; k->exp100 = EXP100_SEND_DATA; k->keepon |= KEEP_WRITE; k->keepon |= KEEP_SEND; } } } } else { else { Loading @@ -922,7 +922,7 @@ static CURLcode readwrite_http_headers(struct SessionHandle *data, * (or prevent them from starting). * (or prevent them from starting). */ */ k->exp100 = EXP100_FAILED; k->exp100 = EXP100_FAILED; k->keepon &= ~KEEP_WRITE; k->keepon &= ~KEEP_SEND; } } /* /* Loading Loading @@ -975,7 +975,7 @@ static CURLcode readwrite_http_headers(struct SessionHandle *data, /* We rewind after a complete send, so thus we continue /* We rewind after a complete send, so thus we continue sending now */ sending now */ infof(data, "Keep sending data to get tossed away!\n"); infof(data, "Keep sending data to get tossed away!\n"); k->keepon |= KEEP_WRITE; k->keepon |= KEEP_SEND; } } } } Loading Loading @@ -1021,7 +1021,7 @@ static CURLcode readwrite_http_headers(struct SessionHandle *data, if(*stop_reading) { if(*stop_reading) { /* we make sure that this socket isn't read more now */ /* we make sure that this socket isn't read more now */ k->keepon &= ~KEEP_READ; k->keepon &= ~KEEP_RECV; } } if(data->set.verbose) if(data->set.verbose) Loading Loading @@ -1463,7 +1463,7 @@ static CURLcode readwrite_upload(struct SessionHandle *data, if((k->bytecount == 0) && (k->writebytecount == 0)) if((k->bytecount == 0) && (k->writebytecount == 0)) Curl_pgrsTime(data, TIMER_STARTTRANSFER); Curl_pgrsTime(data, TIMER_STARTTRANSFER); *didwhat |= KEEP_WRITE; *didwhat |= KEEP_SEND; /* /* * We loop here to do the READ and SEND loop until we run out of * We loop here to do the READ and SEND loop until we run out of Loading @@ -1488,9 +1488,9 @@ static CURLcode readwrite_upload(struct SessionHandle *data, We have sent off the full HTTP 1.1 request, and we shall now We have sent off the full HTTP 1.1 request, and we shall now go into the Expect: 100 state and await such a header */ go into the Expect: 100 state and await such a header */ k->exp100 = EXP100_AWAITING_CONTINUE; /* wait for the header */ k->exp100 = EXP100_AWAITING_CONTINUE; /* wait for the header */ k->keepon &= ~KEEP_WRITE; /* disable writing */ k->keepon &= ~KEEP_SEND; /* disable writing */ k->start100 = Curl_tvnow(); /* timeout count starts now */ k->start100 = Curl_tvnow(); /* timeout count starts now */ *didwhat &= ~KEEP_WRITE; /* we didn't write anything actually */ *didwhat &= ~KEEP_SEND; /* we didn't write anything actually */ break; break; } } Loading @@ -1512,13 +1512,13 @@ static CURLcode readwrite_upload(struct SessionHandle *data, else else nread = 0; /* we're done uploading/reading */ nread = 0; /* we're done uploading/reading */ if(!nread && (k->keepon & KEEP_WRITE_PAUSE)) { if(!nread && (k->keepon & KEEP_SEND_PAUSE)) { /* this is a paused transfer */ /* this is a paused transfer */ break; break; } } else if(nread<=0) { else if(nread<=0) { /* done */ /* done */ k->keepon &= ~KEEP_WRITE; /* we're done writing */ k->keepon &= ~KEEP_SEND; /* we're done writing */ if(conn->bits.rewindaftersend) { if(conn->bits.rewindaftersend) { result = Curl_readrewind(conn); result = Curl_readrewind(conn); Loading Loading @@ -1614,7 +1614,7 @@ static CURLcode readwrite_upload(struct SessionHandle *data, if(k->upload_done) { if(k->upload_done) { /* switch off writing, we're done! */ /* switch off writing, we're done! */ k->keepon &= ~KEEP_WRITE; /* we're done writing */ k->keepon &= ~KEEP_SEND; /* we're done writing */ } } } } Loading Loading @@ -1647,7 +1647,7 @@ CURLcode Curl_readwrite(struct connectdata *conn, /* only use the proper socket if the *_HOLD bit is not set simultaneously as /* only use the proper socket if the *_HOLD bit is not set simultaneously as then we are in rate limiting state in that transfer direction */ then we are in rate limiting state in that transfer direction */ if((k->keepon & KEEP_READBITS) == KEEP_READ) { if((k->keepon & KEEP_RECVBITS) == KEEP_RECV) { fd_read = conn->sockfd; fd_read = conn->sockfd; #if defined(USE_LIBSSH2) #if defined(USE_LIBSSH2) if(conn->protocol & (PROT_SCP|PROT_SFTP)) if(conn->protocol & (PROT_SCP|PROT_SFTP)) Loading @@ -1656,7 +1656,7 @@ CURLcode Curl_readwrite(struct connectdata *conn, } else } else fd_read = CURL_SOCKET_BAD; fd_read = CURL_SOCKET_BAD; if((k->keepon & KEEP_WRITEBITS) == KEEP_WRITE) if((k->keepon & KEEP_SENDBITS) == KEEP_SEND) fd_write = conn->writesockfd; fd_write = conn->writesockfd; else else fd_write = CURL_SOCKET_BAD; fd_write = CURL_SOCKET_BAD; Loading @@ -1674,7 +1674,7 @@ CURLcode Curl_readwrite(struct connectdata *conn, /* We go ahead and do a read if we have a readable socket or if /* We go ahead and do a read if we have a readable socket or if the stream was rewound (in which case we have data in a the stream was rewound (in which case we have data in a buffer) */ buffer) */ if((k->keepon & KEEP_READ) && if((k->keepon & KEEP_RECV) && ((select_res & CURL_CSELECT_IN) || conn->bits.stream_was_rewound)) { ((select_res & CURL_CSELECT_IN) || conn->bits.stream_was_rewound)) { result = readwrite_data(data, conn, k, &didwhat, done); result = readwrite_data(data, conn, k, &didwhat, done); Loading @@ -1683,7 +1683,7 @@ CURLcode Curl_readwrite(struct connectdata *conn, } } /* If we still have writing to do, we check if we have a writable socket. */ /* If we still have writing to do, we check if we have a writable socket. */ if((k->keepon & KEEP_WRITE) && (select_res & CURL_CSELECT_OUT)) { if((k->keepon & KEEP_SEND) && (select_res & CURL_CSELECT_OUT)) { /* write */ /* write */ result = readwrite_upload(data, conn, k, &didwhat); result = readwrite_upload(data, conn, k, &didwhat); Loading Loading @@ -1719,7 +1719,7 @@ CURLcode Curl_readwrite(struct connectdata *conn, if(ms > CURL_TIMEOUT_EXPECT_100) { if(ms > CURL_TIMEOUT_EXPECT_100) { /* we've waited long enough, continue anyway */ /* we've waited long enough, continue anyway */ k->exp100 = EXP100_SEND_DATA; k->exp100 = EXP100_SEND_DATA; k->keepon |= KEEP_WRITE; k->keepon |= KEEP_SEND; infof(data, "Done waiting for 100-continue\n"); infof(data, "Done waiting for 100-continue\n"); } } } } Loading Loading @@ -1787,8 +1787,8 @@ CURLcode Curl_readwrite(struct connectdata *conn, } } /* Now update the "done" boolean we return */ /* Now update the "done" boolean we return */ *done = (bool)(0 == (k->keepon&(KEEP_READ|KEEP_WRITE| *done = (bool)(0 == (k->keepon&(KEEP_RECV|KEEP_SEND| KEEP_READ_PAUSE|KEEP_WRITE_PAUSE))); KEEP_RECV_PAUSE|KEEP_SEND_PAUSE))); return CURLE_OK; return CURLE_OK; } } Loading Loading @@ -1817,7 +1817,7 @@ int Curl_single_getsock(const struct connectdata *conn, return GETSOCK_BLANK; return GETSOCK_BLANK; /* don't include HOLD and PAUSE connections */ /* don't include HOLD and PAUSE connections */ if((data->req.keepon & KEEP_READBITS) == KEEP_READ) { if((data->req.keepon & KEEP_RECVBITS) == KEEP_RECV) { DEBUGASSERT(conn->sockfd != CURL_SOCKET_BAD); DEBUGASSERT(conn->sockfd != CURL_SOCKET_BAD); Loading @@ -1826,13 +1826,13 @@ int Curl_single_getsock(const struct connectdata *conn, } } /* don't include HOLD and PAUSE connections */ /* don't include HOLD and PAUSE connections */ if((data->req.keepon & KEEP_WRITEBITS) == KEEP_WRITE) { if((data->req.keepon & KEEP_SENDBITS) == KEEP_SEND) { if((conn->sockfd != conn->writesockfd) || if((conn->sockfd != conn->writesockfd) || !(data->req.keepon & KEEP_READ)) { !(data->req.keepon & KEEP_RECV)) { /* only if they are not the same socket or we didn't have a readable /* only if they are not the same socket or we didn't have a readable one, we increase index */ one, we increase index */ if(data->req.keepon & KEEP_READ) if(data->req.keepon & KEEP_RECV) sockindex++; /* increase index if we need two entries */ sockindex++; /* increase index if we need two entries */ DEBUGASSERT(conn->writesockfd != CURL_SOCKET_BAD); DEBUGASSERT(conn->writesockfd != CURL_SOCKET_BAD); Loading Loading @@ -1887,34 +1887,34 @@ Transfer(struct connectdata *conn) /* limit-rate logic: if speed exceeds threshold, then do not include fd in /* limit-rate logic: if speed exceeds threshold, then do not include fd in select set. The current speed is recalculated in each Curl_readwrite() select set. The current speed is recalculated in each Curl_readwrite() call */ call */ if((k->keepon & KEEP_WRITE) && if((k->keepon & KEEP_SEND) && (!data->set.max_send_speed || (!data->set.max_send_speed || (data->progress.ulspeed < data->set.max_send_speed) )) { (data->progress.ulspeed < data->set.max_send_speed) )) { fd_write = conn->writesockfd; fd_write = conn->writesockfd; k->keepon &= ~KEEP_WRITE_HOLD; k->keepon &= ~KEEP_SEND_HOLD; } } else { else { fd_write = CURL_SOCKET_BAD; fd_write = CURL_SOCKET_BAD; if(k->keepon & KEEP_WRITE) if(k->keepon & KEEP_SEND) k->keepon |= KEEP_WRITE_HOLD; /* hold it */ k->keepon |= KEEP_SEND_HOLD; /* hold it */ } } if((k->keepon & KEEP_READ) && if((k->keepon & KEEP_RECV) && (!data->set.max_recv_speed || (!data->set.max_recv_speed || (data->progress.dlspeed < data->set.max_recv_speed)) ) { (data->progress.dlspeed < data->set.max_recv_speed)) ) { fd_read = conn->sockfd; fd_read = conn->sockfd; k->keepon &= ~KEEP_READ_HOLD; k->keepon &= ~KEEP_RECV_HOLD; } } else { else { fd_read = CURL_SOCKET_BAD; fd_read = CURL_SOCKET_BAD; if(k->keepon & KEEP_READ) if(k->keepon & KEEP_RECV) k->keepon |= KEEP_READ_HOLD; /* hold it */ k->keepon |= KEEP_RECV_HOLD; /* hold it */ } } /* pause logic. Don't check descriptors for paused connections */ /* pause logic. Don't check descriptors for paused connections */ if(k->keepon & KEEP_READ_PAUSE) if(k->keepon & KEEP_RECV_PAUSE) fd_read = CURL_SOCKET_BAD; fd_read = CURL_SOCKET_BAD; if(k->keepon & KEEP_WRITE_PAUSE) if(k->keepon & KEEP_SEND_PAUSE) fd_write = CURL_SOCKET_BAD; fd_write = CURL_SOCKET_BAD; /* The *_HOLD and *_PAUSE logic is necessary since even though there might /* The *_HOLD and *_PAUSE logic is necessary since even though there might Loading Loading @@ -2730,7 +2730,7 @@ Curl_setup_transfer( if(k->getheader || !data->set.opt_no_body) { if(k->getheader || !data->set.opt_no_body) { if(conn->sockfd != CURL_SOCKET_BAD) { if(conn->sockfd != CURL_SOCKET_BAD) { k->keepon |= KEEP_READ; k->keepon |= KEEP_RECV; } } if(conn->writesockfd != CURL_SOCKET_BAD) { if(conn->writesockfd != CURL_SOCKET_BAD) { Loading @@ -2756,7 +2756,7 @@ Curl_setup_transfer( k->exp100 = EXP100_SENDING_REQUEST; k->exp100 = EXP100_SENDING_REQUEST; /* enable the write bit when we're not waiting for continue */ /* enable the write bit when we're not waiting for continue */ k->keepon |= KEEP_WRITE; k->keepon |= KEEP_SEND; } } } /* if(conn->writesockfd != CURL_SOCKET_BAD) */ } /* if(conn->writesockfd != CURL_SOCKET_BAD) */ } /* if(k->getheader || !data->set.opt_no_body) */ } /* if(k->getheader || !data->set.opt_no_body) */ Loading