H
hellerim
My program runs as a Windows service (on WinXP SP3) monitoring several
devices connected via serial or network ports. It writes out an XML file
periodically which summarizes the current state of the connected devices.
This file then is served by IIS (5.0) to several MMI instances running in a
browser (MSIE 7). These applications request the XML data file also
periodically, about once per second. Evidently there is concurrency possible
between IIS and the the Windows service. The latter writes the state
information to a temporary file. Once finished doing this, it deletes the
existing XML file requested by the MMI clients and moves the temporary file
to its place. This is implemented so to keep the time window where
concurrency may occur as small as possible. Anyway, access collisions do
happen. On the client side I receive HTTP server status 200, 40X, and 500
which is fine and can be handled well by the MMI code. However it bothers me
that there are intermittent authentication dialogs popping up which is
inacceptable (not only to my customer). Since the client is authorized by
Windows this behavior does not make any sense. I suppose that one of the
concurrency scenarios is handled the wrong way by IIS in that an Unauthorized
Access Error is incorrectly stated, probably when the temporary file is being
moved to its target location and IIS tries to open it. May be that this
incorrect interpretation resides deep down inside the Win32 file handling
routines. As a workaround I implemented an ASPX file which is requested by
the MMI code instead of the XML file. Here, some C# code loops until the XML
file can be opened or the loop counter exceeds some threshold value; in
either case, data is written to the response stream. It works fine for me: No
authentication dialog was seen any more in the MMI.
I had no time to check this in other environments.
I suspect this is a bug report but don't know where to post it. Since I
found a similar phenomenon when trying to access a serial port in .NET while
it was being used by another process (an UnauthorizedAccessException is
thrown), I posted as similar question in the .NET General area.
devices connected via serial or network ports. It writes out an XML file
periodically which summarizes the current state of the connected devices.
This file then is served by IIS (5.0) to several MMI instances running in a
browser (MSIE 7). These applications request the XML data file also
periodically, about once per second. Evidently there is concurrency possible
between IIS and the the Windows service. The latter writes the state
information to a temporary file. Once finished doing this, it deletes the
existing XML file requested by the MMI clients and moves the temporary file
to its place. This is implemented so to keep the time window where
concurrency may occur as small as possible. Anyway, access collisions do
happen. On the client side I receive HTTP server status 200, 40X, and 500
which is fine and can be handled well by the MMI code. However it bothers me
that there are intermittent authentication dialogs popping up which is
inacceptable (not only to my customer). Since the client is authorized by
Windows this behavior does not make any sense. I suppose that one of the
concurrency scenarios is handled the wrong way by IIS in that an Unauthorized
Access Error is incorrectly stated, probably when the temporary file is being
moved to its target location and IIS tries to open it. May be that this
incorrect interpretation resides deep down inside the Win32 file handling
routines. As a workaround I implemented an ASPX file which is requested by
the MMI code instead of the XML file. Here, some C# code loops until the XML
file can be opened or the loop counter exceeds some threshold value; in
either case, data is written to the response stream. It works fine for me: No
authentication dialog was seen any more in the MMI.
I had no time to check this in other environments.
I suspect this is a bug report but don't know where to post it. Since I
found a similar phenomenon when trying to access a serial port in .NET while
it was being used by another process (an UnauthorizedAccessException is
thrown), I posted as similar question in the .NET General area.