diff options
author | Eric Wong <e@yhbt.net> | 2011-01-16 05:09:57 +0000 |
---|---|---|
committer | Eric Wong <e@yhbt.net> | 2011-01-16 05:09:57 +0000 |
commit | 8a5fc89a0d84fe9f35f3afa207762b783f673df2 (patch) | |
tree | 309c3c08acdb4d28fb9fd251234ad6e1ff8ca796 | |
parent | 7e3fa56ad3078fd980f12acf6d1344582a9aafef (diff) | |
download | sleepy_penguin-8a5fc89a0d84fe9f35f3afa207762b783f673df2.tar.gz |
We don't want to end up accidentally splitting arrays for the same epoll file descriptor since they'll be linked.
-rw-r--r-- | ext/sleepy_penguin/epoll.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/ext/sleepy_penguin/epoll.c b/ext/sleepy_penguin/epoll.c index 6454692..b8cfa3a 100644 --- a/ext/sleepy_penguin/epoll.c +++ b/ext/sleepy_penguin/epoll.c @@ -124,7 +124,7 @@ static VALUE alloc(VALUE klass) self = Data_Make_Struct(klass, struct rb_epoll, gcmark, gcfree, ep); ep->fd = -1; ep->io = Qnil; - ep->marks = rb_ary_new(); + ep->marks = Qnil; ep->capa = step; ep->flags = EPOLL_CLOEXEC; ep->events = xmalloc(sizeof(struct epoll_event) * ep->capa); @@ -145,6 +145,7 @@ static void my_epoll_create(struct rb_epoll *ep) rb_sys_fail("epoll_create1"); } st_insert(active, (st_data_t)ep->fd, (st_data_t)ep); + ep->marks = rb_ary_new(); } static void ep_check(struct rb_epoll *ep) @@ -521,7 +522,9 @@ static VALUE init_copy(VALUE copy, VALUE orig) NIL_P(b->io) && "Ruby broken?"); ep_check(a); + assert(NIL_P(b->marks) && "mark array not nil"); b->marks = a->marks; + assert(TYPE(b->marks) == T_ARRAY && "mark array not initialized"); b->flags = a->flags; b->fd = cloexec_dup(a); if (b->fd == -1) { |