mirror of
https://github.com/moparisthebest/curl
synced 2024-12-21 23:58:49 -05:00
Curl_socket_ready: make timeout a 'long'
It was mostly typecasted to int all over the code so switching to long instead all over should be a net gain.
This commit is contained in:
parent
fba00c9f7b
commit
4f170ee8f9
@ -211,8 +211,8 @@ int waitconnect(struct connectdata *conn,
|
||||
for(;;) {
|
||||
|
||||
/* now select() until we get connect or timeout */
|
||||
rc = Curl_socket_ready(CURL_SOCKET_BAD, sockfd, (int)(timeout_msec>1000?
|
||||
1000:timeout_msec));
|
||||
rc = Curl_socket_ready(CURL_SOCKET_BAD, sockfd, timeout_msec>1000?
|
||||
1000:timeout_msec);
|
||||
if(Curl_pgrsUpdate(conn))
|
||||
return WAITCONN_ABORTED;
|
||||
|
||||
|
@ -490,8 +490,7 @@ cyassl_connect_common(struct connectdata *conn,
|
||||
curl_socket_t readfd = ssl_connect_2_reading==
|
||||
connssl->connecting_state?sockfd:CURL_SOCKET_BAD;
|
||||
|
||||
what = Curl_socket_ready(readfd, writefd,
|
||||
nonblocking?0:(int)timeout_ms);
|
||||
what = Curl_socket_ready(readfd, writefd, nonblocking?0:timeout_ms);
|
||||
if(what < 0) {
|
||||
/* fatal error */
|
||||
failf(data, "select/poll on SSL socket, errno: %d", SOCKERRNO);
|
||||
|
@ -343,7 +343,7 @@ static CURLcode AllowServerConnect(struct connectdata *conn)
|
||||
if(timeout_ms < interval_ms)
|
||||
interval_ms = timeout_ms;
|
||||
|
||||
switch (Curl_socket_ready(sock, CURL_SOCKET_BAD, (int)interval_ms)) {
|
||||
switch (Curl_socket_ready(sock, CURL_SOCKET_BAD, interval_ms)) {
|
||||
case -1: /* error */
|
||||
/* let's die here */
|
||||
failf(data, "Error while waiting for server connect");
|
||||
@ -517,7 +517,7 @@ CURLcode Curl_GetFTPResponse(ssize_t *nreadp, /* return number of bytes read */
|
||||
*/
|
||||
}
|
||||
else {
|
||||
switch (Curl_socket_ready(sockfd, CURL_SOCKET_BAD, (int)interval_ms)) {
|
||||
switch (Curl_socket_ready(sockfd, CURL_SOCKET_BAD, interval_ms)) {
|
||||
case -1: /* select() error, stop reading */
|
||||
failf(data, "FTP response aborted due to select/poll error: %d",
|
||||
SOCKERRNO);
|
||||
|
@ -256,7 +256,7 @@ static CURLcode handshake(struct connectdata *conn,
|
||||
|
||||
what = Curl_socket_ready(readfd, writefd,
|
||||
nonblocking?0:
|
||||
((int)timeout_ms?timeout_ms:1000));
|
||||
timeout_ms?timeout_ms:1000);
|
||||
if(what < 0) {
|
||||
/* fatal error */
|
||||
failf(data, "select/poll on SSL socket, errno: %d", SOCKERRNO);
|
||||
@ -907,7 +907,7 @@ int Curl_gtls_shutdown(struct connectdata *conn, int sockindex)
|
||||
if(conn->ssl[sockindex].session) {
|
||||
while(!done) {
|
||||
int what = Curl_socket_ready(conn->sock[sockindex],
|
||||
CURL_SOCKET_BAD, SSL_SHUTDOWN_TIMEOUT);
|
||||
CURL_SOCKET_BAD, SSL_SHUTDOWN_TIMEOUT);
|
||||
if(what > 0) {
|
||||
/* Something to read, let's do it and hope that it is the close
|
||||
notify alert from the server */
|
||||
|
@ -244,7 +244,7 @@ CURLcode Curl_proxyCONNECT(struct connectdata *conn,
|
||||
|
||||
/* loop every second at least, less if the timeout is near */
|
||||
switch (Curl_socket_ready(tunnelsocket, CURL_SOCKET_BAD,
|
||||
check<1000L?(int)check:1000)) {
|
||||
check<1000L?check:1000)) {
|
||||
case -1: /* select() error, stop reading */
|
||||
error = SELECT_ERROR;
|
||||
failf(data, "Proxy CONNECT aborted due to select/poll error");
|
||||
|
@ -138,7 +138,7 @@ CURLcode Curl_pp_easy_statemach(struct pingpong *pp)
|
||||
|
||||
rc = Curl_socket_ready(pp->sendleft?CURL_SOCKET_BAD:sock, /* reading */
|
||||
pp->sendleft?sock:CURL_SOCKET_BAD, /* writing */
|
||||
(int)interval_ms);
|
||||
interval_ms);
|
||||
|
||||
if(Curl_pgrsUpdate(conn))
|
||||
result = CURLE_ABORTED_BY_CALLBACK;
|
||||
|
@ -238,7 +238,7 @@ Curl_polarssl_connect(struct connectdata *conn,
|
||||
}
|
||||
|
||||
switch(Curl_socket_ready(conn->sock[sockindex],
|
||||
CURL_SOCKET_BAD, timeout_ms)) {
|
||||
CURL_SOCKET_BAD, timeout_ms)) {
|
||||
case 0:
|
||||
failf(data, "SSL handshake timeout");
|
||||
return CURLE_OPERATION_TIMEDOUT;
|
||||
|
@ -160,7 +160,7 @@ static int wait_ms(int timeout_ms)
|
||||
* CURL_CSELECT_IN | CURL_CSELECT_OUT | CURL_CSELECT_ERR
|
||||
*/
|
||||
int Curl_socket_ready(curl_socket_t readfd, curl_socket_t writefd,
|
||||
int timeout_ms)
|
||||
long timeout_ms)
|
||||
{
|
||||
#ifdef HAVE_POLL_FINE
|
||||
struct pollfd pfd[2];
|
||||
|
@ -7,7 +7,7 @@
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2008, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
@ -85,7 +85,7 @@ struct pollfd
|
||||
#endif
|
||||
|
||||
int Curl_socket_ready(curl_socket_t readfd, curl_socket_t writefd,
|
||||
int timeout_ms);
|
||||
long timeout_ms);
|
||||
|
||||
int Curl_poll(struct pollfd ufds[], unsigned int nfds, int timeout_ms);
|
||||
|
||||
|
@ -81,7 +81,7 @@ int Curl_blockread_all(struct connectdata *conn, /* connection data */
|
||||
break;
|
||||
}
|
||||
if(Curl_socket_ready(sockfd, CURL_SOCKET_BAD,
|
||||
(int)(conn_timeout - conntime)) <= 0) {
|
||||
conn_timeout - conntime) <= 0) {
|
||||
result = ~CURLE_OK;
|
||||
break;
|
||||
}
|
||||
@ -409,7 +409,7 @@ CURLcode Curl_SOCKS5(const char *proxy_name,
|
||||
curlx_nonblock(sock, TRUE);
|
||||
|
||||
/* wait until socket gets connected */
|
||||
result = Curl_socket_ready(CURL_SOCKET_BAD, sock, (int)timeout);
|
||||
result = Curl_socket_ready(CURL_SOCKET_BAD, sock, timeout);
|
||||
|
||||
if(-1 == result) {
|
||||
failf(conn->data, "SOCKS5: no connection here");
|
||||
@ -448,7 +448,7 @@ CURLcode Curl_SOCKS5(const char *proxy_name,
|
||||
|
||||
curlx_nonblock(sock, TRUE);
|
||||
|
||||
result = Curl_socket_ready(sock, CURL_SOCKET_BAD, (int)timeout);
|
||||
result = Curl_socket_ready(sock, CURL_SOCKET_BAD, timeout);
|
||||
|
||||
if(-1 == result) {
|
||||
failf(conn->data, "SOCKS5 nothing to read");
|
||||
|
@ -2548,7 +2548,7 @@ static CURLcode ssh_easy_statemach(struct connectdata *conn,
|
||||
fd_write = sock;
|
||||
/* wait for the socket to become ready */
|
||||
Curl_socket_ready(fd_read, fd_write,
|
||||
(int)(left>1000?1000:left)); /* ignore result */
|
||||
left>1000?1000:left); /* ignore result */
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -881,7 +881,7 @@ int Curl_ossl_shutdown(struct connectdata *conn, int sockindex)
|
||||
buffsize = (int)sizeof(buf);
|
||||
while(!done) {
|
||||
int what = Curl_socket_ready(conn->sock[sockindex],
|
||||
CURL_SOCKET_BAD, SSL_SHUTDOWN_TIMEOUT);
|
||||
CURL_SOCKET_BAD, SSL_SHUTDOWN_TIMEOUT);
|
||||
if(what > 0) {
|
||||
ERR_clear_error();
|
||||
|
||||
@ -2477,8 +2477,7 @@ ossl_connect_common(struct connectdata *conn,
|
||||
curl_socket_t readfd = ssl_connect_2_reading==
|
||||
connssl->connecting_state?sockfd:CURL_SOCKET_BAD;
|
||||
|
||||
what = Curl_socket_ready(readfd, writefd,
|
||||
nonblocking?0:(int)timeout_ms);
|
||||
what = Curl_socket_ready(readfd, writefd, nonblocking?0:timeout_ms);
|
||||
if(what < 0) {
|
||||
/* fatal error */
|
||||
failf(data, "select/poll on SSL socket, errno: %d", SOCKERRNO);
|
||||
|
@ -1255,7 +1255,7 @@ static CURLcode tftp_easy_statemach(struct connectdata *conn)
|
||||
|
||||
|
||||
/* Wait until ready to read or timeout occurs */
|
||||
rc = Curl_socket_ready(fd_read, CURL_SOCKET_BAD, (int)(timeout_ms));
|
||||
rc = Curl_socket_ready(fd_read, CURL_SOCKET_BAD, timeout_ms);
|
||||
|
||||
k->now = Curl_tvnow();
|
||||
|
||||
|
@ -1282,9 +1282,9 @@ Transfer(struct connectdata *conn)
|
||||
struct SingleRequest *k = &data->req;
|
||||
bool done=FALSE;
|
||||
bool first=TRUE;
|
||||
int timeout_ms;
|
||||
long timeout_ms;
|
||||
int buffersize;
|
||||
int totmp;
|
||||
long totmp;
|
||||
|
||||
if((conn->sockfd == CURL_SOCKET_BAD) &&
|
||||
(conn->writesockfd == CURL_SOCKET_BAD))
|
||||
@ -1322,8 +1322,8 @@ Transfer(struct connectdata *conn)
|
||||
/* calculate upload rate-limitation timeout. */
|
||||
buffersize = (int)(data->set.buffer_size ?
|
||||
data->set.buffer_size : BUFSIZE);
|
||||
totmp = (int)Curl_sleep_time(data->set.max_send_speed,
|
||||
data->progress.ulspeed, buffersize);
|
||||
totmp = Curl_sleep_time(data->set.max_send_speed,
|
||||
data->progress.ulspeed, buffersize);
|
||||
if(totmp < timeout_ms)
|
||||
timeout_ms = totmp;
|
||||
}
|
||||
@ -1343,8 +1343,8 @@ Transfer(struct connectdata *conn)
|
||||
/* Calculate download rate-limitation timeout. */
|
||||
buffersize = (int)(data->set.buffer_size ?
|
||||
data->set.buffer_size : BUFSIZE);
|
||||
totmp = (int)Curl_sleep_time(data->set.max_recv_speed,
|
||||
data->progress.dlspeed, buffersize);
|
||||
totmp = Curl_sleep_time(data->set.max_recv_speed,
|
||||
data->progress.dlspeed, buffersize);
|
||||
if(totmp < timeout_ms)
|
||||
timeout_ms = totmp;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user