+ io_set(io, 0);
+
+ splay_unlink_node(&io_tree, &io->node);
+ io->cb = NULL;
+}
+
+void timeout_add(timeout_t *timeout, timeout_cb_t cb, void *data, struct timeval *tv) {
+ timeout->cb = cb;
+ timeout->data = data;
+ timeout->node.data = timeout;
+
+ timeout_set(timeout, tv);
+}
+
+void timeout_set(timeout_t *timeout, struct timeval *tv) {
+ if(timerisset(&timeout->tv))
+ splay_unlink_node(&timeout_tree, &timeout->node);
+
+ if(!now.tv_sec)
+ gettimeofday(&now, NULL);
+
+ timeradd(&now, tv, &timeout->tv);
+
+ if(!splay_insert_node(&timeout_tree, &timeout->node))
+ abort();
+}
+
+void timeout_del(timeout_t *timeout) {
+ if(!timeout->cb)