]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Move network_init to lib/net
authorNick Mathewson <nickm@torproject.org>
Thu, 28 Jun 2018 15:59:16 +0000 (11:59 -0400)
committerNick Mathewson <nickm@torproject.org>
Thu, 28 Jun 2018 15:59:16 +0000 (11:59 -0400)
src/common/compat.c
src/lib/net/socket.c

index e71931aa12716e39096cc4acea155bfca9869186..f8333624ca7dded3bc5f2a99bae3ef4b496f0c81 100644 (file)
@@ -429,34 +429,6 @@ compute_num_cpus(void)
   return num_cpus;
 }
 
-/** Called before we make any calls to network-related functions.
- * (Some operating systems require their network libraries to be
- * initialized.) */
-int
-network_init(void)
-{
-#ifdef _WIN32
-  /* This silly exercise is necessary before windows will allow
-   * gethostbyname to work. */
-  WSADATA WSAData;
-  int r;
-  r = WSAStartup(0x101,&WSAData);
-  if (r) {
-    log_warn(LD_NET,"Error initializing windows network layer: code was %d",r);
-    return -1;
-  }
-  if (sizeof(SOCKET) != sizeof(tor_socket_t)) {
-    log_warn(LD_BUG,"The tor_socket_t type does not match SOCKET in size; Tor "
-             "might not work. (Sizes are %d and %d respectively.)",
-             (int)sizeof(tor_socket_t), (int)sizeof(SOCKET));
-  }
-  /* WSAData.iMaxSockets might show the max sockets we're allowed to use.
-   * We might use it to complain if we're trying to be a server but have
-   * too few sockets available. */
-#endif /* defined(_WIN32) */
-  return 0;
-}
-
 #if defined(HW_PHYSMEM64)
 /* This appears to be an OpenBSD thing */
 #define INT64_HW_MEM HW_PHYSMEM64
index ae384bcd479bcd062ee759719c1171b5f70a00c3..dc3d1531ff6ea162839a9fa21f18f21fd1ed001e 100644 (file)
 #include <stddef.h>
 #include <string.h>
 
+/** Called before we make any calls to network-related functions.
+ * (Some operating systems require their network libraries to be
+ * initialized.) */
+int
+network_init(void)
+{
+#ifdef _WIN32
+  /* This silly exercise is necessary before windows will allow
+   * gethostbyname to work. */
+  WSADATA WSAData;
+  int r;
+  r = WSAStartup(0x101,&WSAData);
+  if (r) {
+    log_warn(LD_NET,"Error initializing windows network layer: code was %d",r);
+    return -1;
+  }
+  if (sizeof(SOCKET) != sizeof(tor_socket_t)) {
+    log_warn(LD_BUG,"The tor_socket_t type does not match SOCKET in size; Tor "
+             "might not work. (Sizes are %d and %d respectively.)",
+             (int)sizeof(tor_socket_t), (int)sizeof(SOCKET));
+  }
+  /* WSAData.iMaxSockets might show the max sockets we're allowed to use.
+   * We might use it to complain if we're trying to be a server but have
+   * too few sockets available. */
+#endif /* defined(_WIN32) */
+  return 0;
+}
+
 /* When set_max_file_sockets() is called, update this with the max file
  * descriptor value so we can use it to check the limit when opening a new
  * socket. Default value is what Debian sets as the default hard limit. */