[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r2211 - GNUnet/src/transports
From: |
durner |
Subject: |
[GNUnet-SVN] r2211 - GNUnet/src/transports |
Date: |
Tue, 25 Oct 2005 12:53:38 -0700 (PDT) |
Author: durner
Date: 2005-10-25 12:53:29 -0700 (Tue, 25 Oct 2005)
New Revision: 2211
Modified:
GNUnet/src/transports/http.c
GNUnet/src/transports/tcp.c
GNUnet/src/transports/tcp6.c
GNUnet/src/transports/udp.c
GNUnet/src/transports/udp6.c
Log:
Don't hang on startup if no network connection was established (Mantis #956)
Modified: GNUnet/src/transports/http.c
===================================================================
--- GNUnet/src/transports/http.c 2005-10-24 18:44:03 UTC (rev 2210)
+++ GNUnet/src/transports/http.c 2005-10-25 19:53:29 UTC (rev 2211)
@@ -312,6 +312,19 @@
}
/**
+ * Cron job to get IP address
+ */
+static void getAddress(void *ip) {
+ if (SYSERR == getPublicIPAddress(* ((IPaddr **) ip)))
+ LOG(LOG_WARNING,
+ _("Could not determine my public IP address.\n"));
+ else
+ LOG(LOG_DEBUG,
+ "HTTP uses IP address %u.%u.%u.%u.\n",
+ PRIP(ntohl(*(int*) *((IPaddr **) ip))));
+}
+
+/**
* Disconnect from a remote node. May only be called
* on sessions that were aquired by the caller first.
* For the core, aquiration means to call associate or
@@ -1083,6 +1096,7 @@
P2P_hello_MESSAGE * msg;
HostAddress * haddr;
unsigned short port;
+ IPaddr **addr;
port = getGNUnetHTTPPort();
if (0 == port) {
@@ -1093,15 +1107,13 @@
msg = (P2P_hello_MESSAGE *) MALLOC(sizeof(P2P_hello_MESSAGE) +
sizeof(HostAddress));
haddr = (HostAddress*) &msg[1];
- if (SYSERR == getPublicIPAddress(&haddr->ip)) {
- FREE(msg);
- LOG(LOG_WARNING,
- _("HTTP: Could not determine my public IP address.\n"));
- return NULL;
- }
- LOG(LOG_DEBUG,
- "HTTP uses IP address %u.%u.%u.%u.\n",
- PRIP(ntohl(*(int*)&haddr->ip)));
+ /* Get address later, don't block startup by
+ name resolution here */
+ memset(&haddr->ip, 0, sizeof(IPaddr));
+ addr = (IPaddr **) MALLOC(sizeof(IPaddr *));
+ *addr = &haddr->ip;
+ addCronJob(getAddress, 0, 0, (void *) addr);
+
haddr->port = htons(port);
haddr->reserved = htons(0);
msg->senderAddressSize = htons(sizeof(HostAddress));
Modified: GNUnet/src/transports/tcp.c
===================================================================
--- GNUnet/src/transports/tcp.c 2005-10-24 18:44:03 UTC (rev 2210)
+++ GNUnet/src/transports/tcp.c 2005-10-25 19:53:29 UTC (rev 2211)
@@ -264,6 +264,19 @@
}
/**
+ * Cron job to get IP address
+ */
+static void getAddress(void *ip) {
+ if (SYSERR == getPublicIPAddress(* ((IPaddr **) ip)))
+ LOG(LOG_WARNING,
+ _("Could not determine my public IP address.\n"));
+ else
+ LOG(LOG_DEBUG,
+ "TCP uses IP address %u.%u.%u.%u.\n",
+ PRIP(ntohl(*(int*) *((IPaddr **) ip))));
+}
+
+/**
* Disconnect from a remote node. May only be called
* on sessions that were aquired by the caller first.
* For the core, aquiration means to call associate or
@@ -1062,6 +1075,7 @@
P2P_hello_MESSAGE * msg;
HostAddress * haddr;
unsigned short port;
+ IPaddr **addr;
port = getGNUnetTCPPort();
if (0 == port) {
@@ -1076,15 +1090,12 @@
msg = (P2P_hello_MESSAGE *) MALLOC(sizeof(P2P_hello_MESSAGE) +
sizeof(HostAddress));
haddr = (HostAddress*) &msg[1];
- if (SYSERR == getPublicIPAddress(&haddr->ip)) {
- FREE(msg);
- LOG(LOG_WARNING,
- _("Could not determine my public IP address.\n"));
- return NULL;
- }
- LOG(LOG_DEBUG,
- "TCP uses IP address %u.%u.%u.%u.\n",
- PRIP(ntohl(*(int*)&haddr->ip)));
+ /* Get address later, don't block startup by
+ name resolution here */
+ memset(&haddr->ip, 0, sizeof(IPaddr));
+ addr = (IPaddr **) MALLOC(sizeof(IPaddr *));
+ *addr = &haddr->ip;
+ addCronJob(getAddress, 0, 0, (void *) addr);
haddr->port = htons(port);
haddr->reserved = htons(0);
msg->senderAddressSize = htons(sizeof(HostAddress));
Modified: GNUnet/src/transports/tcp6.c
===================================================================
--- GNUnet/src/transports/tcp6.c 2005-10-24 18:44:03 UTC (rev 2210)
+++ GNUnet/src/transports/tcp6.c 2005-10-25 19:53:29 UTC (rev 2211)
@@ -248,6 +248,15 @@
}
/**
+ * Cron job to get IP address
+ */
+static void getAddress(void *ip) {
+ if (SYSERR == getPublicIP6Address(*(IP6addr **)ip))
+ LOG(LOG_WARNING,
+ _("Could not determine my public IPv6 address.\n"));
+}
+
+/**
* Disconnect from a remote node. May only be called
* on sessions that were aquired by the caller first.
* For the core, aquiration means to call associate or
@@ -942,6 +951,7 @@
P2P_hello_MESSAGE * msg;
Host6Address * haddr;
unsigned short port;
+ IP6addr **addr;
port = getGNUnetTCP6Port();
if (0 == port) {
@@ -952,12 +962,12 @@
msg = (P2P_hello_MESSAGE *) MALLOC(sizeof(P2P_hello_MESSAGE) +
sizeof(Host6Address));
haddr = (Host6Address*) &msg[1];
- if (SYSERR == getPublicIP6Address(&haddr->ip)) {
- FREE(msg);
- LOG(LOG_WARNING,
- _("Could not determine my public IPv6 address.\n"));
- return NULL;
- }
+ /* Get address later, don't block startup by
+ name resolution here */
+ memset(&haddr->ip, 0, sizeof(IP6addr));
+ addr = (IP6addr **) MALLOC(sizeof(IP6addr *));
+ *addr = &haddr->ip;
+ addCronJob(getAddress, 0, 0, (void *) addr);
haddr->port = htons(port);
haddr->reserved = htons(0);
msg->senderAddressSize = htons(sizeof(Host6Address));
Modified: GNUnet/src/transports/udp.c
===================================================================
--- GNUnet/src/transports/udp.c 2005-10-24 18:44:03 UTC (rev 2210)
+++ GNUnet/src/transports/udp.c 2005-10-25 19:53:29 UTC (rev 2211)
@@ -155,6 +155,22 @@
}
/**
+ * Cron job to get IP address
+ */
+/**
+ * Cron job to get IP address
+ */
+static void getAddress(void *ip) {
+ if (SYSERR == getPublicIPAddress(* ((IPaddr **) ip)))
+ LOG(LOG_WARNING,
+ _("Could not determine my public IP address.\n"));
+ else
+ LOG(LOG_DEBUG,
+ "UDP uses IP address %u.%u.%u.%u.\n",
+ PRIP(ntohl(*(int*) *((IPaddr **) ip))));
+}
+
+/**
* Allocate and bind a server socket for the UDP transport.
*/
static int passivesock(unsigned short port) {
@@ -342,6 +358,7 @@
static P2P_hello_MESSAGE * createhello() {
P2P_hello_MESSAGE * msg;
HostAddress * haddr;
+ IPaddr **addr;
if ( ( (udp_shutdown == YES) && (getGNUnetUDPPort() == 0) ) ||
( (udp_shutdown == NO) && (port == 0) ) )
@@ -350,15 +367,13 @@
msg = MALLOC(sizeof(P2P_hello_MESSAGE) + sizeof(HostAddress));
haddr = (HostAddress*) &msg[1];
- if (SYSERR == getPublicIPAddress(&haddr->senderIP)) {
- FREE(msg);
- LOG(LOG_WARNING,
- _("UDP: Could not determine my public IP address.\n"));
- return NULL;
- }
- LOG(LOG_DEBUG,
- "UDP uses IP address %u.%u.%u.%u.\n",
- PRIP(ntohl(*(int*)&haddr->senderIP)));
+ /* Get address later, don't block startup by
+ name resolution here */
+ memset(&haddr->senderIP, 0, sizeof(IPaddr));
+ addr = (IPaddr **) MALLOC(sizeof(IPaddr *));
+ *addr = &haddr->senderIP;
+ addCronJob(getAddress, 0, 0, (void *) addr);
+
if (udp_shutdown == YES)
haddr->senderPort = htons(getGNUnetUDPPort());
else
Modified: GNUnet/src/transports/udp6.c
===================================================================
--- GNUnet/src/transports/udp6.c 2005-10-24 18:44:03 UTC (rev 2210)
+++ GNUnet/src/transports/udp6.c 2005-10-25 19:53:29 UTC (rev 2211)
@@ -183,6 +183,15 @@
}
/**
+ * Cron job to get IP address
+ */
+static void getAddress(void *ip) {
+ if (SYSERR == getPublicIP6Address(*(IP6addr **)ip))
+ LOG(LOG_WARNING,
+ _("Could not determine my public IPv6 address.\n"));
+}
+
+/**
* Listen on the given socket and distribute the packets to the UDP6
* handler.
*/
@@ -339,6 +348,7 @@
P2P_hello_MESSAGE * msg;
Host6Address * haddr;
unsigned short port;
+ IP6addr **addr;
port = getGNUnetUDP6Port();
if (port == 0)
@@ -347,12 +357,13 @@
msg = MALLOC(sizeof(P2P_hello_MESSAGE) + sizeof(Host6Address));
haddr = (Host6Address*) &msg[1];
- if (SYSERR == getPublicIP6Address(&haddr->senderIP)) {
- FREE(msg);
- LOG(LOG_WARNING,
- _("UDP6: Could not determine my public IPv6 address.\n"));
- return NULL;
- }
+ /* Get address later, don't block startup by
+ name resolution here */
+ memset(&haddr->senderIP, 0, sizeof(IP6addr));
+ addr = (IP6addr **) MALLOC(sizeof(IP6addr *));
+ *addr = &haddr->senderIP;
+ addCronJob(getAddress, 0, 0, (void *) addr);
+
haddr->senderPort = htons(port);
haddr->reserved = htons(0);
msg->senderAddressSize = htons(sizeof(Host6Address));
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r2211 - GNUnet/src/transports,
durner <=