Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
http: call curl_global_init in parent and child processes
Until now we have relied on curl_easy_init() calling curl_global_init() for us and thus not worrying about when curl is initialized. Unfortunately, on some platforms libcurl does not work properly when initialized in one process, and then later accessed from a child process. The following case demonstrated the problem on CentOS 6: cat fields.txt | ./lpass add --non-interactive --sync=now MyAccount The uploader queue showed every connection failing with error 35: unable to validate the connection certificate. The --sync=now means the server will be contacted to refresh the blob, in the parent process. Then, the add itself will happen via the lpass uploader in a child process. When the sync runs, libcurl is initialized in the parent. When the child runs, libcurl inherits stale global state from the parent that prevents it from operating properly. Reinitializing curl in the child fixes this. Add a new function, http_init() which calls the curl destroy and init functions. These are reference-counted, so curl_global_destroy() must be called in the child process before curl_global_init(); however, curl_global_destroy() checks that init has been run first so we can just always call both rather than having separate init and re-init functions. Fixes lastpass#166. Signed-off-by: Bob Copeland <[email protected]>
- Loading branch information