comparison xml/amazonBookSearch.php @ 23:d606320ec331

post-5.7-upgrade efforts to reduce dropped connections, db insertion fails
author Charlie Root
date Sun, 30 Dec 2018 07:00:09 -0500
parents 46382face560
children b1bbf44c701b
comparison
equal deleted inserted replaced
22:69c37b58d091 23:d606320ec331
93 curl_setopt ($crl, CURLOPT_ENCODING , "gzip"); 93 curl_setopt ($crl, CURLOPT_ENCODING , "gzip");
94 curl_setopt ($crl, CURLOPT_RETURNTRANSFER, 1); 94 curl_setopt ($crl, CURLOPT_RETURNTRANSFER, 1);
95 curl_setopt ($crl, CURLOPT_CONNECTTIMEOUT, $timeout); 95 curl_setopt ($crl, CURLOPT_CONNECTTIMEOUT, $timeout);
96 $gotit=0; 96 $gotit=0;
97 $semaphore = new SyncSemaphore("Amazon"); 97 $semaphore = new SyncSemaphore("Amazon");
98 $gotit = $semaphore->lock(4000); 98 $gotit = $semaphore->lock(1000);
99 file_put_contents('/var/ywww/debug/phpDebug', 99 file_put_contents('/var/ywww/debug/phpDebug',
100 "Got it: ".(int)$gotit." 3\n",FILE_APPEND); 100 "Got it: ".(int)$gotit." 3\n",FILE_APPEND);
101 if (!$gotit) { $gotit = $semaphore->lock(20000); } 101 if (!$gotit) { $gotit = $semaphore->lock(1000); }
102 $ret = curl_exec($crl); 102 $ret = curl_exec($crl);
103 curl_close($crl); 103 curl_close($crl);
104 if ($gotit) { 104 if ($gotit) {
105 usleep(1000000); 105 usleep(500000);
106 file_put_contents('/var/ywww/debug/phpDebug',"Unlocking 3\n",FILE_APPEND); 106 file_put_contents('/var/ywww/debug/phpDebug',"Unlocking 3\n",FILE_APPEND);
107 $semaphore->unlock(); 107 $semaphore->unlock();
108 } 108 }
109 echo $ret; 109 echo $ret;