Theseus has asked for the wisdom of the Perl Monks concerning the following question:

I'm writing a CGI application that uses an Access database through DBI:ODBC, and running on Windows 2000 Advanced Server with IIS 5.

Here's the problem, the program executes fine and finishes, but the HTTP request never seems to time out. Internet Explorer never "gives up" on retrieving the page. On the server, the perl process is still running, and the instant I terminate it, the browser stops seeking and stops. The problem is, I have inserted both exit and die commands into my script(when using exit, there is no error text, when using die, the browser prints what line the script died at after it's previous output), and they still do not terminate the perl process.

When I take all the database-related commands(remove the connect string and every command referencing the $dbh or $sth handles after that), the program executes perfectly.

The changes I make to the database are going through and committing(I've tried this with and without AutoCommit on), the process just isn't terminating when it should. Can anyone offer any help?

Replies are listed 'Best First'.
Re: CGI just won't die...
by johnny_carlos (Scribe) on Jun 10, 2002 at 23:32 UTC
    Are you executing a $dhh->disconnect after you're done with using the db?

    I would suggest running your script using the debugger to find out where it is hanging up.

    from the command line:
    perl -wd script_name.cgi

    If you have query string parameters you can send them in as command line args:
    perl -wd script_name.cgi name=value name2=value

    The n key will step thru your program line by line, s will step into a subroutine. You should easily be able to find the line causing the problem that way. Check the docs for the debugger, it's the way to go.

    hth,
    john
      Yes, I'm using $dbh->disconnect, which is returning 1. I've tried running the script from the server and it executes fine and the process terminates like it should. It's only giving me a problem when IIS is running the process. Does anyone have any idea what this might be?
Re: CGI just won't die...
by Theseus (Pilgrim) on Jun 11, 2002 at 13:56 UTC
    Another new development... When I switch the server to use perlis.dll rather than perl.exe to handle perl scripts, it terminates correctly just as it does when run from a command line on the server.

    However, I can't use perlis.dll because ISAPI doesn't pass enough information to my scripts as CGI does($ENV{'REMOTE_USER'} is critical to me). Anyone have any ideas based on this new information?

    Another thing worth noting is that this does not happen all the time, just most of the time. About 20% of the time the process will terminate normally, it's the other 80% that it hangs. It's not spiking the CPU on the server, the process just hangs there using 0% CPU until the server timeout hits.