curl-library
Segmentation Fault with multithread app. with libcurl 7.15 RedHat Linux 64 bits
Date: Tue, 12 Jan 2010 10:11:08 -0500
Hi
I use libcurl to invoke a web service using the HTTP/POST method for
sending input and receiving the results from the web service.
I move my application from a i386-redhat-linux-gnu server using libcurl
7.12 to a x86_64-redhat-linux-gnu server using libcurl version 7.15 and
have been getting segfault in curl functions after a while (Takes some
time). My application is multithread. I followed all the recomendations
for multithread applications but it seems that adding the option
CURLOPT_NOSIGNAL have solved the problem but I am not sure why. Does
that make sense??
Thank you in advance
Marc Perreault
Here is an extract from my code:
curl = curl_easy_init();
// initalize custom header list (stating that Expect:
100-continue is not wanted
//
headerlist = curl_slist_append(headerlist, buf);
if(curl) {
// what URL that receives this POST
curl_easy_setopt(curl, CURLOPT_URL, service_name);
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headerlist);
curl_easy_setopt(curl, CURLOPT_POST, 1);
curl_easy_setopt(curl, CURLOPT_TIMEOUT, 100);
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, NULL);
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE,
file_info.st_size);
curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_callback);
/* now specify which file to upload */
curl_easy_setopt(curl, CURLOPT_READDATA, hd_src);
curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1);
/* send all data to this function */
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);
/* open the files */
headerfile = fopen(headerfilename,"w");
if (headerfile == NULL) {
cout << "Unable to open " << headerfilename << endl;
curl_easy_cleanup(curl);
return -1;
}
bodyfile = fopen(bodyfilename,"w");
if (bodyfile == NULL) {
cout << "Unable to open " << bodyfilename << endl;
curl_easy_cleanup(curl);
return -1;
}
// we want the headers to this file handle
curl_easy_setopt(curl, CURLOPT_WRITEHEADER, headerfile);
// we want the body to this file handle
curl_easy_setopt(curl, CURLOPT_WRITEDATA, bodyfile);
res = curl_easy_perform(curl);
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2010-01-12