Comment 194 for bug 553745

Comment on attachment 60179
reference event sources before calling timeout handler to ensure events stay valid for loop iteration.

Review of attachment 60179:

::: src/libply/ply-event-loop.c
@@ +1296,5 @@
> + {
> + ply_event_source_t *source;
> + source = (ply_event_source_t *) (events[i].data.ptr);
> +
> + ply_event_source_take_reference (source);

we can't just take the reference inside the loop, since the loop may get called repeatedly because of EINTR. We could explicitly check for EINTR and not take the reference in that case, I guess. We do need to ensure events don't get dispatched after they are no longer being watched, but I think we should still be okay. The source is going to stick around, now, but the destination will still get free'd at stop_watching_fd time, so the source will in effect be orphaned and harmless.