The script Sample.php is :
<html>
<body>
<?
// error handler function
// this function NEVER RETURN (all errors are FATAL) !!
function myErrorHandler($errno,$ErrorMsg)
{ echo $ErrorMsg,'</body></html>';
exit(); // global exit of PHP
}
//MAIN PGM:
// set to the user defined error handler
set_error_handler('myErrorHandler');
$connect_id=sybase_connect('server,'GenRe','password');
if (!$connect_id)
echo "An error in sybase_connect !!<br>";
else
{ $res=sybase_query('select * from toto',$connect_id);
// code never reached !
if (!$res)
echo "An error in sybase_query !!<br>";
else
echo 'No error';
}
?>
</html>
</body>
Before I display Sample.php I try a sp_who command on Sybase. The result is
:
1> sp_who
2> go
fid spid status loginame origname hostname blk_spid
dbname cmd block_xloid
------ ------ ------------ ------------ ------------ ---------- --------
---------- ---------------- -----------
0 2 sleeping NULL NULL 0
master NETWORK HANDLER 0
0 3 sleeping NULL NULL 0
master DEADLOCK TUNE 0
0 4 sleeping NULL NULL 0
master MIRROR HANDLER 0
0 5 sleeping NULL NULL 0
master ASTC HANDLER 0
0 6 sleeping NULL NULL 0
master CHECKPOINT SLEEP 0
0 7 sleeping NULL NULL 0
master HOUSEKEEPER 0
0 12 recv sleep sa sa WinNT 0
CPC_V0 AWAITING COMMAND 0
0 15 recv sleep sa sa WinNT 0
CPC_V0 AWAITING COMMAND 0
0 17 running sa sa WinNT 0
CPC_V0 SELECT 0
(9 rows affected)
(return status = 0)
It seems OK !
After one display of Sample.php the sp_who become :
1> sp_who
2> go
fid spid status loginame origname hostname blk_spid
dbname cmd block_xloid
------ ------ ------------ ------------ ------------ ---------- --------
---------- ---------------- -----------
0 2 sleeping NULL NULL 0
master NETWORK HANDLER 0
0 3 sleeping NULL NULL 0
master DEADLOCK TUNE 0
0 4 sleeping NULL NULL 0
master MIRROR HANDLER 0
0 5 sleeping NULL NULL 0
master ASTC HANDLER 0
0 6 sleeping NULL NULL 0
master CHECKPOINT SLEEP 0
0 7 sleeping NULL NULL 0
master HOUSEKEEPER 0
0 12 recv sleep sa sa WinNT 0
CPC_V0 AWAITING COMMAND 0
0 15 recv sleep sa sa WinNT 0
CPC_V0 AWAITING COMMAND 0
0 17 running sa sa WinNT 0
CPC_V0 SELECT 0
0 19 recv sleep GenRe GenRe 0
CPC_V0 AWAITING COMMAND 0
(10 rows affected)
(return status = 0)
And you can see the last user in state "recv sleep" still here, even if the
PHP script is dead.
As intended PHP have produced :
<html>
<body>
Sybase: Server message: toto not found. Specify owner.objectname or use
sp_help to check whether the object exists (sp_help may produce lots of
output).
(severity 16, procedure N/A)</body></html>
It wouldn't be very harmful if PHP doesn't try, later, to use this "recv
sleep" connexion again !
If I display (refresh) Sample.php a few time, the sp_who give me :
1> sp_who
2> go
fid spid status loginame origname hostname blk_spid
dbname cmd block_xloid
------ ------ ------------ ------------ ------------ ---------- --------
---------- ---------------- -----------
0 2 sleeping NULL NULL 0
master NETWORK HANDLER 0
0 3 sleeping NULL NULL 0
master DEADLOCK TUNE 0
0 4 sleeping NULL NULL 0
master MIRROR HANDLER 0
0 5 sleeping NULL NULL 0
master ASTC HANDLER 0
0 6 sleeping NULL NULL 0
master CHECKPOINT SLEEP 0
0 7 sleeping NULL NULL 0
master HOUSEKEEPER 0
0 11 recv sleep GenRe GenRe 0
CPC_V0 AWAITING COMMAND 0
0 12 recv sleep sa sa WinNT 0
CPC_V0 AWAITING COMMAND 0
0 13 recv sleep GenRe GenRe 0
CPC_V0 AWAITING COMMAND 0
0 14 recv sleep GenRe GenRe 0
CPC_V0 AWAITING COMMAND 0
0 15 recv sleep sa sa WinNT 0
CPC_V0 AWAITING COMMAND 0
0 16 recv sleep GenRe GenRe 0
CPC_V0 AWAITING COMMAND 0
0 17 running sa sa WinNT 0
CPC_V0 SELECT 0
0 19 recv sleep GenRe GenRe 0
CPC_V0 AWAITING COMMAND 0
(14 rows affected)
(return status = 0)
You can see we now have 5 "recv sleep" connexions with the user GenRe. And
PHP is set up to keep only 5 Sybase connexion. So one more refresh of
Sample.php produce the output :
<html>
<body>
Sybase: Unable to allocate connection record</body></html>
And now, all the Sybase access will abort with this error the only way to
unlock PHP is to kill and restart it.
PS. please forgive my bad English, and thanks for your support.
-----Message d'origine-----
De : Bug Database [mailto:[EMAIL PROTECTED]]
Envoyé : jeudi 19 avril 2001 22:03
À : [EMAIL PROTECTED]
Objet : Bug #10408 Updated: Bad Sybase-CTlib closing
ID: 10408
Updated by: joey
Reported By: [EMAIL PROTECTED]
Old-Status: Open
Status: Feedback
Bug Type: Sybase-ct (ctlib) related
PHP Version: 4.0.4pl1
Assigned To:
Comments:
Cannot duplicate this locally, can you provide more info?
Previous Comments:
---------------------------------------------------------------------------
[2001-04-19 15:18:52] [EMAIL PROTECTED]
if you run this script :
<html>
<body>
<?
// error handler function
// this function NEVER RETURN (all errors are FATAL) !!
function myErrorHandler($errno,$ErrorMsg)
{ global $connect_id;
echo $ErrorMsg,'</body></html>'; // I want to see this one
!!!
exit(); // global exit of php
}
//MAIN PGM:
// set to the user defined error handler
set_error_handler('myErrorHandler');
$connect_id=sybase_connect('MyServer','MyLogin','MyPassword');
if (!$connect_id)
echo "An error in sybase_query !!<br>"; // I don't want to see this
message
else
{ $res=sybase_query('select * from toto',$connect_id);
if (!$res)
echo "An error in sybase_query !!<br>"; // I don't want to
see this message too
else
echo 'No error';
}
?>
</html>
</body>
and that the table toto doesn't exist you trigger the myErrorHandler and the
script terminate as intended. The problem is that Sybase doesn't seem aware
of this and the process will live forever even if it doesn't allow Sybase
query any more. So if you run this script a few times all the processes will
be sleeping and you will no more be able to make a Sybase query. I think
there is a problem in the way you handle the Sybase connexion in a error
handler with an exit() call.
---------------------------------------------------------------------------
ATTENTION! Do NOT reply to this email!
To reply, use the web interface found at
http://bugs.php.net/?id=10408&edit=2
--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]