ok that was wrong, disconnect http clients whne we're done sending or upon error, not immediately after queueing everything.

This commit is contained in:
Joris Vink 2013-05-30 21:57:14 +02:00
parent ca1c884e43
commit bb4001d119
2 changed files with 11 additions and 17 deletions

View File

@ -40,6 +40,7 @@
#include "http.h"
static int http_post_data_recv(struct netbuf *);
static int http_send_done(struct netbuf *);
int
http_request_new(struct connection *c, struct spdy_stream *s, char *host,
@ -187,7 +188,7 @@ http_response(struct http_request *req, int status, u_int8_t *d, u_int32_t len)
net_send_queue(req->owner, htext, hlen, 0, NULL, NULL);
free(htext);
net_send_queue(req->owner, d, len, 0, NULL, NULL);
net_send_queue(req->owner, d, len, 0, NULL, http_send_done);
}
return (KORE_RESULT_OK);
@ -439,3 +440,10 @@ http_post_data_recv(struct netbuf *nb)
return (KORE_RESULT_OK);
}
static int
http_send_done(struct netbuf *nb)
{
/* disconnects. */
return (KORE_RESULT_ERROR);
}

View File

@ -388,17 +388,8 @@ kore_server_final_disconnect(struct connection *c)
return;
}
if (!TAILQ_EMPTY(&(c->send_queue)))
return;
if (c->ssl != NULL) {
if (SSL_shutdown(c->ssl) == 0) {
pthread_mutex_unlock(&(c->lock));
return;
}
if (c->ssl != NULL)
SSL_free(c->ssl);
}
kore_log("kore_server_final_disconnect(%p) succeeded", c);
TAILQ_REMOVE(&disconnected, c, list);
@ -513,10 +504,6 @@ kore_connection_handle(struct connection *c, int flags)
}
break;
case CONN_STATE_DISCONNECTING:
if (c->flags & CONN_WRITE_POSSIBLE) {
if (!net_send_flush(c))
return (KORE_RESULT_ERROR);
}
break;
default:
kore_log("unknown state on %d (%d)", c->fd, c->state);
@ -591,8 +578,7 @@ kore_worker_entry(void *arg)
if (r != KORE_RESULT_ERROR) {
r = net_send_flush(req->owner);
if (r == KORE_RESULT_ERROR ||
req->owner->proto == CONN_PROTO_HTTP)
if (r == KORE_RESULT_ERROR)
kore_server_disconnect(req->owner);
} else {
kore_server_disconnect(req->owner);