1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-07-31 22:10:45 +02:00

[ticket/14487] Try to handle connection timeouts

PHPBB3-14487
This commit is contained in:
Máté Bartus
2016-02-28 00:19:24 +01:00
parent 30db51a86e
commit 062358f8b1
8 changed files with 210 additions and 9 deletions

View File

@@ -41,6 +41,11 @@ class ajax_iohandler extends iohandler_base
*/
protected $router;
/**
* @var string
*/
protected $phpbb_root_path;
/**
* @var string
*/
@@ -76,6 +81,11 @@ class ajax_iohandler extends iohandler_base
*/
protected $redirect_url;
/**
* @var resource
*/
protected $file_lock_pointer;
/**
* Constructor
*
@@ -83,8 +93,9 @@ class ajax_iohandler extends iohandler_base
* @param \phpbb\request\request_interface $request HTTP request interface
* @param \phpbb\template\template $template Template engine
* @param router $router Router
* @param string $root_path Path to phpBB's root
*/
public function __construct(path_helper $path_helper, \phpbb\request\request_interface $request, \phpbb\template\template $template, router $router)
public function __construct(path_helper $path_helper, \phpbb\request\request_interface $request, \phpbb\template\template $template, router $router, $root_path)
{
$this->path_helper = $path_helper;
$this->request = $request;
@@ -96,6 +107,7 @@ class ajax_iohandler extends iohandler_base
$this->download = array();
$this->redirect_url = array();
$this->file_status = '';
$this->phpbb_root_path = $root_path;
parent::__construct();
}
@@ -432,6 +444,33 @@ class ajax_iohandler extends iohandler_base
$this->send_response(true);
}
/**
* Acquires a file lock
*/
public function acquire_lock()
{
$lock_file = $this->phpbb_root_path . 'store/io_lock.lock';
$this->file_lock_pointer = @fopen($lock_file, 'w+');
if ($this->file_lock_pointer)
{
flock($this->file_lock_pointer, LOCK_EX);
}
}
/**
* Release file lock
*/
public function release_lock()
{
if ($this->file_lock_pointer)
{
fwrite($this->file_lock_pointer, 'ok');
flock($this->file_lock_pointer, LOCK_UN);
fclose($this->file_lock_pointer);
}
}
/**
* Callback function for language replacing
*