# Compiler flags.
CC=gcc
CC=/usr/local/bin/gcc
CC=/usr/local/bin/sparc-sun-solaris2.8-gcc
CC=${GCCPATH}
LD=/usr/ccs/bin/ld
CFLAGS="-D_REENTRANT -L${GCCLIBPATH} -lnsl -lsmq -lstdc++ -lsocket -lrt -lpthread -I/opt/ar/gemsdev/api/include -I/opt/ar/sdi/sonic_adapter/SonicCClient6.1-FCS/Solaris_GCC/include -Ilibxml -I/opt/ar/sdi/libxml2/libxml2-2.6.30/include"
LDFLAGS="-G"
CPPFLAGS="-I/tmp/TSO1 -I/usr/include"
LDLIBS="-lnsl -lw -lpthread -lxml2"
$CC $CPPFLAGS $CFLAGS -DUNIX -D$ARCHTYPE -I$SMQROOT/include -L$SMQROOT/bin/$BUILDMODE $LDLIBS $LDFLAGS -o $1.so $1.c
exit
============================================
The shared lib is loaded as a multithreaded plugin in a daemon on Solaris 10.
The problem is that when the code in the attached file runs for the second time it crashes at line 44. The first run has no problems.
Any pointers? Please help.
Thanks in advance,
Arthur
//Allocate mem for valueOperandPtr->u.value.u.charVal -
//which holds an XML string to be sent out to the external service
sdiRequest=(char *)malloc(strlen(valueOperandPtr->u.value.u.charVal)+1);
/* NOTE : Had to add "<" in front of the XML value
sent in from the form as the value of the search since Remedy
strips the leading <. Most likely thinking it was an operator*/
sprintf(sdiRequest,"<%s",valueOperandPtr->u.value.u.charVal);
len=strlen(sdiRequest);
sdiRequestDoc = xmlReadMemory(sdiRequest, len, "noname0.xml", NULL, 0);
if (doc == NULL)
{
free(sdiRequest);
return AddErrorMessage(status, AR_RETURN_ERROR,
PLUGIN_ERROR_GENERIC,
"Request sent in is not a well formed XML");
}
Request();
iInitRun=0;
sdiRequest=talker(sdiRequest);
Release();
ARPluginLogging(AR_PLUGIN_LOG_INFO, "Eval");
if (sdiRequest == NULL)
{
free(sdiRequest);
return AddErrorMessage(status, AR_RETURN_ERROR,
PLUGIN_ERROR_GENERIC,
"No Output from SDI");
}
/*
* The document being in memory, it has no base per RFC 2396,
* and the argument - "noname.xml" will serve as its base.
*/
len = strlen(sdiRequest);
xmlFreeDoc(sdiRequestDoc);
ARPluginLogging(AR_PLUGIN_LOG_INFO,
"After len - %d\n",len);
doc = xmlReadMemory(sdiRequest, len, "noname1.xml", NULL, 0);
ARPluginLogging(AR_PLUGIN_LOG_INFO,
"After doc\n");