mirror of
git://projects.qi-hardware.com/openwrt-xburst.git
synced 2024-11-19 04:49:42 +02:00
[package] uhttpd: do not subscribe to epoll write events
Watch child read pipe end for data instead of relying on socket write notification to process cgi data, should lower cpu consumption during requests on weaker devices. git-svn-id: svn://svn.openwrt.org/openwrt/trunk@32640 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
parent
fffc489ef4
commit
c2e7896dea
@ -8,7 +8,7 @@
|
|||||||
include $(TOPDIR)/rules.mk
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
PKG_NAME:=uhttpd
|
PKG_NAME:=uhttpd
|
||||||
PKG_RELEASE:=36
|
PKG_RELEASE:=37
|
||||||
|
|
||||||
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
|
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
|
||||||
PKG_CONFIG_DEPENDS := \
|
PKG_CONFIG_DEPENDS := \
|
||||||
|
@ -530,6 +530,7 @@ bool uh_cgi_request(struct client *cl, struct path_info *pi,
|
|||||||
memset(state, 0, sizeof(*state));
|
memset(state, 0, sizeof(*state));
|
||||||
|
|
||||||
state->cl = cl;
|
state->cl = cl;
|
||||||
|
state->cl->pipe.fd = rfd[0];
|
||||||
state->cl->proc.pid = child;
|
state->cl->proc.pid = child;
|
||||||
|
|
||||||
/* close unneeded pipe ends */
|
/* close unneeded pipe ends */
|
||||||
|
@ -558,6 +558,7 @@ bool uh_lua_request(struct client *cl, lua_State *L)
|
|||||||
memset(state, 0, sizeof(*state));
|
memset(state, 0, sizeof(*state));
|
||||||
|
|
||||||
state->cl = cl;
|
state->cl = cl;
|
||||||
|
state->cl->pipe.fd = rfd[0];
|
||||||
state->cl->proc.pid = child;
|
state->cl->proc.pid = child;
|
||||||
|
|
||||||
/* close unneeded pipe ends */
|
/* close unneeded pipe ends */
|
||||||
|
@ -996,6 +996,9 @@ void uh_client_remove(struct client *cl)
|
|||||||
if (cur->proc.pid)
|
if (cur->proc.pid)
|
||||||
uloop_process_delete(&cur->proc);
|
uloop_process_delete(&cur->proc);
|
||||||
|
|
||||||
|
if (cur->pipe.fd)
|
||||||
|
uloop_fd_delete(&cur->pipe);
|
||||||
|
|
||||||
uloop_fd_delete(&cur->fd);
|
uloop_fd_delete(&cur->fd);
|
||||||
close(cur->fd.fd);
|
close(cur->fd.fd);
|
||||||
|
|
||||||
|
@ -219,7 +219,7 @@ static int uh_socket_bind(fd_set *serv_fds, int *max_fd,
|
|||||||
*max_fd = max(*max_fd, sock);
|
*max_fd = max(*max_fd, sock);
|
||||||
|
|
||||||
l->fd.cb = uh_listener_cb;
|
l->fd.cb = uh_listener_cb;
|
||||||
uloop_fd_add(&l->fd, ULOOP_READ | ULOOP_WRITE);
|
uloop_fd_add(&l->fd, ULOOP_READ);
|
||||||
|
|
||||||
bound++;
|
bound++;
|
||||||
continue;
|
continue;
|
||||||
@ -539,7 +539,7 @@ static void uh_listener_cb(struct uloop_fd *u, unsigned int events)
|
|||||||
if ((cl = uh_client_add(new_fd, serv)) != NULL)
|
if ((cl = uh_client_add(new_fd, serv)) != NULL)
|
||||||
{
|
{
|
||||||
/* add client socket to global fdset */
|
/* add client socket to global fdset */
|
||||||
uloop_fd_add(&cl->fd, ULOOP_READ | ULOOP_WRITE);
|
uloop_fd_add(&cl->fd, ULOOP_READ);
|
||||||
|
|
||||||
#ifdef HAVE_TLS
|
#ifdef HAVE_TLS
|
||||||
/* setup client tls context */
|
/* setup client tls context */
|
||||||
@ -569,6 +569,15 @@ static void uh_listener_cb(struct uloop_fd *u, unsigned int events)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void uh_pipe_cb(struct uloop_fd *u, unsigned int events)
|
||||||
|
{
|
||||||
|
struct client *cl = container_of(u, struct client, pipe);
|
||||||
|
|
||||||
|
D("SRV: Client(%d) pipe(%d) readable\n", cl->fd.fd, cl->pipe.fd);
|
||||||
|
|
||||||
|
uh_client_cb(&cl->fd, ULOOP_WRITE);
|
||||||
|
}
|
||||||
|
|
||||||
static void uh_child_cb(struct uloop_process *p, int rv)
|
static void uh_child_cb(struct uloop_process *p, int rv)
|
||||||
{
|
{
|
||||||
struct client *cl = container_of(p, struct client, proc);
|
struct client *cl = container_of(p, struct client, proc);
|
||||||
@ -686,6 +695,15 @@ static void uh_client_cb(struct uloop_fd *u, unsigned int events)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* request handler spawned a pipe, register handler */
|
||||||
|
if (cl->pipe.fd)
|
||||||
|
{
|
||||||
|
D("SRV: Client(%d) pipe(%d) spawned\n", u->fd, cl->pipe.fd);
|
||||||
|
|
||||||
|
cl->pipe.cb = uh_pipe_cb;
|
||||||
|
uloop_fd_add(&cl->pipe, ULOOP_READ);
|
||||||
|
}
|
||||||
|
|
||||||
/* request handler spawned a child, register handler */
|
/* request handler spawned a child, register handler */
|
||||||
if (cl->proc.pid)
|
if (cl->proc.pid)
|
||||||
{
|
{
|
||||||
@ -701,7 +719,6 @@ static void uh_client_cb(struct uloop_fd *u, unsigned int events)
|
|||||||
/* header processing complete */
|
/* header processing complete */
|
||||||
D("SRV: Client(%d) dispatched\n", u->fd);
|
D("SRV: Client(%d) dispatched\n", u->fd);
|
||||||
cl->dispatched = true;
|
cl->dispatched = true;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!cl->cb(cl))
|
if (!cl->cb(cl))
|
||||||
|
@ -160,6 +160,7 @@ struct client {
|
|||||||
SSL *tls;
|
SSL *tls;
|
||||||
#endif
|
#endif
|
||||||
struct uloop_fd fd;
|
struct uloop_fd fd;
|
||||||
|
struct uloop_fd pipe;
|
||||||
struct uloop_process proc;
|
struct uloop_process proc;
|
||||||
struct uloop_timeout timeout;
|
struct uloop_timeout timeout;
|
||||||
bool (*cb)(struct client *);
|
bool (*cb)(struct client *);
|
||||||
|
Loading…
Reference in New Issue
Block a user