Commit d709cb2a authored by Daniel Stenberg's avatar Daniel Stenberg
Browse files

- Eric Wong introduced curlx_nonblock() that the curl tool now (re-)uses for

  setting a file descriptor non-blocking. Used by the functionality Eric
  himself brough on June 15th.
parent 444bb03f
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -6,6 +6,11 @@

                                  Changelog

Daniel Stenberg (9 Jul 2009)
- Eric Wong introduced curlx_nonblock() that the curl tool now (re-)uses for
  setting a file descriptor non-blocking. Used by the functionality Eric
  himself brough on June 15th.

Daniel Stenberg (8 Jul 2009)
- Constantine Sapuntzakis posted bug report #2813123
  (http://curl.haxx.se/bug/view.cgi?id=2813123) and an a patch that fixes the
+2 −2
Original line number Diff line number Diff line
@@ -10,7 +10,7 @@ CSOURCES = file.c timeval.c base64.c hostip.c progress.c formdata.c \
  hostares.c hostasyn.c hostip4.c hostip6.c hostsyn.c hostthre.c	\
  inet_ntop.c parsedate.c select.c gtls.c sslgen.c tftp.c splay.c	\
  strdup.c socks.c ssh.c nss.c qssl.c rawstr.c curl_addrinfo.c          \
  socks_gssapi.c socks_sspi.c curl_sspi.c slist.c
  socks_gssapi.c socks_sspi.c curl_sspi.c slist.c nonblock.c

HHEADERS = arpa_telnet.h netrc.h file.h timeval.h qssl.h hostip.h	\
  progress.h formdata.h cookie.h http.h sendf.h ftp.h url.h dict.h	\
@@ -21,4 +21,4 @@ HHEADERS = arpa_telnet.h netrc.h file.h timeval.h qssl.h hostip.h \
  strtoofft.h strerror.h inet_ntop.h curlx.h curl_memory.h setup.h	\
  transfer.h select.h easyif.h multiif.h parsedate.h sslgen.h gtls.h	\
  tftp.h sockaddr.h splay.h strdup.h setup_once.h socks.h ssh.h nssg.h	\
  curl_base64.h rawstr.h curl_addrinfo.h curl_sspi.h slist.h
  curl_base64.h rawstr.h curl_addrinfo.h curl_sspi.h slist.h nonblock.h
+1 −54
Original line number Diff line number Diff line
@@ -177,59 +177,6 @@ long Curl_timeleft(struct connectdata *conn,
  return timeout_ms;
}


/*
 * Curl_nonblock() set the given socket to either blocking or non-blocking
 * mode based on the 'nonblock' boolean argument. This function is highly
 * portable.
 */
int Curl_nonblock(curl_socket_t sockfd,    /* operate on this */
                  int nonblock   /* TRUE or FALSE */)
{
#if defined(USE_BLOCKING_SOCKETS)

  return 0; /* returns success */

#elif defined(HAVE_FCNTL_O_NONBLOCK)

  /* most recent unix versions */
  int flags;
  flags = fcntl(sockfd, F_GETFL, 0);
  if(FALSE != nonblock)
    return fcntl(sockfd, F_SETFL, flags | O_NONBLOCK);
  else
    return fcntl(sockfd, F_SETFL, flags & (~O_NONBLOCK));

#elif defined(HAVE_IOCTL_FIONBIO)

  /* older unix versions */
  int flags;
  flags = nonblock;
  return ioctl(sockfd, FIONBIO, &flags);

#elif defined(HAVE_IOCTLSOCKET_FIONBIO)

  /* Windows */
  unsigned long flags;
  flags = nonblock;
  return ioctlsocket(sockfd, FIONBIO, &flags);

#elif defined(HAVE_IOCTLSOCKET_CAMEL_FIONBIO)

  /* Amiga */
  return IoctlSocket(sockfd, FIONBIO, (long)nonblock);

#elif defined(HAVE_SETSOCKOPT_SO_NONBLOCK)

  /* BeOS */
  long b = nonblock ? 1 : 0;
  return setsockopt(sockfd, SOL_SOCKET, SO_NONBLOCK, &b, sizeof(b));

#else
#  error "no non-blocking method was found/used/set"
#endif
}

/*
 * waitconnect() waits for a TCP connect on the given socket for the specified
 * number if milliseconds. It returns:
@@ -846,7 +793,7 @@ singleipconnect(struct connectdata *conn,
  }

  /* set socket non-blocking */
  Curl_nonblock(sockfd, TRUE);
  curlx_nonblock(sockfd, TRUE);

  /* Connect TCP sockets, bind UDP */
  if(conn->socktype == SOCK_STREAM)
+1 −2
Original line number Diff line number Diff line
@@ -23,8 +23,7 @@
 * $Id$
 ***************************************************************************/

int Curl_nonblock(curl_socket_t sockfd,    /* operate on this */
                  int nonblock   /* TRUE or FALSE */);
#include "nonblock.h" /* for curlx_nonblock(), formerly Curl_nonblock() */

CURLcode Curl_is_connected(struct connectdata *conn,
                           int sockindex,
+3 −0
Original line number Diff line number Diff line
@@ -53,6 +53,9 @@
  curlx_tvdiff_secs()
*/

#include "nonblock.h"
/* "nonblock.h" provides curlx_nonblock() */

/* Now setup curlx_ * names for the functions that are to become curlx_ and
   be removed from a future libcurl official API:
   curlx_getenv
Loading