version 1.111, 2003/06/12 19:12:03 |
version 1.112, 2003/09/18 08:49:45 |
|
|
static void |
static void |
new_socket(sock_type type, int fd) |
new_socket(sock_type type, int fd) |
{ |
{ |
u_int i, old_alloc; |
u_int i, old_alloc, new_alloc; |
|
|
if (fcntl(fd, F_SETFL, O_NONBLOCK) < 0) |
if (fcntl(fd, F_SETFL, O_NONBLOCK) < 0) |
error("fcntl O_NONBLOCK: %s", strerror(errno)); |
error("fcntl O_NONBLOCK: %s", strerror(errno)); |
|
|
for (i = 0; i < sockets_alloc; i++) |
for (i = 0; i < sockets_alloc; i++) |
if (sockets[i].type == AUTH_UNUSED) { |
if (sockets[i].type == AUTH_UNUSED) { |
sockets[i].fd = fd; |
sockets[i].fd = fd; |
sockets[i].type = type; |
|
buffer_init(&sockets[i].input); |
buffer_init(&sockets[i].input); |
buffer_init(&sockets[i].output); |
buffer_init(&sockets[i].output); |
buffer_init(&sockets[i].request); |
buffer_init(&sockets[i].request); |
|
sockets[i].type = type; |
return; |
return; |
} |
} |
old_alloc = sockets_alloc; |
old_alloc = sockets_alloc; |
sockets_alloc += 10; |
new_alloc = sockets_alloc + 10; |
if (sockets) |
if (sockets) |
sockets = xrealloc(sockets, sockets_alloc * sizeof(sockets[0])); |
sockets = xrealloc(sockets, new_alloc * sizeof(sockets[0])); |
else |
else |
sockets = xmalloc(sockets_alloc * sizeof(sockets[0])); |
sockets = xmalloc(new_alloc * sizeof(sockets[0])); |
for (i = old_alloc; i < sockets_alloc; i++) |
for (i = old_alloc; i < new_alloc; i++) |
sockets[i].type = AUTH_UNUSED; |
sockets[i].type = AUTH_UNUSED; |
sockets[old_alloc].type = type; |
sockets_alloc = new_alloc; |
sockets[old_alloc].fd = fd; |
sockets[old_alloc].fd = fd; |
buffer_init(&sockets[old_alloc].input); |
buffer_init(&sockets[old_alloc].input); |
buffer_init(&sockets[old_alloc].output); |
buffer_init(&sockets[old_alloc].output); |
buffer_init(&sockets[old_alloc].request); |
buffer_init(&sockets[old_alloc].request); |
|
sockets[old_alloc].type = type; |
} |
} |
|
|
static int |
static int |