国产+高潮+在线,国产 av 仑乱内谢,www国产亚洲精品久久,51国产偷自视频区视频,成人午夜精品网站在线观看

讀寫文件發(fā)生錯誤:Too many open files,如何解決?

EricWen

ubuntu系統(tǒng)
Warning: file_put_contents(/xxxx/log//17-03-22.txt): failed to open stream: Too many open files in /xxx/common/function.php on line 323

這是方法是寫日志,用的是file_put_contents方法,按理說寫完日志就關掉了文件連接了,而我的work就看了3個進程,就導致了這個問題,請問如何解決?

調(diào)試發(fā)現(xiàn)是curl_init造成的,但是有關閉,系統(tǒng)卻一直保持連接

protected function _wget($url, $post_data = null)
    {
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
        curl_setopt($ch, CURLOPT_TIMEOUT, 15);
        if ($post_data) {
            curl_setopt($ch, CURLOPT_POST, 1);
            curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
        }
        $response = curl_exec($ch);
        if ($response === false) {
            system_log('獲取遠程數(shù)據(jù)失?。? . curl_error($ch));
            curl_close($ch);
            return false;
        }
        $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
        curl_close($ch);
        if ($http_code == 200) {
            $ret = json_decode($response, true);
            if ($ret) {
                return $ret;
            }
            system_log('獲取遠程數(shù)據(jù)返回異常內(nèi)容:' . $response);
        } else {
            system_log('獲取遠程數(shù)據(jù)返回異常狀態(tài)碼:' . $http_code . ',返回內(nèi)容為:' . $response);
            return false;
        }
    }

圖片

8885 2 0
2個回答

walkor 打賞

http://php.net/manual/en/function.curl-setopt.php
這里有curl選項,應該有強制關閉復用鏈接的選項,找下

  • 暫無評論
Wakada

兄弟,請問這個問題你解決了嗎,同樣碰到!

  • 暫無評論
年代過于久遠,無法發(fā)表回答
??