Re: [PATCH v6 16/28] fsmonitor--daemon: stub in health thread
- From
- Jeff Hostetler <git@jeffhostetler.com>
- Date
- May 17, 2022, 19:48 UTC
- Message-ID
- <d2c909df-44f6-bc2c-ebbc-13ea51cf62fe@jeffhostetler.com>
- In-Reply-To
- <nycvar.QRO.7.76.6.2205121622030.352@tvgsbejvaqbjf.bet>
On 5/12/22 11:05 AM, Johannes Schindelin wrote:
Show 9 quoted lines
> Hi Jeff, > > On Fri, 22 Apr 2022, Jeff Hostetler via GitGitGadget wrote: > >> From: Jeff Hostetler <jeffhost@microsoft.com> >> >> Create another thread to watch over the daemon process and >> automatically shut it down if necessary. >>
[...]
Show 6 quoted lines
>> The platform-specific code for Windows sets up enough of the >> WaitForMultipleObjects() machinery to watch for system and/or custom >> events. Currently, the set of wait handles only includes our custom >> shutdown event (sent from our other theads). Later commits in this >> series will extend the set of wait handles to monitor other >> conditions.
[...]
Show 23 quoted lines
>> diff --git a/compat/fsmonitor/fsm-health-win32.c b/compat/fsmonitor/fsm-health-win32.c
>> new file mode 100644
>> index 00000000000..94b1d020f25
>> --- /dev/null
>> +++ b/compat/fsmonitor/fsm-health-win32.c
>> @@ -0,0 +1,72 @@
>> +#include "cache.h"
>> +#include "config.h"
>> +#include "fsmonitor.h"
>> +#include "fsm-health.h"
>> +#include "fsmonitor--daemon.h"
>> +
>> +struct fsm_health_data
>> +{
>> + HANDLE hEventShutdown;
>> +
>> + HANDLE hHandles[1]; /* the array does not own these handles */
>> +#define HEALTH_SHUTDOWN 0
>
> How about defining `HANDLE hHandles[HEALTH_SHUTDOWN + 1]` to indicate that
> the constant is used as an offset into `hHandles`?
>
>> + int nr_handles; /* number of active event handles */I think I'd like to keep this one as is. It matches the style that I used in `fsm-listen-win32.c` where I have 3 listener handles.
Granted, it does look a little odd when there is only 1 handle in the array. But the idea was to allow new handles to be added as we want to watch more things.
It might be clearer (in both of them) to define the array in terms of an enum rather than a local list of #define's. But I'm not sure it matters.
Jeff