Bug 919127

Summary: provide a CURL_GLOBAL_ACK_EINTR flag to curl_global_init()
Product: [Fedora] Fedora Reporter: Ales Kozumplik <akozumpl>
Component: curlAssignee: Kamil Dudka <kdudka>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 17CC: jzeleny, kdudka, paul, zpavlas
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: curl-7.29.0-4.fc19 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 920593 (view as bug list) Environment:
Last Closed: 2013-03-18 02:34:13 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 920589, 920593    

Description Ales Kozumplik 2013-03-07 16:46:07 UTC
Hello,

we use curl for some higher-level libraries (librepo and urlgrabber namely) and they both need to be able to setup libcurl to interrupt a hanged operation on Ctrl-C. This is currently not possible (unless Curl is compiled with a special switch) but it is essential for a good user experience in applications like Yum.

There is a upstream patch proposed already: http://sourceforge.net/p/curl/bugs/1168/

Comment 1 Kamil Dudka 2013-03-07 19:36:18 UTC
Thanks for the patch and the upstream proposal.  Could you please provide a pycurl-based test code that can be used to verify that libcurl behaves as expected?

Comment 2 Zdeněk Pavlas 2013-03-08 08:09:25 UTC
Run this, then hit ctrl-c.  When curl and pycurl are patched, perform() should immediately raise pycurl.error: (28, 'connect() timed out!').  Otherwise, ctrl-c is ignored, and you have to wait for a minute or sigkill this.

import pycurl
if hasattr(pycurl, 'GLOBAL_ACK_EINTR'):
    pycurl.global_init(pycurl.GLOBAL_ACK_EINTR)
c = pycurl.Curl()
c.setopt(pycurl.CONNECTTIMEOUT, 60)
c.setopt(pycurl.URL, 'http://10.10.10.0')
c.perform()

Comment 3 Ales Kozumplik 2013-03-08 08:31:28 UTC
Also: we are not explicitly focusing on the pycurl case but mostly on the C curl library where the root cause of this problem is. for instance librepo does not use the curl python bindings at all.

Comment 4 Kamil Dudka 2013-03-08 11:45:02 UTC
(In reply to comment #3)
> Also: we are not explicitly focusing on the pycurl case but mostly on the C
> curl library where the root cause of this problem is. for instance librepo
> does not use the curl python bindings at all.

That sounds wrong to me.  If you write a generic enough library, you do not know in advance how the user of your library will use signals.  Hence, initializing libcurl this way in a library will sooner or later cause a bad surprise elsewhere.  I strongly suggest to use the multi interface instead, which allows you much more than the proposed patch.

We were discussing this with Zdenek before in the context of pycurl and yum as an application.  The only reason for not using the multi interface in yum was the performance penalty caused by implementing the select() loop in python.  However, this reason does not exist in a C library.  You can see that the easy interface is now implemented as a wrapper around the multi interface even in libcurl itself:

http://daniel.haxx.se/blog/2013/01/17/internally-were-all-multi-now/

Comment 5 Kamil Dudka 2013-03-11 16:30:03 UTC
proposed upstream:

http://thread.gmane.org/gmane.comp.web.curl.library/38653/focus=38654

Comment 6 Ales Kozumplik 2013-03-12 09:09:04 UTC
Thanks for the proposed patches Kamil.

(In reply to comment #4)
> That sounds wrong to me.  If you write a generic enough library, you do not
> know in advance how the user of your library will use signals.  Hence,
> initializing libcurl this way in a library will sooner or later cause a bad
> surprise elsewhere.  I strongly suggest to use the multi interface instead,
> which allows you much more than the proposed patch.

Adding tmlcoch. Tomas, this opinion of Kamil is probably something you should be aware of, even if you decide against going for this approach.

Comment 8 Kamil Dudka 2013-03-12 11:18:53 UTC
fixed in curl-7.29.0-4.fc19

Comment 9 Fedora Update System 2013-03-12 12:08:11 UTC
curl-7.27.0-7.fc18 has been submitted as an update for Fedora 18.
https://admin.fedoraproject.org/updates/curl-7.27.0-7.fc18

Comment 10 Fedora Update System 2013-03-12 12:08:25 UTC
curl-7.24.0-6.fc17 has been submitted as an update for Fedora 17.
https://admin.fedoraproject.org/updates/curl-7.24.0-6.fc17

Comment 11 Fedora Update System 2013-03-12 23:27:14 UTC
Package curl-7.24.0-6.fc17:
* should fix your issue,
* was pushed to the Fedora 17 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing curl-7.24.0-6.fc17'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2013-3757/curl-7.24.0-6.fc17
then log in and leave karma (feedback).

Comment 12 Fedora Update System 2013-03-18 02:34:19 UTC
curl-7.27.0-7.fc18 has been pushed to the Fedora 18 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 13 Fedora Update System 2013-03-27 20:38:03 UTC
curl-7.24.0-6.fc17 has been pushed to the Fedora 17 stable repository.  If problems still persist, please make note of it in this bug report.