sock/child: remove global variable addrlen.
This changes listen_sock() to not return the addrlen of the used address from getaddrinfo call to the caller, stored in global addrlen in child.c. This was only used to be able to allocate enough space for the arguments to the later accept call depending on whether IPv4 or IPv6 is used. This removes the need to pass this info by always allocating sizeof(struct sockaddr_storage) instead, which is enough to carry both sockaddr_in and sockaddr_in6. Signed-off-by: Michael Adam <obnox@samba.org>
This commit is contained in:
1 parent
4bbd6e8626
commit
7eea1638bc
3 files changed
+8
-13
No files matched your search
+3
-8
@@ -163,12 +163,10 @@ int socket_blocking (int sock)
|
||||
}
|
||||
|
||||
/*
|
||||
* Start listening to a socket. Create a socket with the selected port.
|
||||
* The size of the socket address will be returned to the caller through
|
||||
* the pointer, while the socket is returned as a default return.
|
||||
* - rjkaes
|
||||
* Start listening on a socket. Create a socket with the selected port.
|
||||
* The socket fd is returned upon success, -1 upon error.
|
||||
*/
|
||||
int listen_sock (uint16_t port, socklen_t * addrlen)
|
||||
int listen_sock (uint16_t port)
|
||||
{
|
||||
struct addrinfo hints, *result, *rp;
|
||||
char portstr[6];
|
||||
@@ -176,7 +174,6 @@ int listen_sock (uint16_t port, socklen_t * addrlen)
|
||||
const int on = 1;
|
||||
|
||||
assert (port > 0);
|
||||
assert (addrlen != NULL);
|
||||
|
||||
memset (&hints, 0, sizeof (struct addrinfo));
|
||||
hints.ai_family = AF_UNSPEC;
|
||||
@@ -227,8 +224,6 @@ int listen_sock (uint16_t port, socklen_t * addrlen)
|
||||
return -1;
|
||||
}
|
||||
|
||||
*addrlen = rp->ai_addrlen;
|
||||
|
||||
freeaddrinfo (result);
|
||||
|
||||
return listenfd;
|
||||
|
||||
Reference in new issue
Block a user