summaryrefslogtreecommitdiff
path: root/src/lib/update.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2014-05-02 20:06:58 +0100
committerCarl Hetherington <cth@carlh.net>2014-05-02 20:06:58 +0100
commit2f61270d2726445f562efc0e4b33fa19ba235183 (patch)
tree01420c5e3a5aa06217300ddfcb20b16569a727c0 /src/lib/update.cc
parent2587e198b0bab725db51808a414713915cd3f3fb (diff)
Comments.
Diffstat (limited to 'src/lib/update.cc')
-rw-r--r--src/lib/update.cc10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/lib/update.cc b/src/lib/update.cc
index a98ee5b5d..019db8e76 100644
--- a/src/lib/update.cc
+++ b/src/lib/update.cc
@@ -34,6 +34,7 @@ using std::string;
using std::stringstream;
using boost::lexical_cast;
+/** Singleton instance */
UpdateChecker* UpdateChecker::_instance = 0;
static size_t
@@ -42,6 +43,9 @@ write_callback_wrapper (void* data, size_t size, size_t nmemb, void* user)
return reinterpret_cast<UpdateChecker*>(user)->write_callback (data, size, nmemb);
}
+/** Construct an UpdateChecker. This sets things up and starts a thread to
+ * do the work.
+ */
UpdateChecker::UpdateChecker ()
: _buffer (new char[BUFFER_SIZE])
, _offset (0)
@@ -73,6 +77,7 @@ UpdateChecker::~UpdateChecker ()
delete[] _buffer;
}
+/** Start running the update check */
void
UpdateChecker::run ()
{
@@ -85,6 +90,7 @@ void
UpdateChecker::thread ()
{
while (1) {
+ /* Block until there is something to do */
boost::mutex::scoped_lock lock (_process_mutex);
while (_to_do == 0) {
_condition.wait (lock);
@@ -94,12 +100,16 @@ UpdateChecker::thread ()
try {
_offset = 0;
+
+ /* Perform the request */
int r = curl_easy_perform (_curl);
if (r != CURLE_OK) {
set_state (FAILED);
return;
}
+
+ /* Parse the reply */
_buffer[_offset] = '\0';
stringstream s;