}
}
-void uh_accept_client(int fd)
+bool uh_accept_client(int fd)
{
static struct client *next_client;
struct client *cl;
sl = sizeof(addr);
sfd = accept(fd, (struct sockaddr *) &addr, &sl);
if (sfd < 0)
- return;
+ return false;
set_addr(&cl->peer_addr, &addr);
sl = sizeof(addr);
next_client = NULL;
n_clients++;
cl->id = client_id++;
+ return true;
}
void uh_close_fds(void)
{
struct listener *l;
- if (!n_blocked && conf.max_requests &&
+ if ((!n_blocked && conf.max_requests) ||
n_clients >= conf.max_requests)
return;
if (!l->blocked)
continue;
+ l->fd.cb(&l->fd, ULOOP_READ);
+ if (n_clients >= conf.max_requests)
+ break;
+
n_blocked--;
l->blocked = false;
uloop_fd_add(&l->fd, ULOOP_READ);
{
struct listener *l = container_of(fd, struct listener, fd);
- uh_accept_client(fd->fd);
+ while (1) {
+ if (!uh_accept_client(fd->fd))
+ break;
+ }
if (conf.max_requests && n_clients >= conf.max_requests)
uh_block_listener(l);
void uh_index_add(const char *filename);
-void uh_accept_client(int fd);
+bool uh_accept_client(int fd);
void uh_unblock_listeners(void);
void uh_setup_listeners(void);