do not reset .notify_write on request done
[project/uhttpd.git] / client.c
index d1584f9..3163afc 100644 (file)
--- a/client.c
+++ b/client.c
@@ -73,6 +73,8 @@ static void uh_dispatch_done(struct client *cl)
 {
        if (cl->dispatch.free)
                cl->dispatch.free(cl);
+       if (cl->dispatch.req_free)
+               cl->dispatch.req_free(cl);
 }
 
 static void client_timeout(struct uloop_timeout *timeout)
@@ -108,7 +110,6 @@ void uh_request_done(struct client *cl)
 {
        uh_chunk_eof(cl);
        uh_dispatch_done(cl);
-       cl->us->notify_write = NULL;
        memset(&cl->dispatch, 0, sizeof(cl->dispatch));
 
        if (!conf.http_keepalive || cl->request.connection_close)
@@ -193,6 +194,9 @@ static bool client_init_cb(struct client *cl, char *buf, int len)
        if (!newline)
                return false;
 
+       if (newline == buf)
+               return true;
+
        *newline = 0;
        blob_buf_init(&cl->hdr, 0);
        cl->state = client_parse_request(cl, buf);
@@ -486,14 +490,14 @@ void uh_client_notify_state(struct client *cl)
 
 static void client_ustream_read_cb(struct ustream *s, int bytes)
 {
-       struct client *cl = container_of(s, struct client, sfd);
+       struct client *cl = container_of(s, struct client, sfd.stream);
 
        uh_client_read_cb(cl);
 }
 
 static void client_ustream_write_cb(struct ustream *s, int bytes)
 {
-       struct client *cl = container_of(s, struct client, sfd);
+       struct client *cl = container_of(s, struct client, sfd.stream);
 
        if (cl->dispatch.write_cb)
                cl->dispatch.write_cb(cl);
@@ -501,7 +505,7 @@ static void client_ustream_write_cb(struct ustream *s, int bytes)
 
 static void client_notify_state(struct ustream *s)
 {
-       struct client *cl = container_of(s, struct client, sfd);
+       struct client *cl = container_of(s, struct client, sfd.stream);
 
        uh_client_notify_state(cl);
 }