Browse Source

Handle write errors (fixes ab keep-alive problems)

personal/stbuehler/wip
Stefan Bühler 14 years ago
parent
commit
1ed36c93b9
  1. 27
      src/connection.c
  2. 2
      src/lighttpd.c
  3. 1
      src/network.c
  4. 2
      src/request.c

27
src/connection.c

@ -61,7 +61,7 @@ static void connection_cb(struct ev_loop *loop, ev_io *w, int revents) {
if (revents & EV_READ) {
if (con->in->is_closed) {
/* don't read the next request before current one is done */
ev_io_set(w, w->fd, w->events && ~EV_READ);
ev_io_rem_events(loop, w, EV_READ);
} else {
switch (network_read(srv, con, w->fd, con->raw_in)) {
case NETWORK_STATUS_SUCCESS:
@ -91,9 +91,30 @@ static void connection_cb(struct ev_loop *loop, ev_io *w, int revents) {
if (revents & EV_WRITE) {
if (con->raw_out->length > 0) {
network_write(srv, con, w->fd, con->raw_out);
switch (network_write(srv, con, w->fd, con->raw_out)) {
case NETWORK_STATUS_SUCCESS:
dojoblist = TRUE;
break;
case NETWORK_STATUS_FATAL_ERROR:
connection_set_state(srv, con, CON_STATE_ERROR);
dojoblist = TRUE;
break;
case NETWORK_STATUS_CONNECTION_CLOSE:
connection_set_state(srv, con, CON_STATE_CLOSE);
dojoblist = TRUE;
break;
case NETWORK_STATUS_WAIT_FOR_EVENT:
break;
case NETWORK_STATUS_WAIT_FOR_AIO_EVENT:
/* TODO ? */
ev_io_rem_events(loop, w, EV_WRITE);
break;
case NETWORK_STATUS_WAIT_FOR_FD:
/* TODO */
ev_io_rem_events(loop, w, EV_WRITE);
break;
}
// CON_TRACE(srv, con, "cq->len: raw_out=%i, out=%i", (int) con->raw_out->length, (int) con->out->length);
dojoblist = TRUE;
}
if (con->raw_out->length == 0) {
// CON_TRACE(srv, con, "%s", "stop write");

2
src/lighttpd.c

@ -110,7 +110,7 @@ int main(int argc, char *argv[]) {
TRACE(srv, "%s", "Test!");
//srv->log_stderr = log_new(srv, LOG_TYPE_FILE, g_string_new("lightytest.log"));
/* srv->log_stderr = log_new(srv, LOG_TYPE_FILE, g_string_new("lightytest.log")); */
log_write_(srv, NULL, LOG_LEVEL_WARNING, "test %s", "foo1");
log_warning(srv, NULL, "test %s", "foo1"); /* duplicate won't be logged */
log_warning(srv, NULL, "test %s", "foo2");

1
src/network.c

@ -108,7 +108,6 @@ network_status_t network_read(server *srv, connection *con, int fd, chunkqueue *
}
g_string_truncate(buf, r);
chunkqueue_append_string(cq, buf);
CON_TRACE(srv, con, "read (%i) '%s'", (int) r, buf->str);
len += r;
} while (r == blocksize && len < max_read);

2
src/request.c

@ -99,7 +99,7 @@ void request_validate_header(server *srv, connection *con) {
return;
} else if (hh) {
g_string_append_len(req->host, GSTR_LEN((GString*) g_queue_peek_head(&hh->values)));
CON_TRACE(srv, con, "hostname: '%s'", req->host->str);
// CON_TRACE(srv, con, "hostname: '%s'", req->host->str);
}
/* content-length */

Loading…
Cancel
Save