Permalink
Browse files

Fixes:

 - source socket is now closed after an unsuccesful address family approach
 - we are now using the correct structure to set the destination port (v4/v6)
 - we are using the src->addr_current for updating the socket
  • Loading branch information...
1 parent dea28fe commit 84e068bc4ead672c60b6ceae82096f4dc4cbfdc4 @skinkie committed Oct 13, 2011
Showing with 14 additions and 2 deletions.
  1. +14 −2 cherokee/source.c
View
16 cherokee/source.c
@@ -161,13 +161,25 @@ cherokee_source_connect (cherokee_source_t *src, cherokee_socket_t *sock)
addr = addr_info;
continue;
}
+
+ cherokee_socket_close(sock);
@alobbs
alobbs added a line comment Oct 13, 2011

There is no much of a point for this. It will reach this point if it could not create the socket fd, and therefore there is nothing to be closed. (It does not hurt though).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
}
/* Update the new socket with the address info
*/
- SOCKET_ADDR_IPv4(sock)->sin_port = htons(src->port);
+ switch (src->addr_current->ai_family) {
+ case AF_INET:
+ SOCKET_ADDR_IPv4(sock)->sin_port = htons(src->port);
+ break;
+ case AF_INET6:
+ SOCKET_ADDR_IPv6(sock)->sin6_port = htons(src->port);
+ break;
+ default:
+ SHOULDNT_HAPPEN;
+ return ret_error;
+ }
- ret = cherokee_socket_update_from_addrinfo (sock, addr_info, 0);
+ ret = cherokee_socket_update_from_addrinfo (sock, src->addr_current, 0);
if (unlikely (ret != ret_ok)) {
return ret_error;
}

0 comments on commit 84e068b

Please sign in to comment.