Re: curl crashes when internet switched off

2019-09-04 Thread Salman Ahmed via curl-library
Makes sense.
Thanks for the help + Rainer too

On Wed, Sep 4, 2019 at 3:45 PM Daniel Stenberg  wrote:

> On Wed, 4 Sep 2019, Salman Ahmed wrote:
>
> Please stop top-posting. It makes it really hard to follow this
> discussion/thread.
>
> > I updated my libcurl to 7.65.3 and at the same time I found out that the
> 3rd
> > party sdk i am using does use curl_easy_setopt(curl, CURLOPT_NOSIGNAL,
> 1).
> > After I set that to "0" my program didn't terminate when wifi was
> switched
> > off.
>
> Then you could probably achieve the same result with the older version as
> well.
>
> > But from the brief reading on google,
>
> Don't read on google. Read the genuine docs on the curl site.
>
> > it seems that CURLOPT_NOSIGNAL should be set to 1 for multithreaded
> > applications like mine. Is there a way to keep CURLOPT_NOSIGNAL = 1 and
> > handle the broken SIGPIPE problem I am getting originally?
>
> It depends on what you want to do.
>
> The SIGPIPE signal here originates from OpenSSL (when it tries to use the
> socket after the connection has closed). The only way to prevent that from
> happening in libcurl is for libcurl to switch off the signal on entry and
> switch it on again on exit. It does this if CURLOPT_NOSIGNAL is set to 1.
>
> The sighandler is however global for your application so if you use
> libcurl
> from multiple threads within that application libcurl will switch that
> state
> on/off in a racy manner and you don't really know how it'll handle the
> signal
> if/when it arrives.
>
> You're then better off adding a single global SIGPIPE ignore yourself and
> tell
> curl to hands off anything that has to do with signals.
>
> --
>
>   / daniel.haxx.se | Get the best commercial curl support there is - from
> me
>| Private help, bug fixes, support, ports, new features
>| https://www.wolfssl.com/contact/
>
---
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette:   https://curl.haxx.se/mail/etiquette.html

Re: curl crashes when internet switched off

2019-09-04 Thread Daniel Stenberg via curl-library

On Wed, 4 Sep 2019, Salman Ahmed wrote:

Please stop top-posting. It makes it really hard to follow this 
discussion/thread.


I updated my libcurl to 7.65.3 and at the same time I found out that the 3rd 
party sdk i am using does use curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1). 
After I set that to "0" my program didn't terminate when wifi was switched 
off.


Then you could probably achieve the same result with the older version as 
well.



But from the brief reading on google,


Don't read on google. Read the genuine docs on the curl site.

it seems that CURLOPT_NOSIGNAL should be set to 1 for multithreaded 
applications like mine. Is there a way to keep CURLOPT_NOSIGNAL = 1 and 
handle the broken SIGPIPE problem I am getting originally?


It depends on what you want to do.

The SIGPIPE signal here originates from OpenSSL (when it tries to use the 
socket after the connection has closed). The only way to prevent that from 
happening in libcurl is for libcurl to switch off the signal on entry and 
switch it on again on exit. It does this if CURLOPT_NOSIGNAL is set to 1.


The sighandler is however global for your application so if you use libcurl 
from multiple threads within that application libcurl will switch that state 
on/off in a racy manner and you don't really know how it'll handle the signal 
if/when it arrives.


You're then better off adding a single global SIGPIPE ignore yourself and tell 
curl to hands off anything that has to do with signals.


--

 / daniel.haxx.se | Get the best commercial curl support there is - from me
  | Private help, bug fixes, support, ports, new features
  | https://www.wolfssl.com/contact/
---
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette:   https://curl.haxx.se/mail/etiquette.html

Re: curl crashes when internet switched off

2019-09-04 Thread Salman Ahmed via curl-library
I updated my libcurl to 7.65.3 and at the same time I found out that the
3rd party sdk i am using does use curl_easy_setopt(curl, CURLOPT_NOSIGNAL,
1). After I set that to "0" my program didn't terminate when wifi was
switched off. But from the brief reading on google , it seems that
CURLOPT_NOSIGNAL should be set to 1 for multithreaded applications like
mine. Is there a way to keep CURLOPT_NOSIGNAL = 1 and handle the broken
SIGPIPE problem I am getting originally?

On Wed, Sep 4, 2019 at 2:43 PM Daniel Stenberg  wrote:

> On Wed, 4 Sep 2019, Salman Ahmed wrote:
>
> > CURL VER libcurl/7.47.0 OpenSSL/1.0.2g zlib/1.2.8 libidn/1.32 librtmp/2.3
> > Linux VirtualBox 4.15.0-58-generic #64~16.04.1-Ubuntu SMP Wed Aug 7
> > 14:10:35 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
> >
> > I guess its 3 year old libcurl?I dont remember manually
> configure/install.
> > I just got it from the ubuntu repos.
> > Do I need to build curl myself and have this symbol defined?
>
> Ah sorry I see now that I misread what TLS backend that was in use. Ignore
> my
> previous question.
>
> I guess you either suffer from an old libcurl bug (I searched but I
> couldn't
> find any obvious issue) or you've switched off signal handling with
> CURLOPT_NOSIGNAL.
>
> Maybe you can build a modern version as a test just to see if the problem
> persists then or not?
>
> (During those 3.5 years since we released 7.47.0, we have landed at least
> 2235
> documented bug fixes.)
>
> --
>
>   / daniel.haxx.se | Get the best commercial curl support there is - from
> me
>| Private help, bug fixes, support, ports, new features
>| https://www.wolfssl.com/contact/
>
---
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette:   https://curl.haxx.se/mail/etiquette.html

