1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-11-17 18:45:10 +00:00

Merge remote branch 'origin/master' into lua-config

Conflicts:
	src/conky.cc
This commit is contained in:
Pavel Labath 2010-09-11 14:50:37 +02:00
commit ef24f62412
4 changed files with 46 additions and 32 deletions

View File

@ -258,7 +258,7 @@ int apcupsd_scan_arg(const char *arg)
if (sscanf(arg, "%63s %d", host, &port) != 2)
return 1;
apcupsd.port = htons(port);
apcupsd.port = port;
strncpy(apcupsd.host, host, sizeof(apcupsd.host));
return 0;
}

View File

@ -105,34 +105,31 @@ void ccurl_fetch_data(thread_handle &handle, const ccurl_location_ptr &curloc)
chunk.memory = NULL;
chunk.size = 0;
if (curl_global_init(CURL_GLOBAL_ALL) == 0) {
curl = curl_easy_init();
if (curl) {
DBGP("reading curl data from '%s'", curloc->uri);
curl_easy_setopt(curl, CURLOPT_URL, curloc->uri);
curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 1);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, ccurl_write_memory_callback);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *) &chunk);
curl_easy_setopt(curl, CURLOPT_USERAGENT, "conky-curl/1.0");
curl = curl_easy_init();
if (curl) {
DBGP("reading curl data from '%s'", curloc->uri);
curl_easy_setopt(curl, CURLOPT_URL, curloc->uri);
curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 1);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, ccurl_write_memory_callback);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *) &chunk);
curl_easy_setopt(curl, CURLOPT_USERAGENT, "conky-curl/1.0");
res = curl_easy_perform(curl);
if (res == CURLE_OK && chunk.size) {
long http_status_code;
res = curl_easy_perform(curl);
if (res == CURLE_OK && chunk.size) {
long http_status_code;
if(curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &http_status_code) == CURLE_OK && http_status_code == 200) {
std::lock_guard<std::mutex> lock(handle.mutex());
curloc->process_function(curloc->result, chunk.memory);
} else {
NORM_ERR("curl: no data from server");
}
free(chunk.memory);
if(curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &http_status_code) == CURLE_OK && http_status_code == 200) {
std::lock_guard<std::mutex> lock(handle.mutex());
curloc->process_function(curloc->result, chunk.memory);
} else {
NORM_ERR("curl: no data from server");
}
curl_easy_cleanup(curl);
free(chunk.memory);
} else {
NORM_ERR("curl: no data from server");
}
curl_global_cleanup();
curl_easy_cleanup(curl);
}
}

View File

@ -71,6 +71,9 @@
#if defined BUILD_WEATHER_XOAP || defined BUILD_RSS
#include <libxml/parser.h>
#endif
#ifdef BUILD_CURL
#include <curl/curl.h>
#endif
/* local headers */
#include "core.h"
@ -3190,6 +3193,11 @@ int main(int argc, char **argv)
g_signal_pending = 0;
clear_net_stats();
#ifdef BUILD_CURL
if(curl_global_init(CURL_GLOBAL_ALL))
NORM_ERR("curl_global_init() failed, you may not be able to use curl variables");
#endif
/* handle command line parameters that don't change configs */
#ifdef BUILD_X11
if (!setlocale(LC_CTYPE, "")) {
@ -3337,6 +3345,10 @@ int main(int argc, char **argv)
main_loop();
#ifdef BUILD_CURL
curl_global_cleanup();
#endif
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
kvm_close(kd);
#endif

View File

@ -698,6 +698,12 @@ static void imap_thread(thread_handle &handle, struct mail_s *mail)
int res;
fd_set fdset;
if (fail > 0) {
NORM_ERR("Trying IMAP connection again for %s@%s (try %u/%u)",
mail->user, mail->host, fail + 1, mail->retries);
resolved_host = 0; /* force us to resolve the hostname again */
sleep(fail); /* sleep more for the more failures we have */
}
if (!resolved_host) {
memset(&hints, 0, sizeof(struct addrinfo));
hints.ai_family = AF_UNSPEC;
@ -714,10 +720,6 @@ static void imap_thread(thread_handle &handle, struct mail_s *mail)
}
resolved_host = 1;
}
if (fail > 0) {
NORM_ERR("Trying IMAP connection again for %s@%s (try %u/%u)",
mail->user, mail->host, fail + 1, mail->retries);
}
do {
for (rp = ai; rp != NULL; rp = rp->ai_next) {
sockfd = socket(rp->ai_family, rp->ai_socktype, rp->ai_protocol);
@ -1041,6 +1043,13 @@ static void pop3_thread(thread_handle &handle, struct mail_s *mail)
struct timeval fetchtimeout;
int res;
fd_set fdset;
if (fail > 0) {
NORM_ERR("Trying POP3 connection again for %s@%s (try %u/%u)",
mail->user, mail->host, fail + 1, mail->retries);
resolved_host = 0; /* force us to resolve the hostname again */
sleep(fail); /* sleep more for the more failures we have */
}
if (!resolved_host) {
memset(&hints, 0, sizeof(struct addrinfo));
hints.ai_family = AF_UNSPEC;
@ -1055,11 +1064,7 @@ static void pop3_thread(thread_handle &handle, struct mail_s *mail)
fail++;
break;
}
resolved_host = 1;
}
if (fail > 0) {
NORM_ERR("Trying POP3 connection again for %s@%s (try %u/%u)",
mail->user, mail->host, fail + 1, mail->retries);
resolved_host = 1;
}
do {
for (rp = ai; rp != NULL; rp = rp->ai_next) {