I'm using gSOAP under Linux in one of my projects, and I have a problem when using the server for a pretty long time (actually not very long, I get this error after something like 10 hours...). I followed the example gave some time ago here for multithreading in gSOAP. I create a soap service, then use the copy method and pass it to a thread. The thread functions is something like this:
void MyClass::SoapServer(myservice::Service* soapService)
{
int res = soapService->serve();
if (res != SOAP_OK)
{
// log error
}
soapService->destroy();
soap_free(soapService);
}
After a few hours, when there is a constant poller that calls SOAP functions, I get segmentation fault in the gSOAP copy function. Below i attach the code that accepts the connection and creates the thread.
while(true)
{
int error = mySoapService.accept();
if (!soap_valid_socket(error))
{
//error
}
else
{
myservice::Service *soapServiceCopy = NULL;
soapServiceCopy = mySoapService.copy();
// create thread using the SoapServer function
// and pass soapServiceCopy as an argument
}
}
It seems to me that the soap service clean up is correctly performed, is there anything I'm missing?
Thanks