Re: curl crashes when internet switched off

2019-09-04 Thread Rainer Canavan via curl-library
On Wed, Sep 4, 2019 at 2:34 PM Salman Ahmed via curl-library
 wrote:
>
> CURL VER libcurl/7.47.0 OpenSSL/1.0.2g zlib/1.2.8 libidn/1.32 librtmp/2.3
> Linux VirtualBox 4.15.0-58-generic #64~16.04.1-Ubuntu SMP Wed Aug 7 14:10:35 
> UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
>
> I guess its 3 year old libcurl?I dont remember manually configure/install. I 
> just got it from the ubuntu repos.
> Do I need to build curl myself and have this symbol defined?

since you're probably using ubuntu packages for curl, the buildlog
here 
https://launchpadlibrarian.net/408958147/buildlog_ubuntu-xenial-amd64.curl_7.47.0-1ubuntu2.12_BUILDING.txt.gz
should be close enough to what you're using. If it's something
different, you can pick the relevant version from
https://launchpad.net/ubuntu/+source/curl/+publishinghistory, then the
architecture and finally the buildlog.  That build has

checking for MSG_NOSIGNAL... yes

rainer
---
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette:   https://curl.haxx.se/mail/etiquette.html

Re: curl crashes when internet switched off

2019-09-04 Thread Daniel Stenberg via curl-library

On Wed, 4 Sep 2019, Salman Ahmed wrote:


CURL VER libcurl/7.47.0 OpenSSL/1.0.2g zlib/1.2.8 libidn/1.32 librtmp/2.3
Linux VirtualBox 4.15.0-58-generic #64~16.04.1-Ubuntu SMP Wed Aug 7
14:10:35 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

I guess its 3 year old libcurl?I dont remember manually configure/install.
I just got it from the ubuntu repos.
Do I need to build curl myself and have this symbol defined?


Ah sorry I see now that I misread what TLS backend that was in use. Ignore my 
previous question.


I guess you either suffer from an old libcurl bug (I searched but I couldn't 
find any obvious issue) or you've switched off signal handling with 
CURLOPT_NOSIGNAL.


Maybe you can build a modern version as a test just to see if the problem 
persists then or not?


(During those 3.5 years since we released 7.47.0, we have landed at least 2235 
documented bug fixes.)


--

 / daniel.haxx.se | Get the best commercial curl support there is - from me
  | Private help, bug fixes, support, ports, new features
  | https://www.wolfssl.com/contact/
---
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette:   https://curl.haxx.se/mail/etiquette.html

Re: curl crashes when internet switched off

2019-09-04 Thread Salman Ahmed via curl-library
CURL VER libcurl/7.47.0 OpenSSL/1.0.2g zlib/1.2.8 libidn/1.32 librtmp/2.3
Linux VirtualBox 4.15.0-58-generic #64~16.04.1-Ubuntu SMP Wed Aug 7
14:10:35 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

I guess its 3 year old libcurl?I dont remember manually configure/install.
I just got it from the ubuntu repos.
Do I need to build curl myself and have this symbol defined?

Sorry forgot to Reply-All

On Wed, Sep 4, 2019 at 4:50 PM Daniel Stenberg  wrote:

> On Wed, 4 Sep 2019, Salman Ahmed via curl-library wrote:
>
> > I am facing this problem where my application just terminates when I
> > manually switch off my WiFi while it is waiting on curl_easy_perform()
> in a
> > separate thread from the main thread.
>
> What libcurl version is this? On Linux, right?
>
> > Thread 4 "my-app" received signal SIGPIPE, Broken pipe.
>
> libcurl should invoke send() with MSG_NOSIGNAL set that then would avoid
> this.
>
> Did configure find and define HAVE_MSG_NOSIGNAL for you?
>
> --
>
>   / daniel.haxx.se | Get the best commercial curl support there is - from
> me
>| Private help, bug fixes, support, ports, new features
>| https://www.wolfssl.com/contact/
>
---
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette:   https://curl.haxx.se/mail/etiquette.html

Re: curl crashes when internet switched off

2019-09-04 Thread Daniel Stenberg via curl-library

On Wed, 4 Sep 2019, Salman Ahmed via curl-library wrote:

I am facing this problem where my application just terminates when I 
manually switch off my WiFi while it is waiting on curl_easy_perform() in a 
separate thread from the main thread.


What libcurl version is this? On Linux, right?


Thread 4 "my-app" received signal SIGPIPE, Broken pipe.


libcurl should invoke send() with MSG_NOSIGNAL set that then would avoid this.

Did configure find and define HAVE_MSG_NOSIGNAL for you?

--

 / daniel.haxx.se | Get the best commercial curl support there is - from me
  | Private help, bug fixes, support, ports, new features
  | https://www.wolfssl.com/contact/
---
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette:   https://curl.haxx.se/mail/etiquette.html