• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            colorful

            zc qq:1337220912

             

            libcurl 多線程使用注意事項

            1、問題來源,多線程使用Libcurl導致程序跑一段時間后自己退出,沒有明顯的異常。找不到合適的BUG。

             

            最后通過查看資料和網上找的一些文章,發現,原來是信號處理的問題:

             

             

            CURLOPT_NOSIGNAL


            Pass a long. If it is 1, libcurl will not use any functions that install signal handlers or any functions that cause signals to be sent to the process. This option is mainly here to allow multi-threaded unix applications to still set/use all timeout options etc, without risking getting signals. (Added in 7.10)

            If this option is set and libcurl has been built with the standard name resolver, timeouts will not occur while the name resolve takes place. Consider building libcurl with c-ares support to enable asynchronous DNS lookups, which enables nice timeouts for name resolves without signals.

            Setting CURLOPT_NOSIGNAL to 1 makes libcurl NOT ask the system to ignore SIGPIPE signals, which otherwise are sent by the system when trying to send data to a socket which is closed in the other end. libcurl makes an effort to never cause such SIGPIPEs to trigger, but some operating systems have no way to avoid them and even on those that have there are some corner cases when they may still happen, contrary to our desire. 

             

            就是當多個線程都使用超時處理的時候,同時主線程中有sleep或是wait等操作。如果不設置這個選項,libcurl將會發信號打斷這個wait從而導致程序退出。

             

            所以,在使用的時候把這個選項設置成1就可以了.

            curl_setopt(curl, CURLOPT_NOSIGNAL, 1L);

             

            2、關于libcurl庫的初始化和關閉:curl_global_init()和curl_global_cleanup()

            這兩個函數并不是線程安全的。所以只能在主線程中進行一次的初始化和清除。

            雖然這個不是一定就會有問題,但是如果不這樣處理還是有概率發生的。

            posted on 2013-12-02 17:16 多彩人生 閱讀(1549) 評論(0)  編輯 收藏 引用

            導航

            統計

            常用鏈接

            留言簿(3)

            隨筆分類

            隨筆檔案

            搜索

            最新評論

            閱讀排行榜

            評論排行榜

            久久久久国产视频电影| 久久精品中文字幕有码| 精品久久人人爽天天玩人人妻| 久久久久久亚洲精品不卡 | 伊人久久大香线蕉精品不卡| 无码任你躁久久久久久老妇App| 99精品国产免费久久久久久下载 | 狠狠干狠狠久久| 丁香五月综合久久激情| 亚洲国产成人久久综合碰| 亚洲午夜久久久影院伊人| 久久精品一区二区| 久久精品中文字幕一区| 亚洲国产成人久久精品影视 | 亚洲欧美伊人久久综合一区二区 | 亚洲午夜精品久久久久久浪潮| 久久伊人五月丁香狠狠色| 国产成人久久久精品二区三区 | 亚洲中文字幕久久精品无码喷水| 久久精品国产久精国产| 亚洲精品tv久久久久久久久| 久久精品不卡| 99久久精品免费看国产一区二区三区| 伊人久久国产免费观看视频| 婷婷综合久久中文字幕| 久久狠狠高潮亚洲精品| 无码国内精品久久综合88 | 久久亚洲精品无码aⅴ大香| 亚洲国产精品久久久久网站| 亚洲日韩中文无码久久| 思思久久99热只有频精品66| 91精品国产高清久久久久久国产嫩草| 久久国产色AV免费观看| 亚洲AV无一区二区三区久久 | 久久久久亚洲AV成人网| 日本免费久久久久久久网站| 精品久久人妻av中文字幕| 日本人妻丰满熟妇久久久久久| 久久精品免费一区二区| 国色天香久久久久久久小说 | 久久国产精品无码网站|