ap->addrlen = addrlen;
ap->connection = connection;
- ap->sock = GNUNET_NETWORK_socket_create (ap->addr->sa_family, SOCK_STREAM, 0);
- if (NULL == ap->sock)
- {
- GNUNET_free (ap);
- return; /* not supported by OS */
- }
switch (ap->addr->sa_family)
{
case AF_INET:
- {
- struct sockaddr_in bnd;
-
- ((struct sockaddr_in *) ap->addr)->sin_port = htons (connection->port);
-
- bnd.sin_family = AF_INET;
- bnd.sin_port = htons (0);
- bnd.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
-#if HAVE_SOCKADDR_IN_SIN_LEN
- bnd.sin_len = sizeof (bnd);
-#endif
- if (0 == memcmp (&bnd.sin_addr.s_addr,
- &((struct sockaddr_in *) ap->addr)->sin_addr.s_addr,
- sizeof (bnd.sin_addr.s_addr)))
- {
- /* bind source IP to FORCE it to be loopback */
- (void) GNUNET_NETWORK_socket_bind (ap->sock,
- (const struct sockaddr *) &bnd,
- sizeof (bnd));
- }
- }
+ ((struct sockaddr_in *) ap->addr)->sin_port = htons (connection->port);
break;
case AF_INET6:
- {
- struct sockaddr_in6 bnd;
-
- ((struct sockaddr_in6 *) ap->addr)->sin6_port = htons (connection->port);
-
- bnd.sin6_family = AF_INET6;
- bnd.sin6_port = htons (0);
- bnd.sin6_addr = in6addr_loopback;
-#if HAVE_SOCKADDR_IN_SIN_LEN
- bnd.sin6_len = sizeof (bnd);
-#endif
- if (0 == memcmp (&bnd.sin6_addr,
- &((struct sockaddr_in6 *) ap->addr)->sin6_addr,
- sizeof (bnd.sin6_addr)))
- {
- /* bind source IP to FORCE it to be loopback */
- (void) GNUNET_NETWORK_socket_bind (ap->sock,
- (const struct sockaddr *) &bnd,
- sizeof (bnd));
- }
- }
+ ((struct sockaddr_in6 *) ap->addr)->sin6_port = htons (connection->port);
break;
default:
GNUNET_break (0);
GNUNET_free (ap);
return; /* not supported by us */
}
+ ap->sock = GNUNET_NETWORK_socket_create (ap->addr->sa_family, SOCK_STREAM, 0);
+ if (NULL == ap->sock)
+ {
+ GNUNET_free (ap);
+ return; /* not supported by OS */
+ }
LOG (GNUNET_ERROR_TYPE_INFO, _("Trying to connect to `%s' (%p)\n"),
GNUNET_a2s (ap->addr, ap->addrlen), connection);
-
if ((GNUNET_OK !=
GNUNET_NETWORK_socket_connect (ap->sock, ap->addr, ap->addrlen)) &&
(EINPROGRESS != errno))
GNUNET_free (connection);
return NULL;
}
- if (GNUNET_OK !=
- GNUNET_NETWORK_socket_connect (connection->sock, connection->addr, connection->addrlen))
+ if ( (GNUNET_OK !=
+ GNUNET_NETWORK_socket_connect (connection->sock, connection->addr, connection->addrlen)) &&
+ (EINPROGRESS != errno) )
{
/* Just return; we expect everything to work eventually so don't fail HARD */
GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (connection->sock));
size_t size;
GNUNET_CONNECTION_TransmitReadyNotify notify;
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "process_notify is running\n");
+
GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == connection->write_task);
if (NULL == (notify = connection->nth.notify_ready))
+ {
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Noone to notify\n");
return GNUNET_NO;
+ }
used = connection->write_buffer_off - connection->write_buffer_pos;
avail = connection->write_buffer_size - used;
size = connection->nth.notify_size;
if (size > avail)
+ {
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Not enough buffer\n");
return GNUNET_NO;
+ }
connection->nth.notify_ready = NULL;
if (connection->write_buffer_size - connection->write_buffer_off < size)
{