2012-05-10 Miguel de Dios <miguel.dedios@artica.es>
* include/functions_users.php: fixes from the equal chat in the Integria IMS. MERGED FROM 4.0.2 git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6286 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
4897288d66
commit
614db7dce4
|
@ -1,3 +1,10 @@
|
||||||
|
2012-05-10 Miguel de Dios <miguel.dedios@artica.es>
|
||||||
|
|
||||||
|
* include/functions_users.php: fixes from the equal chat in the
|
||||||
|
Integria IMS.
|
||||||
|
|
||||||
|
MERGED FROM 4.0.2
|
||||||
|
|
||||||
2012-05-10 Sergio Martin <sergio.martin@artica.es>
|
2012-05-10 Sergio Martin <sergio.martin@artica.es>
|
||||||
|
|
||||||
* pandoradb.sql
|
* pandoradb.sql
|
||||||
|
|
|
@ -226,6 +226,7 @@ function users_get_user_by_id ($id_user){
|
||||||
return $result_user;
|
return $result_user;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
define("MAX_TIMES", 10);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
//////////////////////WEBCHAT FUNCTIONS/////////////////////////////////
|
//////////////////////WEBCHAT FUNCTIONS/////////////////////////////////
|
||||||
|
@ -240,11 +241,11 @@ function users_get_last_messages($last_time = false) {
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//Try to look $max_times times
|
//Try to look MAX_TIMES times
|
||||||
$tries = 0;
|
$tries = 0;
|
||||||
while (!flock($fp_global_counter, LOCK_EX)) {
|
while (!flock($fp_global_counter, LOCK_EX)) {
|
||||||
$tries++;
|
$tries++;
|
||||||
if ($tries >= $max_times) {
|
if ($tries > MAX_TIMES) {
|
||||||
echo json_encode($return);
|
echo json_encode($return);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -313,17 +314,17 @@ function users_save_login() {
|
||||||
if ($fp_user_list === false) {
|
if ($fp_user_list === false) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//Try to look $max_times times
|
//Try to look MAX_TIMES times
|
||||||
$tries = 0;
|
$tries = 0;
|
||||||
while (!flock($fp_user_list, LOCK_EX)) {
|
while (!flock($fp_user_list, LOCK_EX)) {
|
||||||
$tries++;
|
$tries++;
|
||||||
if ($tries >= $max_times) {
|
if ($tries > MAX_TIMES) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
sleep(1);
|
sleep(1);
|
||||||
}
|
}
|
||||||
@fscanf($fp_user_list, "%s", $user_list_json);
|
@fscanf($fp_user_list, "%[^\n]", $user_list_json);
|
||||||
|
|
||||||
$user_list = json_decode($user_list_json, true);
|
$user_list = json_decode($user_list_json, true);
|
||||||
if (empty($user_list))
|
if (empty($user_list))
|
||||||
|
@ -363,17 +364,17 @@ function users_save_logout() {
|
||||||
if ($fp_user_list === false) {
|
if ($fp_user_list === false) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//Try to look $max_times times
|
//Try to look MAX_TIMES times
|
||||||
$tries = 0;
|
$tries = 0;
|
||||||
while (!flock($fp_user_list, LOCK_EX)) {
|
while (!flock($fp_user_list, LOCK_EX)) {
|
||||||
$tries++;
|
$tries++;
|
||||||
if ($tries >= $max_times) {
|
if ($tries > MAX_TIMES) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
sleep(1);
|
sleep(1);
|
||||||
}
|
}
|
||||||
@fscanf($fp_user_list, "%s", $user_list_json);
|
@fscanf($fp_user_list, "%[^\n]", $user_list_json);
|
||||||
|
|
||||||
$user_list = json_decode($user_list_json, true);
|
$user_list = json_decode($user_list_json, true);
|
||||||
if (empty($user_list))
|
if (empty($user_list))
|
||||||
|
@ -400,8 +401,6 @@ function users_save_text_message($message = false, $type = 'message') {
|
||||||
$file_global_counter_chat = sys_get_temp_dir() . '/pandora_chat.global_counter.txt';
|
$file_global_counter_chat = sys_get_temp_dir() . '/pandora_chat.global_counter.txt';
|
||||||
$log_chat_file = sys_get_temp_dir() . '/pandora_chat.log.json.txt';
|
$log_chat_file = sys_get_temp_dir() . '/pandora_chat.log.json.txt';
|
||||||
|
|
||||||
$max_times = 10;
|
|
||||||
|
|
||||||
$return = array('correct' => false);
|
$return = array('correct' => false);
|
||||||
|
|
||||||
$id_user = $config['id_user'];
|
$id_user = $config['id_user'];
|
||||||
|
@ -424,11 +423,11 @@ function users_save_text_message($message = false, $type = 'message') {
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//Try to look $max_times times
|
//Try to look MAX_TIMES times
|
||||||
$tries = 0;
|
$tries = 0;
|
||||||
while (!flock($fp_global_counter, LOCK_EX)) {
|
while (!flock($fp_global_counter, LOCK_EX)) {
|
||||||
$tries++;
|
$tries++;
|
||||||
if ($tries >= $max_times) {
|
if ($tries > MAX_TIMES) {
|
||||||
echo json_encode($return);
|
echo json_encode($return);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -480,18 +479,19 @@ function users_long_polling_check_messages($global_counter) {
|
||||||
$log_chat_file = sys_get_temp_dir() . '/pandora_chat.log.json.txt';
|
$log_chat_file = sys_get_temp_dir() . '/pandora_chat.log.json.txt';
|
||||||
|
|
||||||
$changes = false;
|
$changes = false;
|
||||||
$max_times = 10;
|
|
||||||
|
$tries_general = 0;
|
||||||
|
|
||||||
while (!$changes) {
|
while (!$changes) {
|
||||||
//First lock the file
|
//First lock the file
|
||||||
$fp_global_counter = @fopen($file_global_counter_chat, "a+");
|
$fp_global_counter = @fopen($file_global_counter_chat, "a+");
|
||||||
if ($fp_global_counter) {
|
if ($fp_global_counter) {
|
||||||
//Try to look $max_times times
|
//Try to look MAX_TIMES times
|
||||||
$tries = 0;
|
$tries = 0;
|
||||||
$lock = true;
|
$lock = true;
|
||||||
while (!flock($fp_global_counter, LOCK_EX)) {
|
while (!flock($fp_global_counter, LOCK_EX)) {
|
||||||
$tries++;
|
$tries++;
|
||||||
if ($tries >= $max_times) {
|
if ($tries > MAX_TIMES) {
|
||||||
$lock = false;
|
$lock = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -534,6 +534,11 @@ function users_long_polling_check_messages($global_counter) {
|
||||||
}
|
}
|
||||||
|
|
||||||
sleep(3);
|
sleep(3);
|
||||||
|
$tries_general = $tries_general + 3;
|
||||||
|
|
||||||
|
if ($tries_general > MAX_TIMES) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
echo json_encode(array('correct' => false));
|
echo json_encode(array('correct' => false));
|
||||||
|
@ -559,7 +564,7 @@ function users_get_last_global_counter($mode = 'json') {
|
||||||
$lock = true;
|
$lock = true;
|
||||||
while (!flock($fp_global_counter, LOCK_EX)) {
|
while (!flock($fp_global_counter, LOCK_EX)) {
|
||||||
$tries++;
|
$tries++;
|
||||||
if ($tries >= $max_times) {
|
if ($tries > MAX_TIMES) {
|
||||||
$lock = false;
|
$lock = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -611,7 +616,7 @@ function users_get_last_type_message() {
|
||||||
$lock = true;
|
$lock = true;
|
||||||
while (!flock($fp_global_counter, LOCK_EX)) {
|
while (!flock($fp_global_counter, LOCK_EX)) {
|
||||||
$tries++;
|
$tries++;
|
||||||
if ($tries >= $max_times) {
|
if ($tries > MAX_TIMES) {
|
||||||
$lock = false;
|
$lock = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -657,11 +662,11 @@ function users_check_users() {
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//Try to look $max_times times
|
//Try to look MAX_TIMES times
|
||||||
$tries = 0;
|
$tries = 0;
|
||||||
while (!flock($fp_user_list, LOCK_EX)) {
|
while (!flock($fp_user_list, LOCK_EX)) {
|
||||||
$tries++;
|
$tries++;
|
||||||
if ($tries >= $max_times) {
|
if ($tries > MAX_TIMES) {
|
||||||
echo json_encode($return);
|
echo json_encode($return);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -669,7 +674,7 @@ function users_check_users() {
|
||||||
|
|
||||||
sleep(1);
|
sleep(1);
|
||||||
}
|
}
|
||||||
@fscanf($fp_user_list, "%s", $user_list_json);
|
@fscanf($fp_user_list, "%[^\n]", $user_list_json);
|
||||||
|
|
||||||
$user_list = json_decode($user_list_json, true);
|
$user_list = json_decode($user_list_json, true);
|
||||||
if (empty($user_list))
|
if (empty($user_list))
|
||||||
|
|
Loading…
Reference in New Issue