加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Linux > 正文

什么时候需要curl_global_init()?

发布时间:2020-12-13 19:41:10 所属栏目:Linux 来源:网络整理
导读:虽然它的文件说这个功能是必须的,但我看到两个例子,一个有,另一个没有. http://curl.haxx.se/libcurl/c/persistant.html http://curl.haxx.se/libcurl/c/multi-app.html 这个功能是否必要? 解决方法 如果它被设计,将是必要的. documentation说: This funct
虽然它的文件说这个功能是必须的,但我看到两个例子,一个有,另一个没有.

http://curl.haxx.se/libcurl/c/persistant.html

http://curl.haxx.se/libcurl/c/multi-app.html

这个功能是否必要?

解决方法

如果它被设计,将是必要的. documentation说:

This function must be called at least once within a program (a program is all the code that shares a memory space) before the program calls any other function in libcurl. The environment it sets up is constant for the life of the program and is the same for every program,so multiple calls have the same effect as one call.

但请注意,在curl_easy_init的文件中:

If you did not already call curl_global_init(3),curl_easy_init(3) does it automatically. This may be lethal in multi-threaded cases,since curl_global_init(3) is not thread-safe,and it may result in resource problems because there is no corresponding cleanup.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读