return (FALSE);
}
- static function lock_data()
+ static function lock_data($is_exclusive)
{
if (($tok = @ftok(FTOK_PATH."/challenges", "B")) == -1) {
return (FALSE);
}
// echo "FTOK ".$tok."<br>";
- if (($res = sem_get($tok)) == FALSE) {
+ if (($res = sem_get($tok, ($is_exclusive ? 1 : LOCK_SHARE_MAX) )) == FALSE) {
return (FALSE);
}
if (sem_acquire($res)) {
define(GARBAGE_TIMEOUT, 10);
define(NICKSERV, "<i>BriskServ</i>");
+define(LOCK_SHARE_MAX, 10000);
define(DBG_ONL2, 0x0001);
define(DBG_ONLY, 0x0002);
if ($table_cur->player_n == PLAYERS_N) {
log_main("PLAYERS == N TABLE ".$table_idx);
- if (($sem = Bin5::lock_data($table_idx)) != FALSE) {
+ if (($sem = Bin5::lock_data(TRUE, $table_idx)) != FALSE) {
log_main("bin5 lock data success");
$no_recovery = FALSE;
if ($table_cur->player_n == PLAYERS_N) {
log_main("PLAYERS == N TABLE ".$table_idx);
- if (($sem = Bin5::lock_data($table_idx)) != FALSE) {
+ if (($sem = Bin5::lock_data(TRUE, $table_idx)) != FALSE) {
log_main("bin5 lock data success");
$no_recovery = FALSE;
if ($ghost_user->stat == "table" && $this->table[$table_idx]->player_n == PLAYERS_N) {
// FIXME BRISK4: include for each kind of table
require_once("${G_base}briskin5/Obj/briskin5.phh");
- if (($brisem = Bin5::lock_data($table_idx)) != FALSE) {
+ if (($brisem = Bin5::lock_data(TRUE, $table_idx)) != FALSE) {
if (($bri = Bin5::load_data($table_idx)) != FALSE) {
if ($bri->the_end != TRUE) {
$bri->user[$ghost_user->table_pos]->step_inc();
return ($ret);
}
- static function lock_data()
+ static function lock_data($is_exclusive)
{
GLOBAL $sess;
return (FALSE);
}
// echo "FTOK ".$tok."<br>";
- if (($res = sem_get($tok)) == FALSE) {
+ if (($res = sem_get($tok, ($is_exclusive ? 1 : LOCK_SHARE_MAX) )) == FALSE) {
return (FALSE);
}
if (sem_acquire($res)) {
class Warrant {
static $delta_t;
- static function lock_data()
+ static function lock_data($is_exclusive)
{
GLOBAL $sess;
return (FALSE);
}
// echo "FTOK ".$tok."<br>";
- if (($res = sem_get($tok)) == FALSE) {
+ if (($res = sem_get($tok, ($is_exclusive ? 1 : LOCK_SHARE_MAX) )) == FALSE) {
return (FALSE);
}
if (sem_acquire($res)) {
class Poll {
static $delta_t;
- static function lock_data()
+ static function lock_data($is_exclusive)
{
GLOBAL $sess;
return (FALSE);
}
// echo "FTOK ".$tok."<br>";
- if (($res = sem_get($tok)) == FALSE) {
+ if (($res = sem_get($tok, ($is_exclusive ? 1 : LOCK_SHARE_MAX) )) == FALSE) {
return (FALSE);
}
if (sem_acquire($res)) {
log_main("login[".$i."]: ".$this->item[$i]->login);
/* if it exists check for a valid challenge */
- if (($a_sem = Challenges::lock_data()) != FALSE) {
+ if (($a_sem = Challenges::lock_data(TRUE)) != FALSE) {
if (($chals = &Challenges::load_data()) != FALSE) {
for ($e = 0 ; $e < $chals->item_n ; $e++) {
log_main("login[".$user_obj->code."]: ".$user_obj->login);
/* if it exists check for a valid challenge */
- if (($a_sem = Challenges::lock_data()) != FALSE) {
+ if (($a_sem = Challenges::lock_data(TRUE)) != FALSE) {
if (($chals = &Challenges::load_data()) != FALSE) {
for ($e = 0 ; $e < $chals->item_n ; $e++) {
log_main("challenge[".$e."]: ".$chals->item[$e]->login);
return (FALSE);
}
- static function lock_data()
+ static function lock_data($is_exclusive)
{
if (($tok = @ftok(FTOK_PATH."/hardbans", "B")) == -1) {
return (FALSE);
}
// echo "FTOK ".$tok."<br>";
- if (($res = sem_get($tok)) == FALSE) {
+ if (($res = sem_get($tok, ($is_exclusive ? 1 : LOCK_SHARE_MAX) )) == FALSE) {
return (FALSE);
}
if (sem_acquire($res)) {
{
$bantime = -1;
/* if it exists check for a valid challenge */
- if (($a_sem = Hardbans::lock_data()) != FALSE) {
+ if (($a_sem = Hardbans::lock_data(TRUE)) != FALSE) {
if (($hban = &Hardbans::load_data()) != FALSE) {
for ($e = 0 ; $e < $hban->item_n ; $e++) {
{
$found = FALSE;
/* if it exists check for a valid challenge */
- if (($a_sem = Hardbans::lock_data()) != FALSE) {
+ if (($a_sem = Hardbans::lock_data(TRUE)) != FALSE) {
if (($hban = &Hardbans::load_data()) != FALSE) {
return ($ret);
}
- static function lock_data($table_idx)
+ static function lock_data($is_exclusive, $table_idx)
{
GLOBAL $sess;
return (FALSE);
}
// WARNING monitor this step
- if (($res = @sem_get($tok)) == FALSE) {
+ if (($res = @sem_get($tok, ($is_exclusive ? 1 : LOCK_SHARE_MAX) )) == FALSE) {
return (FALSE);
}
if (sem_acquire($res)) {
ignore_user_abort(TRUE);
if ($first_loop == TRUE) {
- if (($sem = Bin5::lock_data($table_idx)) != FALSE) {
+ if (($sem = Bin5::lock_data(TRUE, $table_idx)) != FALSE) {
// Aggiorna l'expire time lato server
$S_load_stat['U_first_loop']++;
log_main("infolock: U");
Bin5::unlock_data($sem);
ignore_user_abort(FALSE);
- } // if (($sem = Bin5::lock_data($table ...
+ } // if (($sem = Bin5::lock_data(TRUE, $table ...
else {
ignore_user_abort(FALSE);
if ($user == FALSE) {
do {
ignore_user_abort(TRUE);
- if (($sem = Bin5::lock_data($table_idx)) == FALSE)
+ if (($sem = Bin5::lock_data(TRUE, $table_idx)) == FALSE)
break;
log_main("infolock: P");
* if $cur_step == -1 load the current state from the main struct
*/
ignore_user_abort(TRUE);
- $sem = Bin5::lock_data($table_idx);
+ $sem = Bin5::lock_data(TRUE, $table_idx);
if (($bri = Bin5::load_data($table_idx, $table_token)) == FALSE) {
Bin5::unlock_data($sem);
ignore_user_abort(FALSE);
}
else {
ignore_user_abort(TRUE);
- $sem = Bin5::lock_data($table_idx);
+ $sem = Bin5::lock_data(TRUE, $table_idx);
// if (($user = &$bri->get_user($sess, $idx)) == FALSE) {
if (($user = Bin5_user::load_data($table_idx, $proxy_step['i'], $sess)) == FALSE) {
Bin5::unlock_data($sem);
log_mop(0, 'bin::index_wr.php: COMM: '.xcapemesg($mesg));
-$sem = Bin5::lock_data($table_idx);
+$sem = Bin5::lock_data(TRUE, $table_idx);
if (($bri = Bin5::load_data($table_idx,$table_token)) == FALSE) {
echo "Bin5 Load data error";
if (isset($BRISK_SHOWHTML) == FALSE) {
$is_table = FALSE;
- $sem = Room::lock_data();
+ $sem = Room::lock_data(TRUE);
log_main("lock Room");
if (($room = Room::load_data()) == FALSE) {
log_crit("load_data failed");
/* Sync check (read only without modifications */
ignore_user_abort(TRUE);
if ($first_loop == TRUE) {
- if (($sem = Room::lock_data()) != FALSE) {
+ if (($sem = Room::lock_data(TRUE)) != FALSE) {
// Aggiorna l'expire time lato server
$S_load_stat['U_first_loop']++;
if (($user = User::load_data($proxy_step['i'], $sess)) == FALSE) {
log_main("infolock: U");
Room::unlock_data($sem);
ignore_user_abort(FALSE);
- } // if (($sem = Room::lock_data()) != FALSE) {
+ } // if (($sem = Room::lock_data(TRUE)) != FALSE) {
else {
// wait 20 secs, then restart the xhr
ignore_user_abort(FALSE);
if ($user == FALSE) {
do {
ignore_user_abort(TRUE);
- if (($sem = Room::lock_data()) == FALSE)
+ if (($sem = Room::lock_data(TRUE)) == FALSE)
break;
log_main("infolock: P");
* if $cur_step == -1 load the current state from the main struct
*/
ignore_user_abort(TRUE);
- $sem = Room::lock_data();
+ $sem = Room::lock_data(TRUE);
if (($room = Room::load_data()) == FALSE) {
Room::unlock_data($sem);
ignore_user_abort(FALSE);
else {
// TODO: verify if we can use only $user struct
ignore_user_abort(TRUE);
- $sem = Room::lock_data();
+ $sem = Room::lock_data(TRUE);
$S_load_stat['U_heavy']++;
if (($user = User::load_data($proxy_step['i'], $sess)) == FALSE) {
Room::unlock_data($sem);
$curtime = time();
$dt = date("H:i ", $curtime);
-$sem = Room::lock_data();
+$sem = Room::lock_data(TRUE);
if (($room = &Room::load_data()) == FALSE) {
echo "Load data error";
log_wr("Load data error");
if ($argz[0] == 'getchallenge') {
GLOBAL $cli_name;
- if (($a_sem = Challenges::lock_data()) != FALSE) {
+ if (($a_sem = Challenges::lock_data(TRUE)) != FALSE) {
log_main("chal lock data success");
if (($chals = &Challenges::load_data()) != FALSE) {
log_wr("INFO:SKIP:argz == warranty name: [".$cli_name."] AUTH: ".($user->flags & USER_FLAG_AUTH));
if ($user->flags & USER_FLAG_AUTH) {
- if (($wa_lock = Warrant::lock_data()) != FALSE) {
+ if (($wa_lock = Warrant::lock_data(TRUE)) != FALSE) {
if (($fp = @fopen(LEGAL_PATH."/warrant.txt", 'a')) != FALSE) {
/* Unix time | session | nickname | IP | where was | mesg */
fwrite($fp, sprintf("%ld|%s|%s|%s|\n", $curtime, $user->name, xcapelt(urldecode($cli_name)), xcapelt(urldecode($cli_email))));
log_wr("INFO:SKIP:argz == mesgtoadm name: [".$user->name."] AUTH: ".($user->flags & USER_FLAG_AUTH));
if ($user->flags & USER_FLAG_AUTH) {
- if (($wa_lock = Warrant::lock_data()) != FALSE) {
+ if (($wa_lock = Warrant::lock_data(TRUE)) != FALSE) {
if (($bdb = BriskDB::create()) != FALSE) {
$bdb->users_load();
break;
}
- if (($poll_lock = Poll::lock_data()) == FALSE) {
+ if (($poll_lock = Poll::lock_data(TRUE)) == FALSE) {
/* MLANG: "<b>E\' occorso un errore durante il salvataggio, riprova o contatta l\'amministratore.</b>" */
$mesg_to_user = sprintf('chatt_sub("%s", [2, "%s"],"%s");', $dt, NICKSERV, $mlang_indwr['commerr'][$G_lang]);
log_wr("break3");
//
// Create new spawned table
- $bri_sem = Bin5::lock_data($table_idx);
+ $bri_sem = Bin5::lock_data(TRUE, $table_idx);
$table_token = uniqid("");
$room->table[$table_idx]->table_token = $table_token;
$room->table[$table_idx]->table_start = $curtime;