if (cl->dispatch_free)
cl->dispatch_free(cl);
cl->dispatch_free = NULL;
+ cl->dispatch_close_fds = NULL;
}
void uh_request_done(struct client *cl)
n_clients++;
cl->id = client_id++;
}
+
+void uh_close_fds(void)
+{
+ struct client *cl;
+
+ uloop_done();
+ uh_close_listen_fds();
+ list_for_each_entry(cl, &clients, list) {
+ close(cl->sfd.fd.fd);
+ if (cl->dispatch_close_fds)
+ cl->dispatch_close_fds(cl);
+ }
+}
/* Returns NULL on error.
** NB: improperly encoded URL should give client 400 [Bad Syntax]; returning
** NULL here causes 404 [Not Found], but that's not too unreasonable. */
-struct path_info * uh_path_lookup(struct client *cl, const char *url)
+static struct path_info *
+uh_path_lookup(struct client *cl, const char *url)
{
static char path_phys[PATH_MAX];
static char path_info[PATH_MAX];
cl->data.file.fd = fd;
cl->dispatch_write_cb = file_write_cb;
cl->dispatch_free = uh_file_free;
+ cl->dispatch_close_fds = uh_file_free;
file_write_cb(cl);
}
static LIST_HEAD(listeners);
static int n_blocked;
+void uh_close_listen_fds(void)
+{
+ struct listener *l;
+
+ list_for_each_entry(l, &listeners, list)
+ close(l->fd.fd);
+}
+
static void uh_block_listener(struct listener *l)
{
uloop_fd_delete(&l->fd);
struct blob_buf hdr;
void (*dispatch_write_cb)(struct client *cl);
+ void (*dispatch_close_fds)(struct client *cl);
void (*dispatch_free)(struct client *cl);
union {
void uh_auth_add(const char *path, const char *user, const char *pass);
+void uh_close_listen_fds(void);
+void uh_close_fds(void);
+
#endif