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

讀寫(xiě)文件發(fā)生錯(cuò)誤: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

這是方法是寫(xiě)日志,用的是file_put_contents方法,按理說(shuō)寫(xiě)完日志就關(guān)掉了文件連接了,而我的work就看了3個(gè)進(jìn)程,就導(dǎo)致了這個(gè)問(wèn)題,請(qǐng)問(wèn)如何解決?

調(diào)試發(fā)現(xiàn)是curl_init造成的,但是有關(guān)閉,系統(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('獲取遠(yuǎn)程數(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('獲取遠(yuǎn)程數(shù)據(jù)返回異常內(nèi)容:' . $response);
        } else {
            system_log('獲取遠(yuǎn)程數(shù)據(jù)返回異常狀態(tài)碼:' . $http_code . ',返回內(nèi)容為:' . $response);
            return false;
        }
    }

圖片

9051 2 0
2個(gè)回答

walkor 打賞

http://php.net/manual/en/function.curl-setopt.php
這里有curl選項(xiàng),應(yīng)該有強(qiáng)制關(guān)閉復(fù)用鏈接的選項(xiàng),找下

  • 暫無(wú)評(píng)論
Wakada

兄弟,請(qǐng)問(wèn)這個(gè)問(wèn)題你解決了嗎,同樣碰到!

  • 暫無(wú)評(píng)論
年代過(guò)于久遠(yuǎn),無(wú)法發(fā)表回答
??