aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2011-06-04 21:19:14 +0200
committerDaniel Stenberg <daniel@haxx.se>2011-06-04 21:19:14 +0200
commit4f170ee8f9c1d067022300df2da331c30dcda9dd (patch)
tree5734ca49661f8085638ab8255ac60448b2f61cb9
parentfba00c9f7be2dad06b8691952508882c4da14185 (diff)
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.
-rw-r--r--lib/connect.c4
-rw-r--r--lib/cyassl.c3
-rw-r--r--lib/ftp.c4
-rw-r--r--lib/gtls.c4
-rw-r--r--lib/http_proxy.c2
-rw-r--r--lib/pingpong.c2
-rw-r--r--lib/polarssl.c2
-rw-r--r--lib/select.c2
-rw-r--r--lib/select.h4
-rw-r--r--lib/socks.c6
-rw-r--r--lib/ssh.c2
-rw-r--r--lib/ssluse.c5
-rw-r--r--lib/tftp.c2
-rw-r--r--lib/transfer.c12
14 files changed, 26 insertions, 28 deletions
diff --git a/lib/connect.c b/lib/connect.c
index 369ba053e..6d657eb5e 100644
--- a/lib/connect.c
+++ b/lib/connect.c
@@ -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;
diff --git a/lib/cyassl.c b/lib/cyassl.c
index 8fdbc33b1..81bcabaa1 100644
--- a/lib/cyassl.c
+++ b/lib/cyassl.c
@@ -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);
diff --git a/lib/ftp.c b/lib/ftp.c
index e9cca1b15..d758301f5 100644
--- a/lib/ftp.c
+++ b/lib/ftp.c
@@ -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);
diff --git a/lib/gtls.c b/lib/gtls.c
index bb2ee1068..a376fb0b9 100644
--- a/lib/gtls.c
+++ b/lib/gtls.c
@@ -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 */
diff --git a/lib/http_proxy.c b/lib/http_proxy.c
index 08ca1006f..9fa832e4d 100644
--- a/lib/http_proxy.c
+++ b/lib/http_proxy.c
@@ -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");
diff --git a/lib/pingpong.c b/lib/pingpong.c
index 8f0266760..23ab69fb2 100644
--- a/lib/pingpong.c
+++ b/lib/pingpong.c
@@ -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;
diff --git a/lib/polarssl.c b/lib/polarssl.c
index 370b8c64c..2e70a28d5 100644
--- a/lib/polarssl.c
+++ b/lib/polarssl.c
@@ -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;
diff --git a/lib/select.c b/lib/select.c
index 86af1dda9..350539384 100644
--- a/lib/select.c
+++ b/lib/select.c
@@ -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];
diff --git a/lib/select.h b/lib/select.h
index e431e5f07..e012c63f3 100644
--- a/lib/select.h
+++ b/lib/select.h
@@ -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);
diff --git a/lib/socks.c b/lib/socks.c
index bbd2b447e..82293019b 100644
--- a/lib/socks.c
+++ b/lib/socks.c
@@ -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");
diff --git a/lib/ssh.c b/lib/ssh.c
index bc05de69d..1c14b34d5 100644
--- a/lib/ssh.c
+++ b/lib/ssh.c
@@ -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
diff --git a/lib/ssluse.c b/lib/ssluse.c
index 67fd99a38..5bdc536a3 100644
--- a/lib/ssluse.c
+++ b/lib/ssluse.c
@@ -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);
diff --git a/lib/tftp.c b/lib/tftp.c
index 661238987..46b3ecfcb 100644
--- a/lib/tftp.c
+++ b/lib/tftp.c
@@ -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();
diff --git a/lib/transfer.c b/lib/transfer.c
index 59d4792fd..c82fb3594 100644
--- a/lib/transfer.c
+++ b/lib/transfer.c
@@ -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;
}