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: John_Erjavec at cargill dot com
Subject: problem with custom callback functions
Date: Mar 2 1999 5:07PM

All-

Has anyone run into weird callback problems before?  Here is what is going on 
with mine.  When I run the program with the callback functions, I get the 
following error message:

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Start of ASE 11.9.2 upgrade.
Step 3 -- Dropping LynxSP.
Use of uninitialized value at ./rssd_1192_upgrade.spl line 163,  chunk
        1 (#1)
    
    (W) An undefined value was used as if it were already defined.  It was
    interpreted as a "" or a 0, but maybe it was a mistake.  To suppress this
    warning assign an initial value to your variables.
    
ct_cmd_alloc failed at ./rssd_1192_upgrade.spl line 163,  chunk 1.

Open Client Message: (In msg_cb)
Message number: LAYER = (1) ORIGIN = (1) SEVERITY = (1) NUMBER = (60)
Message String: ct_con_drop(): user api layer: external error: There is a usage 
error.  This routine has been called at an illegal time.

Could not open a connection to DS_RSSD:  at ./rssd_1192_upgrade.spl line 163, 
 chunk 1.
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Here are the callback functions:

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
sub msg_cb {
    my($layer, $origin, $severity, $number, $msg, $osmsg) = @_;

    my $client_msg = sprintf "\nOpen Client Message: (In msg_cb)\n";
    $client_msg .= sprintf "Message number: LAYER = (%ld) ORIGIN = (%ld) ",
            $layer, $origin;
    $client_msg .= sprintf "SEVERITY = (%ld) NUMBER = (%ld)\n",
            $severity, $number;
    $client_msg .= sprintf "Message String: %s\n", $msg;
    if (defined($osmsg)) {
        $client_msg .= sprintf "Operating System Error: %s\n",
                $osmsg;
    }

    if (( $number == 6 ) || ( $number == 50 )) {
        log_this($client_msg);

        CS_SUCCEED;
        return;
    }

    print STDERR $client_msg, "\n";

    CS_SUCCEED;
}

sub srv_cb {
    my($cmd, $number, $severity, $state, $line, $server, $proc, $msg) = @_;

#    my $server_msg = qq/
#Server message: (In srv_cb)
#Message number: $number, Severity $severity,
#State $state, Line $line
#/;
#
#    if (defined($server)) {
#        $server_msg .= qq/Server '$server'
#/;
#    }
#
#    if (defined($proc)) {
#        $server_msg .= qq/Procedure '$proc'
#/;
#    }
#
#    $server_msg .= /Message String: $msg/;

#   $DB::trace = 1;

    my $server_msg = sprintf "\nServer message: (In srv_cb)\n";
    $server_msg .= sprintf "Message number: %ld, Severity %ld, ",
               $number, $severity;
    $server_msg .= sprintf "State %ld, Line %ld\n",
               $state, $line;

    if (defined($server)) {
        $server_msg .= sprintf "Server '%s'\n", $server;
    }

    if (defined($proc)) {
        $server_msg .= sprintf " Procedure '%s'\n", $proc;
    }

    $server_msg .= sprintf "Message String: %s\n", $msg;

    if (( $number == 4966 ) || ( $number == 4972 )) {
        send_to_both($server_msg);

        CS_SUCCEED;
        return;
    }

    if (( $number == 5701 ) || ( $number == 0 ) || ( $number == 18422 )) {
        CS_SUCCEED;
        return;
    }

    if (( $number == 5005 ) || ( $number == 6006 ) ||
        ( $number == 5702 ) || ( $number == 5874 )) {
        log_this($server_msg);

        CS_SUCCEED;
        return;
    }

    print STDERR $server_msg, "\n";

    CS_SUCCEED;
}
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

I have diagnostics turned on, and -w turned on.  All variables in the script 
seem to either be defined, or are checked (with the same checking as in the 
default callback functions from the man page) before use.  When making the 
callback message string, I took the default callback functions, and just changed
them to sprintf from printf.  Anyone have any ideas?

-JEV
-- 
John Erjavec V
john_erjavec@cargill.com
Cargill, Inc.