mirror of
https://github.com/winfsp/winfsp.git
synced 2025-07-03 17:32:57 -05:00
dll: fuse: fix daemonization problem on Cygwin
The new FUSE loop use a Windows event (LoopEvent) to signal loop exit. Prior to this commit the Windows event was created outside the FUSE loop and potentially before daemonization (on Cygwin). This means that the event was created in a different process and WaitForMultipleObjects was failing with ERROR_ACCESS_DENIED. This commit ensures that the LoopEvent is created inside the FUSE loop and therefore in the daemonized process.
This commit is contained in:
@ -53,6 +53,10 @@ static NTSTATUS fsp_fuse_loop_start(struct fuse *f)
|
||||
struct fuse_conn_info conn;
|
||||
NTSTATUS Result;
|
||||
|
||||
f->LoopEvent = CreateEventW(0, TRUE, FALSE, 0);
|
||||
if (0 == f->LoopEvent)
|
||||
goto fail;
|
||||
|
||||
context = fsp_fuse_get_context(f->env);
|
||||
if (0 == context)
|
||||
{
|
||||
@ -239,6 +243,12 @@ static void fsp_fuse_loop_cleanup(struct fuse *f)
|
||||
f->ops.destroy(f->data);
|
||||
f->fsinit = FALSE;
|
||||
}
|
||||
|
||||
if (0 != f->LoopEvent)
|
||||
{
|
||||
CloseHandle(f->LoopEvent);
|
||||
f->LoopEvent = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static NTSTATUS fsp_fuse_loop_internal(struct fuse *f)
|
||||
@ -264,11 +274,15 @@ static NTSTATUS fsp_fuse_loop_internal(struct fuse *f)
|
||||
}
|
||||
|
||||
/* if either the service thread dies or our event gets signaled, stop the loop */
|
||||
WaitObjects[0] = fsp_fuse_svcthread;
|
||||
WaitObjects[1] = f->LoopEvent;
|
||||
WaitResult = WaitForMultipleObjects(2, WaitObjects, FALSE, INFINITE);
|
||||
if (WAIT_OBJECT_0 != WaitResult && WAIT_OBJECT_0 + 1 != WaitResult)
|
||||
Result = FspNtStatusFromWin32(GetLastError());
|
||||
Result = STATUS_SUCCESS;
|
||||
if (!f->exited)
|
||||
{
|
||||
WaitObjects[0] = fsp_fuse_svcthread;
|
||||
WaitObjects[1] = f->LoopEvent;
|
||||
WaitResult = WaitForMultipleObjects(2, WaitObjects, FALSE, INFINITE);
|
||||
if (WAIT_OBJECT_0 != WaitResult && WAIT_OBJECT_0 + 1 != WaitResult)
|
||||
Result = FspNtStatusFromWin32(GetLastError());
|
||||
}
|
||||
|
||||
fsp_fuse_loop_stop(f);
|
||||
|
||||
|
Reference in New Issue
Block a user