Mercurial > hg > ywww
changeset 30:b1bbf44c701b
standarise semaphore use
author | Robert Boland <robert@markup.co.uk> |
---|---|
date | Fri, 04 Jan 2019 08:50:23 -0500 |
parents | f024f2f08994 |
children | 4124f103b46b |
files | xml/amazonBookSearch.php |
diffstat | 1 files changed, 11 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/xml/amazonBookSearch.php Fri Jan 04 08:49:25 2019 -0500 +++ b/xml/amazonBookSearch.php Fri Jan 04 08:50:23 2019 -0500 @@ -96,14 +96,20 @@ $gotit=0; $semaphore = new SyncSemaphore("Amazon"); $gotit = $semaphore->lock(1000); - file_put_contents('/var/ywww/debug/phpDebug', - "Got it: ".(int)$gotit." 3\n",FILE_APPEND); - if (!$gotit) { $gotit = $semaphore->lock(1000); } + if (!$gotit) { + file_put_contents('/var/ywww/debug/phpDebug', + "Got it: ".(int)$gotit." 3\n",FILE_APPEND); + $gotit=$semaphore->lock(1000); + file_put_contents('/var/ywww/debug/phpDebug', + "Got it: ".(int)$gotit." 3a\n",FILE_APPEND); + } $ret = curl_exec($crl); curl_close($crl); + usleep(500000); if ($gotit) { - usleep(500000); - file_put_contents('/var/ywww/debug/phpDebug',"Unlocking 3\n",FILE_APPEND); $semaphore->unlock(); } + else { + file_put_contents('/var/ywww/debug/phpDebug',"W/o lock 3b\n",FILE_APPEND); + } echo $ret;