curl / Mailing Lists / curl-library / Single Mail

curl-library

Re: Calling library functions from within callbacks

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Wed, 8 Nov 2017 14:21:41 +0100 (CET)

On Wed, 8 Nov 2017, Wolfgang Steinwender wrote:

> In https://curl.haxx.se/mail/lib-2017-10/0081.html Daniel said calling
> library functions from within callbacks is not allowed.

Yeah, that's the general rule.

> Could this be documented somewhere?
> Maybe right at the affected callbacks?

Yeah, I think that would be great. There are no less than 23 callbacks in
libcurl so it would probably be worth working out the phrasing to use first...

Any suggestion?

> Contradictory, in the example
> https://curl.haxx.se/libcurl/c/http2-serverpush.html
> curl_easy_setopt() is called from within CURLMOPT_PUSHFUNCTION.
> Is this another exception?

Good question! When we don't enforce the rules programmatically and we don't
have tests that detect misuse, that's what happens. The exact rules haven't
been worked out either...

I think we probably should mark that down as another exception. In particular
in the case of the push callback since that's a brand new easy handle created
by libcurl and an application has no better logical place than in the callback
to set new options for it... In other aspects, when setting options with
curl_easy_setopt() when a transfer already has started, there is certainly no
guarantee that the options will "take" until the next transfer is started.

-- 
  / daniel.haxx.se
-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette:   https://curl.haxx.se/mail/etiquette.html
Received on 2017-11-08