[ 
https://issues.apache.org/jira/browse/MINIFICPP-877?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16846758#comment-16846758
 ] 

Daniel Bakai edited comment on MINIFICPP-877 at 5/23/19 2:42 PM:
-----------------------------------------------------------------

[~phrocker] You can't actually tell cURL not to initialise OpenSSL since 7.57.0 
(CURL_GLOBAL_SSL is ignored since that version, see 
[https://curl.haxx.se/libcurl/c/curl_global_init.html]).

So if we can't assume that TLSSocket's singleton is created before any 
ObjectFactory is created, then it is bad for us either way.

However, if we can assume that TLSSocket's singleton is created before any 
ObjectFactory is created, then we don't have a problem: you will not have 
parallel calls to OpenSSL's initializers and we can avoid adding a 
chaining/dependency API to initializers.

I would prefer to avoid having dependencies between initializers: all third 
party libraries that has these kind of global initializers are designed to 
handle calling their _init and _deinit functions more than once (and only 
deallocate when their refcounter reaches 0): we just have to provide 
synchronization and ObjectFactoryInitializers can be kept simple.

So if we can't ensure that the TLSSocket singleton is created before 
ObjectFactoryInitializers are called, then we wouldn't be in a better position 
even if we could tell cURL not to initialize OpenSSL. If we can ensure that, we 
are ready. If we can't, we have to find some other method of synchronization.


was (Author: bakaid):
[~phrocker] You can't actually tell cURL not to initialise OpenSSL since 7.57.0 
(CURL_GLOBAL_SSL is ignored since that version, see 
[https://curl.haxx.se/libcurl/c/curl_global_init.html]).

So if we can't assume that TLSSocket's singleton is created before any 
ObjectFactory is created, then it is bad for us either way.

However, if we can assume that TLSSocket's singleton is created before any 
ObjectFactory is created, then we don't have a problem: you will not have 
parallel calls to OpenSSL's initializers and we can avoid adding a 
chaining/dependency API to initializers.

I would prefer to avoid having dependencies between initializers: all third 
party libraries that has these kind of global initializers are designed to 
handle calling their _init and _deinit functions more than once (and only 
deallocate when their refcounter reaches 0): we just have to provide 
synchronization.

So if we can't ensure that the TLSSocket singleton is created before 
ObjectFactoryInitializers are called, then we wouldn't be in a better position 
even if we could tell cURL not to initialize OpenSSL. If we can ensure that, we 
are ready. If we can't, we have to find some other method of synchronization.

> Create a thread safe way to call thirdparty global initializers
> ---------------------------------------------------------------
>
>                 Key: MINIFICPP-877
>                 URL: https://issues.apache.org/jira/browse/MINIFICPP-877
>             Project: Apache NiFi MiNiFi C++
>          Issue Type: New Feature
>            Reporter: Daniel Bakai
>            Assignee: Daniel Bakai
>            Priority: Major
>             Fix For: 0.7.0
>
>          Time Spent: 10m
>  Remaining Estimate: 0h
>




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to