log_only("PUT_VAR FALLITA ".strlen(serialize($hban)));
log_only(serialize($hban));
}
+ log_shme("Hardban::save_data2");
+
}
$hban->shm_sz = $shm_sz;
log_only("hardban count ".count($hban->item)." _n: ".$hban->item_n);
$hban->mod = FALSE;
- if (shm_put_var($shm, $tok, $hban) != FALSE) {
+ if (@shm_put_var($shm, $tok, $hban) != FALSE) {
shm_detach($shm);
+ log_shme("Hardban::save_data");
return (TRUE);
}
$hban->mod = $oldmod;
return (FALSE);
}
- 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) {
- return (FALSE);
- }
- if (sem_acquire($res)) {
- self::$delta_t = microtime(TRUE);
- log_lock("LOCK hardbans [".self::$delta_t."]");
- return ($res);
- }
- else
+ if (($res = file_lock(FTOK_PATH."/hardbans", $is_exclusive)) != FALSE) {
+ self::$delta_t = microtime(TRUE);
+ log_lock("LOCK hardbans [".self::$delta_t."]");
+
+ return ($res);
+ }
+
return (FALSE);
}
- function unlock_data($res)
+ static function unlock_data($res)
{
GLOBAL $sess;
log_lock("UNLOCK hardbans [".(microtime(TRUE) - (self::$delta_t))."]");
- return (sem_release($res));
+ file_unlock($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) {