in reply to Re: DBD::mysql with a forked processes caused lost MySQL connection unless mysql_auto_reconnect is set?
in thread DBD::mysql with a forked processes caused lost MySQL connection unless mysql_auto_reconnect is set?

But all of my objects are constructed after the fork?
  • Comment on Re: Re: DBD::mysql with a forked processes caused lost MySQL connection unless mysql_auto_reconnect is set?

Replies are listed 'Best First'.
Re: Re: Re: DBD::mysql with a forked processes caused lost MySQL connection unless mysql_auto_reconnect is set?
by perrin (Chancellor) on Jan 25, 2004 at 00:31 UTC
    Your code does a "use TEST" before the fork, which will compile TEST and run all of the code in TEST's "main" section, including the part that opens a db connection.
      Ahhh, so...

      I should be able to fix this by simply moving the use inside of the fork? That doesn't seem to work. I guess even if the use is inside of wakeup() it's still being compiled before forking? Seems I'm a bit confused on what's happening under the covers when forking. Time to do some reading, any suggestions?

      or I can move the db connection call out of the "main" section of TEST.pm. That does work.

      Cool, thanks for the help perrin.

        The reason that moving the "use" doesn't work is that use is evaluated as if it were inside a BEGIN block. If you switch to "require", that will work, but you will have to call import as well. See "perldoc -f use" for more.