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
include $(TOPDIR)/rules.mk
PKG_NAME:=uhttpd
include $(TOPDIR)/rules.mk
PKG_NAME:=uhttpd
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
PKG_CONFIG_DEPENDS := \
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
PKG_CONFIG_DEPENDS := \
memset(state, 0, sizeof(*state));
state->cl = cl;
memset(state, 0, sizeof(*state));
state->cl = cl;
+ state->cl->pipe.fd = rfd[0];
state->cl->proc.pid = child;
/* close unneeded pipe ends */
state->cl->proc.pid = child;
/* close unneeded pipe ends */
memset(state, 0, sizeof(*state));
state->cl = cl;
memset(state, 0, sizeof(*state));
state->cl = cl;
+ state->cl->pipe.fd = rfd[0];
state->cl->proc.pid = child;
/* close unneeded pipe ends */
state->cl->proc.pid = child;
/* close unneeded pipe ends */
if (cur->proc.pid)
uloop_process_delete(&cur->proc);
if (cur->proc.pid)
uloop_process_delete(&cur->proc);
+ if (cur->pipe.fd)
+ uloop_fd_delete(&cur->pipe);
+
uloop_fd_delete(&cur->fd);
close(cur->fd.fd);
uloop_fd_delete(&cur->fd);
close(cur->fd.fd);
*max_fd = max(*max_fd, sock);
l->fd.cb = uh_listener_cb;
*max_fd = max(*max_fd, sock);
l->fd.cb = uh_listener_cb;
- uloop_fd_add(&l->fd, ULOOP_READ | ULOOP_WRITE);
+ uloop_fd_add(&l->fd, ULOOP_READ);
if ((cl = uh_client_add(new_fd, serv)) != NULL)
{
/* add client socket to global fdset */
if ((cl = uh_client_add(new_fd, serv)) != NULL)
{
/* 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
/* setup client tls context */
#ifdef HAVE_TLS
/* setup client tls context */
+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)
{
struct client *cl = container_of(p, struct client, proc);
static void uh_child_cb(struct uloop_process *p, int rv)
{
struct client *cl = container_of(p, struct client, proc);
+ /* 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 */
if (cl->proc.pid)
{
/* request handler spawned a child, register handler */
if (cl->proc.pid)
{
/* header processing complete */
D("SRV: Client(%d) dispatched\n", u->fd);
cl->dispatched = true;
/* header processing complete */
D("SRV: Client(%d) dispatched\n", u->fd);
cl->dispatched = true;
SSL *tls;
#endif
struct uloop_fd fd;
SSL *tls;
#endif
struct uloop_fd fd;
struct uloop_process proc;
struct uloop_timeout timeout;
bool (*cb)(struct client *);
struct uloop_process proc;
struct uloop_timeout timeout;
bool (*cb)(struct client *);