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

Gisle Vanem's fixes to use CURL_SOCKET_BAD more instead of -1 for sockets.

parent 326e8b9f
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -417,6 +417,7 @@ static bool verifyconnect(curl_socket_t sockfd)
  /* This wasn't a successful connect */
  return FALSE;
#else
  (void)sockfd;
  return TRUE;
#endif
}
@@ -571,7 +572,7 @@ CURLcode Curl_connecthost(struct connectdata *conn, /* context */
   */
  for (ai = remotehost->addr; ai; ai = ai->ai_next, aliasindex++) {
    sockfd = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
    if (sockfd < 0)
    if (sockfd == CURL_SOCKET_BAD)
      continue;
#else
  /*
@@ -681,7 +682,7 @@ CURLcode Curl_connecthost(struct connectdata *conn, /* context */
    }
    before = after;
  }
  if (sockfd < 0) {
  if (sockfd == CURL_SOCKET_BAD) {
    /* no good connect was made */
    *sockconn = -1;
    failf(data, "Connect failed");
+5 −5
Original line number Diff line number Diff line
@@ -166,7 +166,7 @@ static CURLcode AllowServerConnect(struct connectdata *conn)
  default:
    /* we have received data here */
    {
      int s;
      curl_socket_t s;
      size_t size = sizeof(struct sockaddr_in);
      struct sockaddr_in add;

@@ -175,7 +175,7 @@ static CURLcode AllowServerConnect(struct connectdata *conn)

      sclose(sock); /* close the first socket */

      if (-1 == s) {
      if (CURL_SOCKET_BAD == s) {
        /* DIE! */
        failf(data, "Error accept()ing server connect");
      	return CURLE_FTP_PORT_FAILED;
@@ -766,7 +766,7 @@ CURLcode Curl_ftp_done(struct connectdata *conn)
#endif
  /* shut down the socket to inform the server we're done */
  sclose(conn->sock[SECONDARYSOCKET]);
  conn->sock[SECONDARYSOCKET] = -1;
  conn->sock[SECONDARYSOCKET] = CURL_SOCKET_BAD;

  if(!ftp->no_transfer) {
    /* Let's see what the server says about the transfer we just performed,
@@ -2379,10 +2379,10 @@ CURLcode Curl_ftp(struct connectdata *conn)
    if(connected)
      retcode = Curl_ftp_nextconnect(conn);

    if(retcode && (conn->sock[SECONDARYSOCKET] >= 0)) {
    if(retcode && (conn->sock[SECONDARYSOCKET] != CURL_SOCKET_BAD)) {
      /* Failure detected, close the second socket if it was created already */
      sclose(conn->sock[SECONDARYSOCKET]);
      conn->sock[SECONDARYSOCKET] = -1;
      conn->sock[SECONDARYSOCKET] = CURL_SOCKET_BAD;
    }

    if(ftp->no_transfer)
+1 −1
Original line number Diff line number Diff line
@@ -486,7 +486,7 @@ CURLMcode curl_multi_perform(CURLM *multi_handle, int *running_handles)
           * possibly know if the connection is in a good shape or not now. */
          easy->easy_conn->bits.close = TRUE;

          if(-1 !=easy->easy_conn->sock[SECONDARYSOCKET]) {
          if(CURL_SOCKET_BAD != easy->easy_conn->sock[SECONDARYSOCKET]) {
            /* if we failed anywhere, we must clean up the secondary socket if
               it was used */
            sclose(easy->easy_conn->sock[SECONDARYSOCKET]);
+4 −3
Original line number Diff line number Diff line
@@ -1091,12 +1091,12 @@ CURLcode Curl_telnet(struct connectdata *conn)
  HANDLE stdin_handle;
  HANDLE objs[2];
  DWORD waitret;
  DWORD nread;
  DWORD readfile_read;
#else
  fd_set readfd;
  fd_set keepfd;
  ssize_t nread;  
#endif
  ssize_t nread;  
  bool keepon = TRUE;
  char *buf = data->state.buffer;
  struct TELNET *tn;
@@ -1203,10 +1203,11 @@ CURLcode Curl_telnet(struct connectdata *conn)
      char *buffer = buf;
              
      if(!ReadFile(stdin_handle, buf, sizeof(data->state.buffer),
                   (LPDWORD)&nread, NULL)) {
                   &readfile_read, NULL)) {
        keepon = FALSE;
        break;
      }
      nread = readfile_read;
        
      while(nread--) {
        outbuf[0] = *buffer++;
+1 −0
Original line number Diff line number Diff line
@@ -63,6 +63,7 @@ static int gettimeofday(struct timeval *tp, void *nothing)
  tp->tv_sec = Sec;
  tp->tv_usec = Usec;
#endif /* WITHOUT_MM_LIB */
  (void)nothing;
  return 0;
}
#else /* WIN32 */
Loading