client: fix spurious keepalive connection timeouts
[project/uhttpd.git] / client.c
index b5736e4b00fbd2bd66784b5b551ff2051ccb36f6..6233d01cd43508c6a9f15026985da21abead8cce 100644 (file)
--- a/client.c
+++ b/client.c
@@ -396,6 +396,7 @@ void client_poll_post_data(struct client *cl)
 {
        struct dispatch *d = &cl->dispatch;
        struct http_request *r = &cl->request;
+       enum client_state st;
        char *buf;
        int len;
 
@@ -460,10 +461,13 @@ void client_poll_post_data(struct client *cl)
        buf = ustream_get_read_buf(cl->us, &len);
        if (!r->content_length && !r->transfer_chunked &&
                cl->state != CLIENT_STATE_DONE) {
+               st = cl->state;
+
                if (cl->dispatch.data_done)
                        cl->dispatch.data_done(cl);
 
-               cl->state = CLIENT_STATE_DONE;
+               if (cl->state == st)
+                       cl->state = CLIENT_STATE_DONE;
        }
 }