Пример #1
0
 /**
  * 捕获锁
  *
  * @param [type] $name
  *            [description]
  * @param bool $sync
  *            是否同步阻止
  * @return [type] [description]
  */
 public function lock($timeoutsec = 10, $sync = TRUE)
 {
     // XXX 暂时去除锁调试数据库冲突
     return true;
     if (!$this->mc) {
         return false;
     }
     if ($this->is_lock()) {
         return true;
     }
     $max_block_time = $timeoutsec;
     $key = $this->get_key();
     do {
         $re = $this->mc->add($key, 1, $timeoutsec);
         if ($re == true) {
             break;
         }
         CommonUtilLog::record(CommonUtilLog::DEBUG, 'get_locker', [$key]);
         sleep(1);
     } while ($sync && $max_block_time--);
     $this->_locked = $re;
     if ($this->_locked) {
         $this->_lockexpiretime = time() + $timeoutsec;
     }
     return $re;
 }
Пример #2
0
 /**
  * 处理消息
  *
  * @param string $postData
  *            客户端传上了的 经过压缩和Base64 编码的数据
  * @return array 返回客户端的数据
  */
 public function processMessage($postData)
 {
     if (empty($postData)) {
         return "f:" . __LINE__;
     }
     // 解压缩数据
     $messagesData = CommonUtilMessage::decodeMessage($postData);
     if (is_null($messagesData)) {
         CommonUtilLog::record(CommonUtilLog::ERROR, 'processMessage', [$postData]);
         return "f:" . __LINE__;
     }
     $returnData = $this->__processMessages($messagesData);
     return $returnData;
 }