X-Git-Url: http://git.roojs.org/?p=Pman.Core;a=blobdiff_plain;f=Notify.php;h=fd582092af5a14fa15dae313ff2f70dba6e54320;hp=95b446afaa4f0d390be8cd759f345147da0c7fb8;hb=HEAD;hpb=3dc17ed46ee979ebb35925dc54c270ae15d7e712 diff --git a/Notify.php b/Notify.php index 95b446af..3fd4c5b4 100644 --- a/Notify.php +++ b/Notify.php @@ -178,6 +178,12 @@ class Pman_Core_Notify extends Pman function get($r,$opts=array()) { + + // if ($this->database_is_locked()) { + // die("LATER - DATABASE IS LOCKED"); + //} + + $this->parseArgs($opts); //date_default_timezone_set('UTC'); @@ -225,6 +231,7 @@ class Pman_Core_Notify extends Pman if (!$this->force) { $w->whereAdd('act_when < NOW()'); // eg.. not if future.. } + $w->orderBy('act_when ASC'); // oldest first. $total = min($w->count(), $opts['limit']); @@ -293,11 +300,14 @@ class Pman_Core_Notify extends Pman $black = $this->server->isBlacklisted($email); if ($black !== false) { - + $this->logecho("Blacklisted - try giving it to next server"); if (false === $this->server->updateNotifyToNextServer($p)) { $ev = $this->addEvent('NOTIFY', $p, 'BLACKLISTED FROM our DB'); - $this->server->updateNotifyToNextServer($w, strtotime('NOW + 5 MINUTES'),true); + // we dont have an althenative server to update it with. + $this->logecho("Blacklisted - next server did not work - try again in 30 mins"); + $this->server->updateNotifyToNextServer($w, date("Y-m-d H:i:s", strtotime('NOW + 30 MINUTES')),true); // $this->errorHandler( $ev->remarks); + } continue; @@ -475,6 +485,8 @@ class Pman_Core_Notify extends Pman foreach($this->pool as $p) { //echo "CHECK PID: " . $p['pid'] . "\n"; + + $info = proc_get_status($p['proc']); //var_dump($info); @@ -522,8 +534,13 @@ class Pman_Core_Notify extends Pman //fclose($p['pipes'][1]); proc_close($p['proc']); - - + sleep(1); + clearstatcache(); + if (file_exists('/proc/'. $p['pid'])) { + $this->logecho("proc PID={$p['pid']} still here - trying to wait"); + pcntl_waitpid($p['pid'], $status, WNOHANG); + } + //clearstatcache(); //if (file_exists('/proc/'.$p['pid'])) { // $pool[] = $p; @@ -602,6 +619,7 @@ class Pman_Core_Notify extends Pman function clearOld() { if ($this->server->isFirstServer()) { + $p = DB_DataObject::factory($this->table); $p->whereAdd(" sent < '2000-01-01'