Skip to content
This repository has been archived by the owner on May 4, 2018. It is now read-only.

fsevents: fix clever rescheduling #946

Closed
wants to merge 1 commit into from
Closed

fsevents: fix clever rescheduling #946

wants to merge 1 commit into from

Conversation

indutny
Copy link
Contributor

@indutny indutny commented Oct 2, 2013

There're could be a situation, where one fsevents handle gets created
and another one is destroyed simultaneously. In such cases
fsevent_need_reschedule will be set to 1 twice and reset only once,
leaving handle destructor hanging in uv_sem_wait().

se nodejs/node-v0.x-archive#6296

/cc @bnoordhuis

@indutny
Copy link
Contributor Author

indutny commented Oct 2, 2013

Added test.

TEST_IMPL(fs_event_start_and_close) {
uv_loop_t* loop;
static uv_fs_event_t fs_event1;
static uv_fs_event_t fs_event2;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why static?

There're could be a situation, where one fsevents handle gets created
and another one is destroyed simultaneously. In such cases
`fsevent_need_reschedule` will be set to 1 twice and reset only once,
leaving handle destructor hanging in uv_sem_wait().
@indutny
Copy link
Contributor Author

indutny commented Oct 2, 2013

Fixed all nits, and improved patch to keep clever hack working.

if (!state->fsevent_need_reschedule)
return;
uv_mutex_lock(&state->fsevent_mutex);
if (state->fsevent_need_reschedule == 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My comment about fsevent_need_reschedule still stands. It doesn't need to be volatile anymore, right?

@bnoordhuis
Copy link
Contributor

One comment but otherwise LGTM.

@indutny indutny closed this Oct 2, 2013
@indutny indutny deleted the fix/node-gh-6296 branch October 2, 2013 17:55
@indutny
Copy link
Contributor Author

indutny commented Oct 5, 2013

Landed in master in 429bb80.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants