From 9d9875c39d91070f62f041284b4213f1fc643498 Mon Sep 17 00:00:00 2001 From: Jean Paul Galea Date: Tue, 14 Apr 2015 09:20:38 +0200 Subject: [PATCH] Set __YKVAL_SYNC_CURL_OPTS__ for resync requests. - Ensure sync/resync requests set the same curl options. - This changes a debug message from "url is " to "YK-VAL resync adding URL: " - curlopts is now a property of SyncLib class. Removes duplication between sync/resync code. --- ykval-synclib.php | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/ykval-synclib.php b/ykval-synclib.php index 8777f09..55547d6 100644 --- a/ykval-synclib.php +++ b/ykval-synclib.php @@ -36,6 +36,7 @@ class SyncLib { public $syncServers = null; public $dbConn = null; + public $curlopts = array(); function __construct($logname='ykval-synclib') { @@ -46,6 +47,9 @@ class SyncLib $this->isConnected=$this->db->connect(); $this->server_nonce=md5(uniqid(rand())); + if (array_key_exists('__YKVAL_SYNC_CURL_OPTS__', $baseParams)) { + $this->curlopts = $baseParams['__YKVAL_SYNC_CURL_OPTS__']; + } } function addField($name, $value) @@ -326,12 +330,9 @@ class SyncLib "&" . $this->otpPartFromInfoString($entry['info']); /* Send out sync request */ - $this->log(LOG_DEBUG, 'url is ' . $url); - curl_setopt($ch, CURLOPT_URL, $url); - curl_setopt($ch, CURLOPT_USERAGENT, "YK-VAL"); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); - curl_setopt($ch, CURLOPT_FAILONERROR, true); - curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); + + curl_settings($this, "YK-VAL resync", $ch, $url, $timeout, $this->curlopts); + $response = curl_exec($ch); if ($response==False) { @@ -430,17 +431,10 @@ class SyncLib "&" . $this->otpPartFromInfoString($row['info']); } - global $baseParams; - $curlopts = array(); - - if (array_key_exists('__YKVAL_SYNC_CURL_OPTS__', $baseParams)) { - $curlopts = $baseParams['__YKVAL_SYNC_CURL_OPTS__']; - } - /* Send out requests */ - $ans_arr=$this->retrieveURLasync_wrap($urls, $ans_req, $timeout, $curlopts); + $ans_arr=$this->retrieveURLasync_wrap($urls, $ans_req, $timeout, $this->curlopts); if (!is_array($ans_arr)) { $this->log(LOG_WARNING, 'No responses from validation server pool');