Changeset 21398


Ignore:
Timestamp:
2012/01/16 22:49:05 (12 years ago)
Author:
Seasoft
Message:

#1610 (PHP のタイムアウトを延長する処理をユーティリティクラスへ移動)

Location:
branches/version-2_12-dev/data/class
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/version-2_12-dev/data/class/pages/admin/basis/LC_Page_Admin_Basis_ZipInstall.php

    r21237 r21398  
    234234        $cntInsert = 0; 
    235235        $img_cnt = 0; 
    236         $safe_mode = (boolean)ini_get('safe_mode'); 
    237         $max_execution_time 
    238             = is_numeric(ini_get('max_execution_time')) 
    239             ? intval(ini_get('max_execution_time')) 
    240             : intval(get_cfg_var('max_execution_time')) 
    241         ; 
    242236 
    243237        $fp = $this->openZipCsv(); 
     
    273267                $img_cnt++; 
    274268            } 
    275             // 暴走スレッドが残留する確率を軽減したタイムアウト防止のロジック 
    276             // TODO 動作が安定していれば、SC_Utils 辺りに移動したい。 
    277             if (!$safe_mode) { 
    278                 // タイムアウトをリセット 
    279                 set_time_limit($max_execution_time); 
    280             } 
     269            SC_Utils_Ex::extendTimeOut(); 
    281270        } 
    282271        fclose($fp); 
  • branches/version-2_12-dev/data/class/util/SC_Utils.php

    r21374 r21398  
    21682168        return preg_match($pattern, $url) >= 1; 
    21692169    } 
     2170 
     2171    /** 
     2172     * PHP のタイムアウトを延長する 
     2173     * 
     2174     * ループの中で呼び出すことを意図している。 
     2175     * 暴走スレッドが残留する確率を軽減するため、set_time_limit(0) とはしていない。 
     2176     * @param integer $seconds 最大実行時間を延長する秒数。 
     2177     * @return boolean 成功=true, 失敗=false 
     2178     */ 
     2179    function extendTimeOut($seconds = null) { 
     2180        $safe_mode = (boolean)ini_get('safe_mode'); 
     2181        if ($safe_mode) return false; 
     2182 
     2183        if (is_null($seconds)) { 
     2184            $seconds 
     2185                = is_numeric(ini_get('max_execution_time')) 
     2186                ? intval(ini_get('max_execution_time')) 
     2187                : intval(get_cfg_var('max_execution_time')) 
     2188            ; 
     2189        } 
     2190 
     2191        // タイムアウトをリセット 
     2192        set_time_limit($seconds); 
     2193 
     2194        return true; 
     2195    } 
    21702196} 
    21712197?> 
Note: See TracChangeset for help on using the changeset viewer.