PEPPLER.ORG
Michael Peppler
Sybase Consulting
Menu
Home
Sybase on Linux
Install Guide for Sybase on Linux
General Sybase Resources
General Perl Resources
Freeware
Sybperl
Sybase::Simple
DBD::Sybase
BCP Tool
Bug Tracker
Mailing List Archive
Downloads Directory
FAQs
Sybase on Linux FAQ
Sybperl FAQ
Personal
Michael Peppler's resume

sybperl-l Archive

Up    Prev    Next    

From: Michael Peppler <mpeppler at MBAY dot NET>
Subject: Re: Syperl and perl 5.004_56 using threads
Date: Jan 30 1998 3:19PM

Srinivas Desirazu wrote:
> 
> I am trying to use the above version with Sybperl 2.09.  I have System
> 11 sybase libraries.  I have a couple of questions.
> 
> 1.  What should the CTLIBVS and DBLIBVS be set to  in  CONFIG

CTLIBVS=100
DBLIBVS=1000

> 2.  Should CS_VERSION_100 be changed in the .xs file

No.

> 
> This setup works fine if I have only one thread.  If I use
> more than one thread I get the following error

Sybperl isn't thread-safe. You must use a mutex around any call
into sybperl. I have not played with this at all, so I don't know
what other things might break - use at your own risk :-)

Michael


> 
> ct_fetch() returned an unexpected retcode at /tmp/sybtest.pl line 32.
> 
> Open Client Message: (In msg_cb)
> Message number: LAYER = (5) ORIGIN = (3) SEVERITY = (5) NUMBER = (6)
> Message String: ct_close(): network packet layer: internal net library error: Net-Lib protocol driver call to read data failed
> Operating System Error: TLI recv call failed - t_errno 4
> Attempt to free unreferenced scalar at /tmp/sybtest.pl line 37.
> 
> Is is possible to use threaded perl with sybperl ?
> 
> Here is sybtest.pl
> 
> use Thread;
> 
> use Sybase::CTlib;
> 
> ct_callback(CS_CLIENTMSG_CB, \&msg_cb);
> ct_callback(CS_SERVERMSG_CB, "srv_cb");
> 
> sub thread_cb {
>     local $server = "RMBILL101_S_1";
> 
>     local $dbh = Sybase::CTlib->ct_connect('blu3dbo', "bluefish", $server);
> 
>     local $sql_cmd = "select * from ADMINIST where fund_code = '1100109765'";
> 
>     my $rc = $dbh->ct_execute($sql_cmd) || die;;
> 
>     die if (! $rc);
>     while(($rc = $::dbh->ct_results($restype)) == CS_SUCCEED)
>     {
>         next if ($restype == CS_CMD_DONE ||
>                  $restype == CS_CMD_FAIL ||
>                  $restype == CS_CMD_SUCCEED);
> 
>         while(@data = $::dbh->ct_fetch)
>         {
>             print "@data" . "\n";
>         }
>     }
> }
> 
> local @thread;
> for($i=0; $i<2; $i++) {
>     $thread[$count] = new Thread (\&thread_cb);
> 
> }
> 
> sub msg_cb
> {
>     my($layer, $origin, $severity, $number, $msg, $osmsg) = @_;
> 
>     printf STDERR "\nOpen Client Message: (In msg_cb)\n";
>     printf STDERR "Message number: LAYER = (%ld) ORIGIN = (%ld) ",
>             $layer, $origin;
>     printf STDERR "SEVERITY = (%ld) NUMBER = (%ld)\n",
>             $severity, $number;
>     printf STDERR "Message String: %s\n", $msg;
>     if (defined($osmsg))
>     {
>         printf STDERR "Operating System Error: %s\n",
>                 $osmsg;
>     }
>     CS_SUCCEED;
> }
> 
> sub srv_cb
> {
>     my($cmd, $number, $severity, $state, $line, $server, $proc, $msg) = @_;
> 
>     printf STDERR "\nServer message: (In srv_cb)\n";
>     printf STDERR "Message number: %ld, Severity %ld, ",
>                $number, $severity;
>     printf STDERR "State %ld, Line %ld\n",
>                $state, $line;
> 
>     if (defined($server))
>     {
>         printf STDERR "Server '%s'\n", $server;
>     }
> 
>     if (defined($proc))
>     {
>         printf STDERR " Procedure '%s'\n", $proc;
>     }
> 
>     printf STDERR "Message String: %s\n", $msg;
>                                 #
>     CS_SUCCEED;
> }
> 
> 
> Thanks for any help.
> 
> Srinivas.

-- 
Michael Peppler       -||-  Data Migrations Inc.
mpeppler@datamig.com  -||-  http://www.mbay.net/~mpeppler