Commit 2d51a09b authored by Per Cederqvist's avatar Per Cederqvist
Browse files

(isc_tcp_accept): Use the address that the accept() call supplies, so

	that we don't have to do an extra call to getpeername().  Copy
	the local address from the socket we listen to, so that we
	don't have to do an extra call to getsockname().
parent 5cf83c36
......@@ -71,11 +71,14 @@ isc_tcp_accept(struct isc_scb_internal *scb)
{
struct isc_scb_internal *new_scb;
int fd;
SOCKADDR_STORAGE addr;
socklen_t len;
len = sizeof(addr);
if ((fd = accept(scb->pub.fd,
(struct sockaddr *) NULL,
(socklen_t *) NULL)) < 0)
(struct sockaddr *)&addr,
&len)) < 0)
{
/* FIXME (bug 106): Log a message. */
return NULL;
......@@ -86,13 +89,8 @@ isc_tcp_accept(struct isc_scb_internal *scb)
return NULL;
/* Fill in the session info structure */
new_scb->pub.raddr = isc_getraddress(&new_scb->pub);
if (new_scb->pub.raddr == NULL)
{
isc_destroy(NULL, &scb->pub);
return NULL;
}
new_scb->pub.laddr = isc_getladdress(&new_scb->pub);
new_scb->pub.raddr = isc_mkipaddress(&addr);
new_scb->pub.laddr = isc_copyaddress(scb->pub.laddr);
return new_scb;
}
......@@ -326,6 +324,7 @@ isc_bindtcp(struct isc_scb_internal *scb,
return -1;
scb->pub.laddr = ia;
assert(scb->pub.raddr == NULL);
return 0;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment