summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2012-12-31 18:49:08 +0100
committerFelix Fietkau <nbd@openwrt.org>2012-12-31 18:49:08 +0100
commit8515c92b9302b258be10df5c5cee240dd4b137f6 (patch)
tree81a74986f105cec6dc5306d1979af0860843a387
parentd779a5dc390b9c6e1ed32cdd287997f81ee88d37 (diff)
make uh_path_lookup static
-rw-r--r--client.c14
-rw-r--r--file.c4
-rw-r--r--listen.c8
-rw-r--r--uhttpd.h4
4 files changed, 29 insertions, 1 deletions
diff --git a/client.c b/client.c
index e1c8c55..a28067e 100644
--- a/client.c
+++ b/client.c
@@ -63,6 +63,7 @@ static void uh_dispatch_done(struct client *cl)
if (cl->dispatch_free)
cl->dispatch_free(cl);
cl->dispatch_free = NULL;
+ cl->dispatch_close_fds = NULL;
}
void uh_request_done(struct client *cl)
@@ -329,3 +330,16 @@ void uh_accept_client(int fd)
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);
+ }
+}
diff --git a/file.c b/file.c
index 7091ef7..23222b9 100644
--- a/file.c
+++ b/file.c
@@ -127,7 +127,8 @@ next:
/* 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];
@@ -585,6 +586,7 @@ static void uh_file_data(struct client *cl, struct path_info *pi, int fd)
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);
}
diff --git a/listen.c b/listen.c
index 55d7143..c4b6b2b 100644
--- a/listen.c
+++ b/listen.c
@@ -37,6 +37,14 @@ struct listener {
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);
diff --git a/uhttpd.h b/uhttpd.h
index c900e90..02d2705 100644
--- a/uhttpd.h
+++ b/uhttpd.h
@@ -119,6 +119,7 @@ struct client {
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 {
@@ -158,4 +159,7 @@ void uh_handle_file_request(struct client *cl);
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