Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Delphi
  4. Can TWebModule instance shutdown itself?

Can TWebModule instance shutdown itself?

Scheduled Pinned Locked Moved Delphi
windows-adminhelpquestion
8 Posts 3 Posters 12 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    Corinna John
    wrote on last edited by
    #1

    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

    S N 3 Replies Last reply
    0
    • C Corinna John

      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

      S Offline
      S Offline
      smags13
      wrote on last edited by
      #2

      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.

      C 1 Reply Last reply
      0
      • S smags13

        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.

        C Offline
        C Offline
        Corinna John
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0
        • C Corinna John

          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

          N Offline
          N Offline
          nortee
          wrote on last edited by
          #4

          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"

          N 1 Reply Last reply
          0
          • N nortee

            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"

            N Offline
            N Offline
            nortee
            wrote on last edited by
            #5

            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"

            1 Reply Last reply
            0
            • C Corinna John

              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

              N Offline
              N Offline
              nortee
              wrote on last edited by
              #6

              Have you managed to figure out where the issue was Corinna?

              Cheers, Glen Vlotman "You cannot code for stupidity"

              C 1 Reply Last reply
              0
              • N nortee

                Have you managed to figure out where the issue was Corinna?

                Cheers, Glen Vlotman "You cannot code for stupidity"

                C Offline
                C Offline
                Corinna John
                wrote on last edited by
                #7

                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.

                N 1 Reply Last reply
                0
                • C Corinna John

                  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.

                  N Offline
                  N Offline
                  nortee
                  wrote on last edited by
                  #8

                  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"

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups