We have an application that monitors remote directories for change notifications using
ReadDirectoryChangesW() . According to Microsoft documentation, each outstanding change notification request consumes a "work item" resource on the server. I have a test which monitors hundreds of directories, on a Windows Server 2003 (32-bit) machine. It fails consistently when the number of directories is above a certain value, around 120, at which point an event is logged on the server saying something like:
The server was unable to allocate a work item 2 times in the last 60 seconds.
When this happens, the connection is dropped, and perfmon shows that a "Work Item Shortage" has occurred.
Articles here and there indicate that the number of work items can be increased by setting the MaxWorkItems registry key. However, it's unclear to me whether this applies to Windows Server 2003. I've tried setting this key (along with MaxMpxCt) to higher values, on the order of several thousand, and restarting the Server service (and also rebooting). However, perfmon always shows "Available Work Items" to be somewhere in the neighborhood of 120-160. When I run my test program, this number drops, predictably, until it hits zero, a shortage is logged, and the connection to my client is dropped.
My question is: Can I affect the number of available work items in my setup, and if so, how? And can I also do this for other versions of Windows we might be using (i.e. Server 2008, etc.)?
For the record, I've also tried playing with MinFreeWorkItems, InitWorkItems, MaxRawWorkItems, and MaxCmds, all to no avail.