cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: libcurl/openssl crashes when remote site partially goes down

From: Magnus Cederlöf <magnus.cederlof_at_gmail.com>
Date: Thu, 17 Jan 2008 15:35:20 +0100

On Jan 17, 2008 2:11 PM, Daniel Stenberg <daniel_at_haxx.se> wrote:

> On Thu, 17 Jan 2008, Magnus Cederlöf wrote:
>
> > Well, I would at least expect that it would return with an error code
> and
> > not just stop executing the program in the middle of a routine. If this
> > routine is incorporated in a larger application it means that everything
> > running in that process will stop. It would be good to have a way to
> catch
> > the error.
>
> (Please don't top-post, it makes it very hard to follow this thread.)
>
> The problem is that there's SIGPIPE sent to the app that seems to arrive
> when
> curl_easy_cleanup() is called and that is actually caused by OpenSSL that
> writes to the socket...
>
> As a quick fix, you can just make your app ignore those. I'm not really
> sure
> how to force openssl to not cause this to happen.
>
> Anyone else?
>
> --
> Commercial curl and libcurl Technical Support: http://haxx.se/curl.html
>

Thanks, that did the trick!
If anyone is interested, here is the code:

#include <signal.h>

void sigpipe_handler (int signum)
{
    printf("Sigpipe catched!\n");
}

int main(void)
{
    struct sigaction sa;
    memset (&sa, 0, sizeof (sa));
    sa.sa_handler = &sigpipe_handler;

    sigaction (SIGPIPE, &sa, NULL);

etc......

However, it would be even better if libcurl/openssl could be failsafe and
just return an error code for problems related to the remote site. If I
could wish.... :-)

Thanks again,
Magnus
Received on 2008-01-17