cURL / Mailing Lists / curl-library / Single Mail

curl-library

Closing an open connection with curl easy handle

From: Thibaut Le Guilly <leguilly.thibaut_at_gmail.com>
Date: Thu, 29 Sep 2011 13:15:00 +0200

Hi,

I am using libcurl to make a client for a RESTful web server. This web
server provides push notifications to update the client whenever a service
state changes. In order to receive these notification, I use a curl easy
handle that perform a GET on the web server in a dedicated thread. The
connection then stays open and I'm able to receive the notification thanks
to the write callback of the easy handle. My problem is that I would like to
be able to close that connection when the client is closing. I thought that
calling curl_easy_cleanup() on the handle would do so, but the thread
doesn't go back from the curl_easy_perform() function.

I'm also using a share handle in order to share the cookies between the
different handles, and when I attempt to cleanup this share handle, I'm
receiving a segmentation fault, which I think is appearing because the
handle used for the push notification is not cleaned properly (when I don't
use this handle everything works fine). The segmentation fault is happening
on a fputc() because of the stream being NULL (the call stack is :
Culr_read_write->Curl_pgrsUpdate->curl_mprintf->??->fputc).

Is there a proper way to close the connection and clean up the handle?

I attached my code hoping someone can see something wrong that I missed
(note that it's part of a bigger program and that I just wrote it for
testing curl functionalities).

Thank you in advance,

Best regards,

-- 
Thibaut




-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html

  • text/x-csrc attachment: main.c
Received on 2011-09-29