sunos: handle disabled watcher after callback

Fix a potential use-after-free bug where the uv__io watcher struct is
referenced after being disabled by its callback function. The stress
is on 'potential' because in practice the watcher's memory is not
released until the next tick of the event loop.
This commit is contained in:
Ben Noordhuis 2013-05-06 11:31:43 +02:00
parent ebdeaed2e3
commit 4a8ec0c622

View File

@ -189,6 +189,9 @@ void uv__io_poll(uv_loop_t* loop, int timeout) {
w->cb(loop, w, pe->portev_events);
nevents++;
if (w != loop->watchers[fd])
continue; /* Disabled by callback. */
/* Events Ports operates in oneshot mode, rearm timer on next run. */
if (w->pevents != 0 && QUEUE_EMPTY(&w->watcher_queue))
QUEUE_INSERT_TAIL(&loop->watcher_queue, &w->watcher_queue);