Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Fork() does not work with win32::ODBC connections

by Anonymous Monk
on Jul 08, 2000 at 01:03 UTC ( [id://21581]=perlquestion: print w/replies, xml ) Need Help??

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

I can't fork my socket after I connect to a database. Why? What can I do?
  • Comment on Fork() does not work with win32::ODBC connections

Replies are listed 'Best First'.
Re: Fork() does not work with win32::ODBC connections
by Corion (Patriarch) on Jul 08, 2000 at 13:08 UTC

    fork() support under Win32 is still very experimental, as Win32 does not support forking natively. The current implementation of fork() does mostly copy the whole data section of the current process and starts it as a second process as far as I know. This means that you will have an issue with all kinds of handles that are not directly supported by Win32 for inter-process sharing. File handles and socket handles are inheritable by child processes, but ODBC handles are not (or so it seems in your case).

    It seems you have two possibilities now, either do away with fork() or do away with Win32::ODBC.

    To do away with fork(), you could write yourself a server process that works as a database server and holds one ODBC handle open. But you'd then have to do asynchronous ODBC accesses and have an event driven server, both of which are hard to implement. Perl threads would maybe help a bit with the asynchronous ODBC accesses, but I don't even know whether ODBC allows more than one running query per connection.

    To do away with Win32::ODBC, you could switch to MS SQL server or mySQL, both of which have Perl modules availabe for them, and as both of the connectors work via sockets (as far as I remember), you even might be able to inherit them via fork().

Re: Fork() does not work with win32::ODBC connections
by Shendal (Hermit) on Jul 08, 2000 at 01:10 UTC
    Since you must be on NT, I would say that you must be running activestate's 5.6 version of perl. Previous versions did not support fork. That said, I've found that support of fork in the latest version is tenuous at best, and may or may not work for your application. AFAIK, it's just betaware now.
RE: Without fork() print to not the NS does not work.
by jcwren (Prior) on Jul 11, 2000 at 05:01 UTC
    OK. Besides lacking -w and use strict, what is this doing that you're asking for advice on? There's no reference to fork() anywhere in this code, that I can find, other than in a print statement. And what exactly is a 'NS'?

    I don't mean to be rude, but without an explanation of the problem, it's somewhat unlikely that significant time would be spent chasing down a problem that's not clearly defined.

    --Chris

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://21581]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (1)
As of 2024-04-25 01:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found