Skip to content

Commit

Permalink
Lazy write-watcher initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
stash committed Sep 20, 2010
1 parent b91a95a commit 4d5015f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
9 changes: 5 additions & 4 deletions Feersum.xs
Expand Up @@ -433,13 +433,9 @@ new_feer_conn (EV_P_ int conn_fd)
trace("prep_socket failed for %d\n", c->fd);
}

// TODO: these initializations should be Lazy
ev_io_init(&c->read_ev_io, try_conn_read, conn_fd, EV_READ);
c->read_ev_io.data = (void *)c;

ev_io_init(&c->write_ev_io, try_conn_write, conn_fd, EV_WRITE);
c->write_ev_io.data = (void *)c;

ev_init(&c->read_ev_timer, conn_read_timeout);
c->read_ev_timer.repeat = read_timeout;
c->read_ev_timer.data = (void *)c;
Expand Down Expand Up @@ -990,6 +986,11 @@ conn_write_ready (struct feer_conn *c)
{
if (c->in_callback) return; // defer until out of callback

if (c->write_ev_io.data == NULL) {
ev_io_init(&c->write_ev_io, try_conn_write, c->fd, EV_WRITE);
c->write_ev_io.data = (void *)c;
}

if (!ev_is_active(&c->write_ev_io)) {
#if AUTOCORK_WRITES
ev_io_start(feersum_ev_loop, &c->write_ev_io);
Expand Down
2 changes: 0 additions & 2 deletions TODO
Expand Up @@ -31,8 +31,6 @@ Handle requests that don't require a body (optional entities).
start (not sure if there's a PSGI-compatible way to do this)
* different request timeout logic will be needed.

Lazy I/O watcher initialization?

Per-client "drain" and "completion" callbacks?

* drain sorta done as the $w->poll_cb()
Expand Down

0 comments on commit 4d5015f

Please sign in to comment.