From f9f833d7a7c5927339f0317af514915a8b5442b9 Mon Sep 17 00:00:00 2001 From: Hiroshi Hatake Date: Tue, 5 Mar 2024 18:27:27 +0900 Subject: [PATCH] subscribe: Add comments to describe what WaitForSingleObject does Signed-off-by: Hiroshi Hatake --- ext/winevt/winevt_subscribe.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ext/winevt/winevt_subscribe.c b/ext/winevt/winevt_subscribe.c index 8c58342..8946582 100644 --- a/ext/winevt/winevt_subscribe.c +++ b/ext/winevt/winevt_subscribe.c @@ -357,6 +357,12 @@ rb_winevt_subscribe_next(VALUE self) return Qfalse; } + /* If a signalEvent notifies a failure, raise + * SubscribeHandlerError to detect stale subscription. + * Note that we don't need to wait explicitly here. + * Because this function is inside of each enumerator. + * So, WaitForSingleObject should return immediately and should be + * processed with the latter each loop if there is no more items. */ dwWait = WaitForSingleObject(winevtSubscribe->signalEvent, 0); if (dwWait == WAIT_FAILED) { raise_system_error(rb_eSubscribeHandlerError, GetLastError());