summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2009-12-14 15:19:37 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2009-12-14 15:19:37 +0100
commitf1d1a096c389b076007cda87c6e7db3172ed98db (patch)
tree26aa7ac4484c6f44322f717af45e2497e6800d55 /lib
parentb77941d725638702c3ca4d17bf97e0048d10f039 (diff)
downloadabrt-f1d1a096c389b076007cda87c6e7db3172ed98db.tar.gz
abrt-f1d1a096c389b076007cda87c6e7db3172ed98db.tar.xz
abrt-f1d1a096c389b076007cda87c6e7db3172ed98db.zip
get rid of ugly sleep call inside while()
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/Plugins/Catcut.cpp16
-rw-r--r--lib/Plugins/FileTransfer.cpp11
-rw-r--r--lib/Plugins/TicketUploader.cpp8
3 files changed, 21 insertions, 14 deletions
diff --git a/lib/Plugins/Catcut.cpp b/lib/Plugins/Catcut.cpp
index 9974faa..ebddfdd 100644
--- a/lib/Plugins/Catcut.cpp
+++ b/lib/Plugins/Catcut.cpp
@@ -50,7 +50,7 @@ send_string(const char *pURL,
return;
}
- do
+ while (1)
{
int content_length = strlen(pContent);
FILE* f = fmemopen((void*)pContent, content_length, "r");
@@ -63,9 +63,11 @@ send_string(const char *pURL,
if (!result)
return;
update_client(_("Sending failed, try it again: %s"), curl_easy_strerror((CURLcode)result));
+ if (--retryCount <= 0)
+ break;
+ /* retry the upload if not succesful, wait a bit before next try */
+ sleep(retryDelaySeconds);
}
- /*retry the upload if not succesful, wait a bit before next try*/
- while (--retryCount != 0 && (sleep(retryDelaySeconds), 1));
throw CABRTException(EXCEP_PLUGIN, "send_string: can't send string");
}
@@ -84,7 +86,7 @@ send_file(const char *pURL,
update_client(_("Sending file %s to %s"), pFilename, pURL);
- do
+ while (1)
{
FILE* f = fopen(pFilename, "r");
if (!f)
@@ -99,9 +101,11 @@ send_file(const char *pURL,
if (!result)
return;
update_client(_("Sending failed, try it again: %s"), curl_easy_strerror((CURLcode)result));
+ if (--retryCount <= 0)
+ break;
+ /* retry the upload if not succesful, wait a bit before next try */
+ sleep(retryDelaySeconds);
}
- /*retry the upload if not succesful, wait a bit before next try*/
- while (--retryCount != 0 && (sleep(retryDelaySeconds), 1));
throw CABRTException(EXCEP_PLUGIN, "send_file: can't send file");
}
diff --git a/lib/Plugins/FileTransfer.cpp b/lib/Plugins/FileTransfer.cpp
index 03ee464..c98645c 100644
--- a/lib/Plugins/FileTransfer.cpp
+++ b/lib/Plugins/FileTransfer.cpp
@@ -68,9 +68,8 @@ void CFileTransfer::SendFile(const char *pURL, const char *pFilename)
string wholeURL = concat_path_file(pURL, pFilename);
- int result;
int count = m_nRetryCount;
- do
+ while (1)
{
FILE *f;
struct stat buf;
@@ -99,12 +98,14 @@ void CFileTransfer::SendFile(const char *pURL, const char *pFilename)
curl_easy_setopt(curl, CURLOPT_READDATA, f);
curl_easy_setopt(curl, CURLOPT_INFILESIZE, buf.st_size);
/* everything is done here; result 0 means success */
- result = curl_easy_perform(curl);
+ int result = curl_easy_perform(curl);
curl_easy_cleanup(curl);
fclose(f);
+ if (result == 0 || --count <= 0)
+ break;
+ /* retry the upload if not succesful, wait a bit before next try */
+ sleep(m_nRetryDelay);
}
- /*retry the upload if not succesful, wait a bit before next try*/
- while (result != 0 && --count >= 0 && (sleep(m_nRetryDelay), 1));
}
/*
diff --git a/lib/Plugins/TicketUploader.cpp b/lib/Plugins/TicketUploader.cpp
index aa6d412..06b6cde 100644
--- a/lib/Plugins/TicketUploader.cpp
+++ b/lib/Plugins/TicketUploader.cpp
@@ -112,7 +112,7 @@ void CTicketUploader::SendFile(const char *pURL, const char *pFilename)
string wholeURL = concat_path_file(pURL, base);
int count = m_nRetryCount;
int result;
- do
+ while (1)
{
FILE* f = fopen(pFilename, "r");
if (!f)
@@ -144,9 +144,11 @@ void CTicketUploader::SendFile(const char *pURL, const char *pFilename)
{
update_client(_("Sending failed, trying again. %s"), curl_easy_strerror((CURLcode)result));
}
+ if (result == 0 || --count <= 0)
+ break;
+ /* retry the upload if not succesful, wait a bit before next try */
+ sleep(m_nRetryDelay);
}
- /*retry the upload if not succesful, wait a bit before next try*/
- while (result != 0 && --count != 0 && (sleep(m_nRetryDelay), 1));
if (count <= 0 && result != 0)
{