Unverified Commit e91e4816 authored by Daniel Stenberg's avatar Daniel Stenberg
Browse files

libcurl: #ifdef away more code for disabled features/protocols

parent 3b06e68b
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -885,6 +885,8 @@ check_symbol_exists(freeifaddrs "${CURL_INCLUDES}" HAVE_FREEIFADDRS)
check_symbol_exists(pipe           "${CURL_INCLUDES}" HAVE_PIPE)
check_symbol_exists(ftruncate      "${CURL_INCLUDES}" HAVE_FTRUNCATE)
check_symbol_exists(getprotobyname "${CURL_INCLUDES}" HAVE_GETPROTOBYNAME)
check_symbol_exists(getpeername    "${CURL_INCLUDES}" HAVE_GETPEERNAME)
check_symbol_exists(getsockname    "${CURL_INCLUDES}" HAVE_GETSOCKNAME)
check_symbol_exists(getrlimit      "${CURL_INCLUDES}" HAVE_GETRLIMIT)
check_symbol_exists(setlocale      "${CURL_INCLUDES}" HAVE_SETLOCALE)
check_symbol_exists(setmode        "${CURL_INCLUDES}" HAVE_SETMODE)
+2 −0
Original line number Diff line number Diff line
@@ -3772,6 +3772,8 @@ AC_CHECK_FUNCS([fnmatch \
  getpwuid_r \
  getrlimit \
  gettimeofday \
  getpeername \
  getsockname \
  if_nametoindex \
  mach_absolute_time \
  pipe \
+4 −1
Original line number Diff line number Diff line
@@ -7,7 +7,7 @@
 *                            | (__| |_| |  _ <| |___
 *                             \___|\___/|_| \_\_____|
 *
 * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
 * Copyright (C) 1998 - 2019, 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
@@ -185,6 +185,9 @@
/* Define if you have the ftruncate function. */
#define HAVE_FTRUNCATE 1

/* Define to 1 if you have the `getpeername' function. */
#define HAVE_GETPEERNAME 1

/* Define if you have the gethostbyaddr function. */
#define HAVE_GETHOSTBYADDR 1

+14 −9
Original line number Diff line number Diff line
@@ -679,17 +679,18 @@ UNITTEST bool getaddressinfo(struct sockaddr *sa, char *addr,
   connection */
void Curl_updateconninfo(struct connectdata *conn, curl_socket_t sockfd)
{
  curl_socklen_t len;
  struct Curl_sockaddr_storage ssrem;
  struct Curl_sockaddr_storage ssloc;
  struct Curl_easy *data = conn->data;

  if(conn->socktype == SOCK_DGRAM)
    /* there's no connection! */
    return;

#if defined(HAVE_GETPEERNAME) || defined(HAVE_GETSOCKNAME)
  if(!conn->bits.reuse && !conn->bits.tcp_fastopen) {
    struct Curl_easy *data = conn->data;
    char buffer[STRERROR_LEN];
    struct Curl_sockaddr_storage ssrem;
    struct Curl_sockaddr_storage ssloc;
    curl_socklen_t len;
#ifdef HAVE_GETPEERNAME
    len = sizeof(struct Curl_sockaddr_storage);
    if(getpeername(sockfd, (struct sockaddr*) &ssrem, &len)) {
      int error = SOCKERRNO;
@@ -697,7 +698,8 @@ void Curl_updateconninfo(struct connectdata *conn, curl_socket_t sockfd)
            error, Curl_strerror(error, buffer, sizeof(buffer)));
      return;
    }

#endif
#ifdef HAVE_GETSOCKNAME
    len = sizeof(struct Curl_sockaddr_storage);
    memset(&ssloc, 0, sizeof(ssloc));
    if(getsockname(sockfd, (struct sockaddr*) &ssloc, &len)) {
@@ -706,7 +708,8 @@ void Curl_updateconninfo(struct connectdata *conn, curl_socket_t sockfd)
            error, Curl_strerror(error, buffer, sizeof(buffer)));
      return;
    }

#endif
#ifdef HAVE_GETPEERNAME
    if(!getaddressinfo((struct sockaddr*)&ssrem,
                       conn->primary_ip, &conn->primary_port)) {
      failf(data, "ssrem inet_ntop() failed with errno %d: %s",
@@ -714,15 +717,17 @@ void Curl_updateconninfo(struct connectdata *conn, curl_socket_t sockfd)
      return;
    }
    memcpy(conn->ip_addr_str, conn->primary_ip, MAX_IPADR_LEN);

#endif
#ifdef HAVE_GETSOCKNAME
    if(!getaddressinfo((struct sockaddr*)&ssloc,
                       conn->local_ip, &conn->local_port)) {
      failf(data, "ssloc inet_ntop() failed with errno %d: %s",
            errno, Curl_strerror(errno, buffer, sizeof(buffer)));
      return;
    }

#endif
  }
#endif

  /* persist connection info in session handle */
  Curl_persistconninfo(conn);
+6 −0
Original line number Diff line number Diff line
@@ -235,6 +235,12 @@
/* Define to 1 if you have the `getprotobyname' function. */
#cmakedefine HAVE_GETPROTOBYNAME 1

/* Define to 1 if you have the `getpeername' function. */
#cmakedefine HAVE_GETPEERNAME 1

/* Define to 1 if you have the `getsockname' function. */
#cmakedefine HAVE_GETSOCKNAME 1

/* Define to 1 if you have the `getpwuid' function. */
#cmakedefine HAVE_GETPWUID 1

Loading