void connection_close(connection_t *c) { ev_io_stop(c->loop, &c->read_watcher); ev_io_stop(c->loop, &c->write_watcher); ev_timer_stop(c->loop, &c->timeout_watcher); close(c->fd); shutdown(c->fd, SHUT_RDWR); buffer_reset(&c->read_buffer); buffer_reset(&c->write_buffer); /* tell Ruby GC vars are not used anymore */ rb_gc_unregister_address(&c->env); rb_gc_unregister_address(&c->input); /* kill the thread if still running */ if (c->thread.active) { c->backend->thread_count--; rb_thread_kill(c->thread.obj); } /* put back in the queue of unused connections */ queue_push(&c->backend->connections, c); }
static VALUE rb_thread_s_kill(VALUE obj, SEL sel, VALUE th) { if (!rb_obj_is_kind_of(th, rb_cThread)) { rb_raise(rb_eTypeError, "wrong argument type %s (expected Thread)", rb_obj_classname(th)); } return rb_thread_kill(th, 0); }
static void kill_waiting_threads(List *waiting) { Entry *entry; for (entry = waiting->entries; entry; entry = entry->next) { rb_thread_kill(entry->value); } }
static VALUE rb_thread_exit(void) { return rb_thread_kill(rb_vm_current_thread(), 0); }
static VALUE SysExit2(VALUE dummy) { VALUE thread = rb_thread_current(); DECR_REG(thread); rb_thread_kill(thread); return Qnil; }