#include "tls.h"
static LIST_HEAD(clients);
+static bool client_done = false;
int n_clients = 0;
struct config conf = {};
char *str;
int len;
+ client_done = false;
do {
str = ustream_get_read_buf(us, &len);
if (!str || !len)
uh_header_error(cl, 413, "Request Entity Too Large");
break;
}
- } while(1);
+ } while (!client_done);
}
static void client_close(struct client *cl)
{
+ if (cl->refcount) {
+ cl->state = CLIENT_STATE_CLEANUP;
+ return;
+ }
+
+ client_done = true;
n_clients--;
uh_dispatch_done(cl);
uloop_timeout_cancel(&cl->timeout);
{
struct ustream *s = cl->us;
- if (!s->write_error) {
+ if (!s->write_error && cl->state != CLIENT_STATE_CLEANUP) {
if (cl->state == CLIENT_STATE_DATA)
return;