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: Followup to SybPerl 2.09_01 on HP-UX 10.10
Date: Mar 10 1998 5:23PM

Dan Johansson wrote:
> 
> I've done some more checking and what I've found is the following:
> IF I comment out the following two lines in ./CTlib/t/vtlib.t
> ct_callback(CS_CLIENTMSG_CB, \&msg_cb); and
> ct_callback(CS_SERVERMSG_CB, \&srv_cb);
> 
> the test passes. If I on the other hand run the testscript with
> perl -w -d I'm getting the following output:

Here's a patch that should fix it:

diff -c -r sybperl-2.09_01/CTlib/CTlib.xs sybperl-2.09_02/CTlib/CTlib.xs
*** sybperl-2.09_01/CTlib/CTlib.xs	Thu Mar  5 16:35:15 1998
--- sybperl-2.09_02/CTlib/CTlib.xs	Tue Mar 10 09:08:31 1998
***************
*** 1,5 ****
  /* -*-C-*-
!  *	@(#)CTlib.xs	1.32	03/05/98
   */
  
  
--- 1,5 ----
  /* -*-C-*-
!  *	@(#)CTlib.xs	1.33	03/10/98
   */
  
  
***************
*** 107,112 ****
--- 107,113 ----
      HV *hv;
  
      HV *magic;
+     SV *handle;
  
      struct _con_info *next;
  } ConInfo;
***************
*** 424,430 ****
  
      rv = newRV((SV*)hv);
      stash = gv_stashpv(package, TRUE);
!     sv = sv_bless(rv, stash);
          
      return sv;
  }
--- 425,431 ----
  
      rv = newRV((SV*)hv);
      stash = gv_stashpv(package, TRUE);
!     info->handle = sv = sv_bless(rv, stash);
          
      return sv;
  }
***************
*** 1470,1476 ****
  		return CS_FAIL;
  	    }
  
! 	    New(902, info, 1, ConInfo);
  	    if((hv = perl_get_hv("Sybase::CTlib::_refCon", FALSE)))
  	    {
  		if((svp = hv_fetch(hv, (char*)connection, sizeof(connection), 0)))
--- 1471,1477 ----
  		return CS_FAIL;
  	    }
  
! 	    Newz(902, info, 1, ConInfo);
  	    if((hv = perl_get_hv("Sybase::CTlib::_refCon", FALSE)))
  	    {
  		if((svp = hv_fetch(hv, (char*)connection, sizeof(connection), 0)))
***************
*** 1633,1639 ****
      if((sv = perl_get_sv("Sybase::CTlib::Version", TRUE|GV_ADDMULTI)))
      {
  	char buff[256];
! 	sprintf(buff, "This is sybperl, version %s\n\nSybase::CTlib version
1.32 03/05/98\n\nCopyright (c) 1995-1997 Michael Peppler\nPortions
Copyright (c) 1995 Sybase, Inc.\n\n",
  		SYBPLVER);
  	sv_setnv(sv, atof(SYBPLVER));
  	sv_setpv(sv, buff);
--- 1634,1640 ----
      if((sv = perl_get_sv("Sybase::CTlib::Version", TRUE|GV_ADDMULTI)))
      {
  	char buff[256];
! 	sprintf(buff, "This is sybperl, version %s\n\nSybase::CTlib version
1.33 03/10/98\n\nCopyright (c) 1995-1997 Michael Peppler\nPortions
Copyright (c) 1995 Sybase, Inc.\n\n",
  		SYBPLVER);
  	sv_setnv(sv, atof(SYBPLVER));
  	sv_setpv(sv, buff);
***************
*** 5286,5292 ****
  	SV *	attr
    CODE:
  {
!     ConInfo *info;
      RefCon *refCon;
      CS_CONNECTION *connection = NULL;
      CS_COMMAND *cmd;
--- 5287,5293 ----
  	SV *	attr
    CODE:
  {
!     ConInfo *info = NULL;
      RefCon *refCon;
      CS_CONNECTION *connection = NULL;
      CS_COMMAND *cmd;
***************
*** 5362,5367 ****
--- 5363,5375 ----
  
      if (retcode == CS_SUCCEED)
      {
+ 	/* make sure that CS_USERDATA for this connection is NULL - needed
+ 	   because servermsg_cb is called when the connection is made */
+ 	if((retcode = ct_con_props(connection, CS_SET, CS_USERDATA,
+ 				   &info, CS_SIZEOF(info), NULL)) != CS_SUCCEED)
+ 	{
+ 	    warn("ct_con_props(CS_USERDATA) failed");
+ 	}
  	len = (server == NULL || !*server) ? 0 : CS_NULLTERM;
  	retcode = ct_connect(connection, server, len);
      }
***************
*** 5554,5562 ****
--- 5562,5577 ----
  
  	if((hv = perl_get_hv("Sybase::CTlib::_refCon", FALSE)))
  	    hv_delete(hv, (char *)refCon->connection,
sizeof(refCon->connection), 0);
+ 
+ 	/* only destroy the extra attributes hash if this is the
+ 	   last handle for this connection */
+ 	hv_undef(info->connection->attr.other);
+ 
  	if(debug_level & TRACE_DESTROY)
  	    warn("[In DESTROY] Freeing refCon");
  	Safefree(refCon);
+ 
+ 	//hv_undef(info->magic);
      }
      
      if(info->numCols)
***************
*** 5568,5574 ****
  	    warn("[In DESTROY] Freeing datafmt");
  	Safefree(info->datafmt);
      }
-     hv_undef(info->connection->attr.other);
      hv_undef(info->hv);
      av_undef(info->av);
      if(debug_level & TRACE_DESTROY)


Michael