struct blob_attr *data = cl->hdr.head;
struct env_var *vars = (void *) uh_buf;
struct blob_attr *tb[__HDR_MAX];
+ const char *url;
int len;
int i;
+ url = blobmsg_data(blob_data(cl->hdr.head));
len = ARRAY_SIZE(proc_header_env);
len += ARRAY_SIZE(extra_vars);
len *= sizeof(struct env_var);
extra_vars[VAR_SCRIPT_FILE].value = pi->phys;
extra_vars[VAR_DOCROOT].value = pi->root;
extra_vars[VAR_QUERY].value = pi->query ? pi->query : "";
- extra_vars[VAR_REQUEST].value = req->url;
+ extra_vars[VAR_REQUEST].value = url;
extra_vars[VAR_PROTO].value = http_versions[req->version];
extra_vars[VAR_METHOD].value = http_methods[req->method];
extra_vars[VAR_PATH_INFO].value = pi->info;
uh_relay_free(&cl->dispatch.proc.r);
}
+static void proc_write_close(struct client *cl)
+{
+ shutdown(cl->dispatch.proc.r.sfd.fd.fd, SHUT_WR);
+}
+
+static void proc_relay_write_cb(struct ustream *us, int bytes)
+{
+ struct client *cl = container_of(us, struct client, dispatch.proc.r.sfd.stream);
+
+ if (ustream_pending_data(us, true))
+ return;
+
+ cl->dispatch.data_blocked = false;
+ us->notify_write = NULL;
+ client_poll_post_data(cl);
+}
+
+static void proc_relay_write_close_cb(struct ustream *us, int bytes)
+{
+ struct client *cl = container_of(us, struct client, dispatch.proc.r.sfd.stream);
+
+ if (ustream_pending_data(us, true))
+ return;
+
+ proc_write_close(cl);
+}
+
+static void proc_data_send(struct client *cl, const char *data, int len)
+{
+ struct ustream *us = &cl->dispatch.proc.r.sfd.stream;
+
+ ustream_write(us, data, len, false);
+ if (ustream_pending_data(us, true)) {
+ cl->dispatch.data_blocked = true;
+ us->notify_write = proc_relay_write_cb;
+ }
+}
+
+static void proc_data_done(struct client *cl)
+{
+ struct ustream *us = &cl->dispatch.proc.r.sfd.stream;
+
+ if (ustream_pending_data(us, true)) {
+ us->notify_write = proc_relay_write_close_cb;
+ return;
+ }
+
+ proc_write_close(cl);
+}
+
bool uh_create_process(struct client *cl, struct path_info *pi,
void (*cb)(struct client *cl, struct path_info *pi, int fd))
{
uh_relay_open(cl, &cl->dispatch.proc.r, fds[0], pid);
d->free = proc_free;
d->close_fds = proc_close_fds;
+ d->data_send = proc_data_send;
+ d->data_done = proc_data_done;
d->proc.r.header_cb = proc_handle_header;
d->proc.r.header_end = proc_handle_header_end;
d->proc.r.close = proc_handle_close;