|
@@ -551,24 +551,10 @@ disconnect:
|
|
|
return nwrite;
|
|
return nwrite;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-static void hio_close_event_cb(hevent_t* ev) {
|
|
|
|
|
- hio_t* io = (hio_t*)ev->userdata;
|
|
|
|
|
- uint32_t id = (uintptr_t)ev->privdata;
|
|
|
|
|
- if (io->id != id) return;
|
|
|
|
|
- hio_close(io);
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
int hio_close (hio_t* io) {
|
|
int hio_close (hio_t* io) {
|
|
|
if (io->closed) return 0;
|
|
if (io->closed) return 0;
|
|
|
if (hv_gettid() != io->loop->tid) {
|
|
if (hv_gettid() != io->loop->tid) {
|
|
|
- hevent_t ev;
|
|
|
|
|
- memset(&ev, 0, sizeof(ev));
|
|
|
|
|
- ev.cb = hio_close_event_cb;
|
|
|
|
|
- ev.userdata = io;
|
|
|
|
|
- ev.privdata = (void*)(uintptr_t)io->id;
|
|
|
|
|
- ev.priority = HEVENT_HIGH_PRIORITY;
|
|
|
|
|
- hloop_post_event(io->loop, &ev);
|
|
|
|
|
- return 0;
|
|
|
|
|
|
|
+ return hio_close_async(io);
|
|
|
}
|
|
}
|
|
|
hrecursive_mutex_lock(&io->write_mutex);
|
|
hrecursive_mutex_lock(&io->write_mutex);
|
|
|
if (!write_queue_empty(&io->write_queue) && io->error == 0 && io->close == 0) {
|
|
if (!write_queue_empty(&io->write_queue) && io->error == 0 && io->close == 0) {
|