Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions system/libraries/Session/drivers/Session_files_driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ public function read($session_id)
return $this->_failure;
}

if (flock($this->_file_handle, LOCK_EX) === FALSE)
if (flock($this->_file_handle, LOCK_SH) === FALSE)
{
log_message('error', "Session: Unable to obtain lock for file '".$this->_file_path.$session_id."'.");
fclose($this->_file_handle);
Expand Down Expand Up @@ -225,6 +225,7 @@ public function read($session_id)
}

$this->_fingerprint = md5($session_data);
flock($this->_file_handle, LOCK_UN);
return $session_data;
}

Expand All @@ -247,7 +248,13 @@ public function write($session_id, $session_data)
{
return $this->_failure;
}

if (flock($this->_file_handle, LOCK_EX) === FALSE)
{
log_message('error', "Session: Unable to obtain lock for file '".$this->_file_path.$session_id."'.");
fclose($this->_file_handle);
$this->_file_handle = NULL;
return $this->_failure;
}
if ( ! is_resource($this->_file_handle))
{
return $this->_failure;
Expand Down Expand Up @@ -284,6 +291,7 @@ public function write($session_id, $session_data)
}

$this->_fingerprint = md5($session_data);
flock($this->_file_handle, LOCK_UN);
return $this->_success;
}

Expand All @@ -300,7 +308,6 @@ public function close()
{
if (is_resource($this->_file_handle))
{
flock($this->_file_handle, LOCK_UN);
fclose($this->_file_handle);

$this->_file_handle = $this->_file_new = $this->_session_id = NULL;
Expand Down