01-06-05 22.16, skrev Jenda Krynicky p� [EMAIL PROTECTED] f�ljande:
>>> What does it do if you fork with DBI?
>>>
>>> Here under Win2k+iThreads it crashes even if I use the
>>> handle only in parent thread. I guess some properties are objects as
>>> well.
>>
>> Sorry has in common with, the same problem applies to fork().
>>
>> Why does it crash, I mean if it isn't used in two threads it should crash?
>> What DBD?
>
> DBD::ODBC
>
> It crashes when both threads die. Seems that again the cleanup of
> one thread rendered it unusable even in the other and than second
> cleanup crashes the process.
>
> And
> bless $dbh, 'non_se_ns_e';
> doesn't help at all in this case.
>
> The script is pretty simple :
> ================
> use DBI;
>
> $dbh = DBI->connect( 'dbi:ODBC:jobodbc' , 'sa', 'sa');
>
> if (fork()) {
>
> $sth = $dbh->prepare("SELECT * FROM jendatest");
>
> $sth->execute();
>
> while ( @row = $sth->fetchrow_array ) {
> print "@row\n";
> }
> }
> ================
> Crashes immediately. (Memory protection error.)
>
> If I add
> } else {
> sleep(5);
> }
> it prints the data, waits a few secs and crashes.
>
> } else {
> bless $dbh, 'dfghfghdfgh';
> sleep(5);
> }
> does the same.
>
> Actualy since if I add "undef $dbh;" after the bless it waits as well
> I guess I was wrong.
>
> The reason is not that the $dbh object contains some object
> with external data.
>
> It seems that the DBI->connect() created some global objects that are
> causing this problem.
>
> Do these thing happen under Unix+normal fork() as well?
> Even if I exec() immediately after fork()?
>
I cc this to dbi-dev (if this is wrong please tell me somone on dbi-dev)
I don't know how DBD::ODBC works but this does not crash using DBD::mysql on
linux atleast. It should certinaly not happen if you exec(). (No global
destruction is run then afaik). I guess the problem is that you are
connecting before the fork, do you still crash if you create it inside the
fork? Can we get a backtrace of the crash?
Artur