Can TWebModule instance shutdown itself?
-
I have an ISAPI application with a TWebModule running on IIS6. There's try/except and fine exception logging around every method. Every single request and it's response status are also being logged. About five times a week this happens: 1) TWebModule.OnException is called with "EInOutError: File not found". Mostly the error is logged by just one thread, sometimes by up to four threads at once. (The cause must be outside my code, because there are no lines outside try/except blocks.) 2) For a few minutes IIS answers thousands of request with status 500, though they are not logged by the ISAPI DLL. That means, the requests don't cause more exceptions in the TWebModule instances, they seem to just bounce off my IIS. 3) Finally there's a message in the event log that one worker process did not recycle in time. 4) For a day or two, everything runs fine again. I guess the TWebModule instance is in some kind of blocked state, but IIS still tries to feed it with requests. So, I want to stop the thread in TWebModule.OnException. Is there a way to shutdown a single TWebModule, that means one IIS thread or worker process, without recycling the whole Application Pool? Thanks a lot, Corinna
-
I have an ISAPI application with a TWebModule running on IIS6. There's try/except and fine exception logging around every method. Every single request and it's response status are also being logged. About five times a week this happens: 1) TWebModule.OnException is called with "EInOutError: File not found". Mostly the error is logged by just one thread, sometimes by up to four threads at once. (The cause must be outside my code, because there are no lines outside try/except blocks.) 2) For a few minutes IIS answers thousands of request with status 500, though they are not logged by the ISAPI DLL. That means, the requests don't cause more exceptions in the TWebModule instances, they seem to just bounce off my IIS. 3) Finally there's a message in the event log that one worker process did not recycle in time. 4) For a day or two, everything runs fine again. I guess the TWebModule instance is in some kind of blocked state, but IIS still tries to feed it with requests. So, I want to stop the thread in TWebModule.OnException. Is there a way to shutdown a single TWebModule, that means one IIS thread or worker process, without recycling the whole Application Pool? Thanks a lot, Corinna
Hi, Corinna, I don't have experience with Delphi on server side, so the following response might be useless to your case. The description makes me still wondering if the threads were crashed by unhandled exception from inside your codes. Just want to make sure there is no such code as XYZ.Create() left outside the try/except or try/finally blocks, as some Delphi components throw exceptions during construction.
-
Hi, Corinna, I don't have experience with Delphi on server side, so the following response might be useless to your case. The description makes me still wondering if the threads were crashed by unhandled exception from inside your codes. Just want to make sure there is no such code as XYZ.Create() left outside the try/except or try/finally blocks, as some Delphi components throw exceptions during construction.
Thanks for your reply! There are some .Create() lines in the main unit, before the TWebModule is created. But if they would crash, the web module's handler woudln't catch them, because, well, it doesn't exist, yet. The DLL uses the library "Graphics32". I don't think it starts any threads on its own, but it creates many objects. It is only called inside try/except block, of course. It also uses some Named Pipes to talk to a Windows service running on the same machine. But the crashes occur mostly during request that do not touch those pipes, so they cannot be the cause. Anyway, the ISAPI application answers between 2 and 4 million requests per day. The EInOutException happens only once or twice a day. When I repeat the failed request later on, it works fine again. That makes it quite tricky to find out what exactly happens.
-
I have an ISAPI application with a TWebModule running on IIS6. There's try/except and fine exception logging around every method. Every single request and it's response status are also being logged. About five times a week this happens: 1) TWebModule.OnException is called with "EInOutError: File not found". Mostly the error is logged by just one thread, sometimes by up to four threads at once. (The cause must be outside my code, because there are no lines outside try/except blocks.) 2) For a few minutes IIS answers thousands of request with status 500, though they are not logged by the ISAPI DLL. That means, the requests don't cause more exceptions in the TWebModule instances, they seem to just bounce off my IIS. 3) Finally there's a message in the event log that one worker process did not recycle in time. 4) For a day or two, everything runs fine again. I guess the TWebModule instance is in some kind of blocked state, but IIS still tries to feed it with requests. So, I want to stop the thread in TWebModule.OnException. Is there a way to shutdown a single TWebModule, that means one IIS thread or worker process, without recycling the whole Application Pool? Thanks a lot, Corinna
Hi Corinna, As you suggest, it definitely sounds to me like there is some kind of resource and/or thread blocking happening, and those are not exactly the nicest to try figure out. Although your code/threads may not be responsible/guilty of the blocking, it is unfortunately something that can become a much bigger problem later on :(. Are you executing any other (custom or not) threads as well?
Cheers, Glen Vlotman "You cannot code for stupidity"
-
Hi Corinna, As you suggest, it definitely sounds to me like there is some kind of resource and/or thread blocking happening, and those are not exactly the nicest to try figure out. Although your code/threads may not be responsible/guilty of the blocking, it is unfortunately something that can become a much bigger problem later on :(. Are you executing any other (custom or not) threads as well?
Cheers, Glen Vlotman "You cannot code for stupidity"
The reason why I am asking if you are using your own threads is you can send a message to all your threads to terminate when you get that exception from TWebModule. Just so you know the module will stop. If you need any pointers on how you would need to do that, let me know.
Cheers, Glen Vlotman "You cannot code for stupidity"
-
I have an ISAPI application with a TWebModule running on IIS6. There's try/except and fine exception logging around every method. Every single request and it's response status are also being logged. About five times a week this happens: 1) TWebModule.OnException is called with "EInOutError: File not found". Mostly the error is logged by just one thread, sometimes by up to four threads at once. (The cause must be outside my code, because there are no lines outside try/except blocks.) 2) For a few minutes IIS answers thousands of request with status 500, though they are not logged by the ISAPI DLL. That means, the requests don't cause more exceptions in the TWebModule instances, they seem to just bounce off my IIS. 3) Finally there's a message in the event log that one worker process did not recycle in time. 4) For a day or two, everything runs fine again. I guess the TWebModule instance is in some kind of blocked state, but IIS still tries to feed it with requests. So, I want to stop the thread in TWebModule.OnException. Is there a way to shutdown a single TWebModule, that means one IIS thread or worker process, without recycling the whole Application Pool? Thanks a lot, Corinna
-
Have you managed to figure out where the issue was Corinna?
Cheers, Glen Vlotman "You cannot code for stupidity"
I solved the problem, but not the question of this thread. :-D Last week I found out that my TWebModules crashed in a logging and clean-up sequence after sending a fine response. I still don't know why that got them into a blocked state until IIS killed them, but since I changed the logging the exceptions are gone. :doh: Thanks for all the help! :rose:
This statement is false.
-
I solved the problem, but not the question of this thread. :-D Last week I found out that my TWebModules crashed in a logging and clean-up sequence after sending a fine response. I still don't know why that got them into a blocked state until IIS killed them, but since I changed the logging the exceptions are gone. :doh: Thanks for all the help! :rose:
This statement is false.
Glad to hear that your problem has been resolved. You can 'force' a thread to terminate using a few techniques. One which I found that works quite well is enabling your thread to listen for a custom message. Once it receives that message the thread can then call the terminate process (and perform whatever cleanups it needs of course). Hope that helps :)
Cheers, Glen Vlotman "You cannot code for stupidity"