Internal function Curl_select() renamed to Curl_socket_ready()

This commit is contained in:
Yang Tse 2007-03-26 23:23:46 +00:00
parent 2166645ce4
commit fba4cd0e62
12 changed files with 25 additions and 22 deletions

View File

@ -6,6 +6,9 @@
Changelog Changelog
Yang Tse (20 March 2007)
- Internal function Curl_select() renamed to Curl_socket_ready()
Daniel S (25 March 2007) Daniel S (25 March 2007)
- Daniel Johnson fixed multi code to traverse the easy handle list properly. - Daniel Johnson fixed multi code to traverse the easy handle list properly.
A left-over bug from the February 21 fix. A left-over bug from the February 21 fix.

View File

@ -197,7 +197,7 @@ int waitconnect(curl_socket_t sockfd, /* socket */
#endif #endif
/* now select() until we get connect or timeout */ /* now select() until we get connect or timeout */
rc = Curl_select(CURL_SOCKET_BAD, sockfd, (int)timeout_msec); rc = Curl_socket_ready(CURL_SOCKET_BAD, sockfd, (int)timeout_msec);
if(-1 == rc) if(-1 == rc)
/* error, no connect here, try next */ /* error, no connect here, try next */
return WAITCONN_SELECT_ERROR; return WAITCONN_SELECT_ERROR;

View File

@ -204,7 +204,7 @@ static CURLcode AllowServerConnect(struct connectdata *conn)
Note the typecast here. */ Note the typecast here. */
timeout_ms = (timeout?(int)timeout:60000); timeout_ms = (timeout?(int)timeout:60000);
switch (Curl_select(sock, CURL_SOCKET_BAD, timeout_ms)) { switch (Curl_socket_ready(sock, CURL_SOCKET_BAD, timeout_ms)) {
case -1: /* error */ case -1: /* error */
/* let's die here */ /* let's die here */
failf(data, "Error while waiting for server connect"); failf(data, "Error while waiting for server connect");
@ -498,7 +498,7 @@ CURLcode Curl_GetFTPResponse(ssize_t *nreadp, /* return number of bytes read */
if(timeout < interval_ms) if(timeout < interval_ms)
interval_ms = timeout; interval_ms = timeout;
switch (Curl_select(sockfd, CURL_SOCKET_BAD, (int)interval_ms)) { switch (Curl_socket_ready(sockfd, CURL_SOCKET_BAD, (int)interval_ms)) {
case -1: /* select() error, stop reading */ case -1: /* select() error, stop reading */
result = CURLE_RECV_ERROR; result = CURLE_RECV_ERROR;
failf(data, "FTP response aborted due to select() error: %d", failf(data, "FTP response aborted due to select() error: %d",
@ -2808,7 +2808,7 @@ CURLcode Curl_ftp_multi_statemach(struct connectdata *conn,
return CURLE_OPERATION_TIMEDOUT; return CURLE_OPERATION_TIMEDOUT;
} }
rc = Curl_select(ftpc->sendleft?CURL_SOCKET_BAD:sock, /* reading */ rc = Curl_socket_ready(ftpc->sendleft?CURL_SOCKET_BAD:sock, /* reading */
ftpc->sendleft?sock:CURL_SOCKET_BAD, /* writing */ ftpc->sendleft?sock:CURL_SOCKET_BAD, /* writing */
0); 0);
@ -2841,7 +2841,7 @@ static CURLcode ftp_easy_statemach(struct connectdata *conn)
return CURLE_OPERATION_TIMEDOUT; /* already too little time */ return CURLE_OPERATION_TIMEDOUT; /* already too little time */
} }
rc = Curl_select(ftpc->sendleft?CURL_SOCKET_BAD:sock, /* reading */ rc = Curl_socket_ready(ftpc->sendleft?CURL_SOCKET_BAD:sock, /* reading */
ftpc->sendleft?sock:CURL_SOCKET_BAD, /* writing */ ftpc->sendleft?sock:CURL_SOCKET_BAD, /* writing */
(int)timeout_ms); (int)timeout_ms);

View File

@ -161,7 +161,7 @@ static CURLcode handshake(struct connectdata *conn,
return CURLE_OPERATION_TIMEOUTED; return CURLE_OPERATION_TIMEOUTED;
} }
rc = Curl_select(conn->sock[sockindex], rc = Curl_socket_ready(conn->sock[sockindex],
conn->sock[sockindex], (int)timeout_ms); conn->sock[sockindex], (int)timeout_ms);
if(rc > 0) if(rc > 0)
/* reabable or writable, go loop*/ /* reabable or writable, go loop*/
@ -535,7 +535,7 @@ int Curl_gtls_shutdown(struct connectdata *conn, int sockindex)
if(conn->ssl[sockindex].session) { if(conn->ssl[sockindex].session) {
while(!done) { while(!done) {
int what = Curl_select(conn->sock[sockindex], int what = Curl_socket_ready(conn->sock[sockindex],
CURL_SOCKET_BAD, SSL_SHUTDOWN_TIMEOUT); CURL_SOCKET_BAD, SSL_SHUTDOWN_TIMEOUT);
if(what > 0) { if(what > 0) {
/* Something to read, let's do it and hope that it is the close /* Something to read, let's do it and hope that it is the close

View File

@ -1225,7 +1225,7 @@ CURLcode Curl_proxyCONNECT(struct connectdata *conn,
/* if we're in multi-mode and we would block, return instead for a retry */ /* if we're in multi-mode and we would block, return instead for a retry */
if (Curl_if_multi == data->state.used_interface) { if (Curl_if_multi == data->state.used_interface) {
if (0 == Curl_select(tunnelsocket, CURL_SOCKET_BAD, 0)) if (0 == Curl_socket_ready(tunnelsocket, CURL_SOCKET_BAD, 0))
/* return so we'll be called again polling-style */ /* return so we'll be called again polling-style */
return CURLE_OK; return CURLE_OK;
else { else {
@ -1273,7 +1273,7 @@ CURLcode Curl_proxyCONNECT(struct connectdata *conn,
} }
/* loop every second at least, less if the timeout is near */ /* loop every second at least, less if the timeout is near */
switch (Curl_select(tunnelsocket, CURL_SOCKET_BAD, switch (Curl_socket_ready(tunnelsocket, CURL_SOCKET_BAD,
check<1000L?(int)check:1000)) { check<1000L?(int)check:1000)) {
case -1: /* select() error, stop reading */ case -1: /* select() error, stop reading */
error = SELECT_ERROR; error = SELECT_ERROR;

View File

@ -84,8 +84,8 @@
/* /*
* Internal function used for waiting a specific amount of ms * Internal function used for waiting a specific amount of ms
* in Curl_select() and Curl_poll() when no file descriptor is * in Curl_socket_ready() and Curl_poll() when no file descriptor
* provided to wait on, just being used to delay execution. * is provided to wait on, just being used to delay execution.
* WinSock select() and poll() timeout mechanisms need a valid * WinSock select() and poll() timeout mechanisms need a valid
* socket descriptor in a not null file descriptor set to work. * socket descriptor in a not null file descriptor set to work.
* Waiting indefinitely with this function is not allowed, a * Waiting indefinitely with this function is not allowed, a
@ -160,7 +160,7 @@ static int wait_ms(int timeout_ms)
* 0 = timeout * 0 = timeout
* CSELECT_IN | CSELECT_OUT | CSELECT_ERR * CSELECT_IN | CSELECT_OUT | CSELECT_ERR
*/ */
int Curl_select(curl_socket_t readfd, curl_socket_t writefd, int timeout_ms) int Curl_socket_ready(curl_socket_t readfd, curl_socket_t writefd, int timeout_ms)
{ {
#ifdef HAVE_POLL_FINE #ifdef HAVE_POLL_FINE
struct pollfd pfd[2]; struct pollfd pfd[2];

View File

@ -68,7 +68,7 @@ struct pollfd
#define CSELECT_OUT 0x02 #define CSELECT_OUT 0x02
#define CSELECT_ERR 0x04 #define CSELECT_ERR 0x04
int Curl_select(curl_socket_t readfd, curl_socket_t writefd, int timeout_ms); int Curl_socket_ready(curl_socket_t readfd, curl_socket_t writefd, int timeout_ms);
int Curl_poll(struct pollfd ufds[], unsigned int nfds, int timeout_ms); int Curl_poll(struct pollfd ufds[], unsigned int nfds, int timeout_ms);

View File

@ -83,7 +83,7 @@ static int blockread_all(struct connectdata *conn, /* connection data */
result = ~CURLE_OK; result = ~CURLE_OK;
break; break;
} }
if(Curl_select(sockfd, CURL_SOCKET_BAD, if(Curl_socket_ready(sockfd, CURL_SOCKET_BAD,
(int)(conn_timeout - conntime)) <= 0) { (int)(conn_timeout - conntime)) <= 0) {
result = ~CURLE_OK; result = ~CURLE_OK;
break; break;
@ -372,7 +372,7 @@ CURLcode Curl_SOCKS5(const char *proxy_name,
Curl_nonblock(sock, TRUE); Curl_nonblock(sock, TRUE);
/* wait until socket gets connected */ /* wait until socket gets connected */
result = Curl_select(CURL_SOCKET_BAD, sock, (int)timeout); result = Curl_socket_ready(CURL_SOCKET_BAD, sock, (int)timeout);
if(-1 == result) { if(-1 == result) {
failf(conn->data, "SOCKS5: no connection here"); failf(conn->data, "SOCKS5: no connection here");
@ -404,7 +404,7 @@ CURLcode Curl_SOCKS5(const char *proxy_name,
Curl_nonblock(sock, TRUE); Curl_nonblock(sock, TRUE);
result = Curl_select(sock, CURL_SOCKET_BAD, (int)timeout); result = Curl_socket_ready(sock, CURL_SOCKET_BAD, (int)timeout);
if(-1 == result) { if(-1 == result) {
failf(conn->data, "SOCKS5 nothing to read"); failf(conn->data, "SOCKS5 nothing to read");

View File

@ -751,7 +751,7 @@ int Curl_ossl_shutdown(struct connectdata *conn, int sockindex)
if(connssl->handle) { if(connssl->handle) {
while(!done) { while(!done) {
int what = Curl_select(conn->sock[sockindex], int what = Curl_socket_ready(conn->sock[sockindex],
CURL_SOCKET_BAD, SSL_SHUTDOWN_TIMEOUT); CURL_SOCKET_BAD, SSL_SHUTDOWN_TIMEOUT);
if(what > 0) { if(what > 0) {
/* Something to read, let's do it and hope that it is the close /* Something to read, let's do it and hope that it is the close
@ -1728,7 +1728,7 @@ Curl_ossl_connect_common(struct connectdata *conn,
connssl->connecting_state?sockfd:CURL_SOCKET_BAD; connssl->connecting_state?sockfd:CURL_SOCKET_BAD;
while(1) { while(1) {
int what = Curl_select(readfd, writefd, nonblocking?0:(int)timeout_ms); int what = Curl_socket_ready(readfd, writefd, nonblocking?0:(int)timeout_ms);
if(what > 0) if(what > 0)
/* readable or writable, go loop in the outer loop */ /* readable or writable, go loop in the outer loop */
break; break;

View File

@ -678,7 +678,7 @@ CURLcode Curl_tftp(struct connectdata *conn, bool *done)
tftp_state_machine(state, event) ) { tftp_state_machine(state, event) ) {
/* Wait until ready to read or timeout occurs */ /* Wait until ready to read or timeout occurs */
rc=Curl_select(state->sockfd, CURL_SOCKET_BAD, state->retry_time * 1000); rc=Curl_socket_ready(state->sockfd, CURL_SOCKET_BAD, state->retry_time * 1000);
if(rc == -1) { if(rc == -1) {
/* bail out */ /* bail out */

View File

@ -329,7 +329,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
else else
fd_write = CURL_SOCKET_BAD; fd_write = CURL_SOCKET_BAD;
select_res = Curl_select(fd_read, fd_write, 0); select_res = Curl_socket_ready(fd_read, fd_write, 0);
if(select_res == CSELECT_ERR) { if(select_res == CSELECT_ERR) {
failf(data, "select/poll returned error"); failf(data, "select/poll returned error");
return CURLE_SEND_ERROR; return CURLE_SEND_ERROR;
@ -1828,7 +1828,7 @@ Transfer(struct connectdata *conn)
the timeout case and if we limit transfer speed we must make sure that the timeout case and if we limit transfer speed we must make sure that
this function doesn't transfer anything while in HOLD status. */ this function doesn't transfer anything while in HOLD status. */
switch (Curl_select(fd_read, fd_write, 1000)) { switch (Curl_socket_ready(fd_read, fd_write, 1000)) {
case -1: /* select() error, stop reading */ case -1: /* select() error, stop reading */
#ifdef EINTR #ifdef EINTR
/* The EINTR is not serious, and it seems you might get this more /* The EINTR is not serious, and it seems you might get this more

View File

@ -1890,7 +1890,7 @@ static bool SocketIsDead(curl_socket_t sock)
int sval; int sval;
bool ret_val = TRUE; bool ret_val = TRUE;
sval = Curl_select(sock, CURL_SOCKET_BAD, 0); sval = Curl_socket_ready(sock, CURL_SOCKET_BAD, 0);
if(sval == 0) if(sval == 0)
/* timeout */ /* timeout */
ret_val = FALSE; ret_val = FALSE;