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:
commit
ef24f62412
@ -258,7 +258,7 @@ int apcupsd_scan_arg(const char *arg)
|
|||||||
if (sscanf(arg, "%63s %d", host, &port) != 2)
|
if (sscanf(arg, "%63s %d", host, &port) != 2)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
apcupsd.port = htons(port);
|
apcupsd.port = port;
|
||||||
strncpy(apcupsd.host, host, sizeof(apcupsd.host));
|
strncpy(apcupsd.host, host, sizeof(apcupsd.host));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -105,34 +105,31 @@ void ccurl_fetch_data(thread_handle &handle, const ccurl_location_ptr &curloc)
|
|||||||
chunk.memory = NULL;
|
chunk.memory = NULL;
|
||||||
chunk.size = 0;
|
chunk.size = 0;
|
||||||
|
|
||||||
if (curl_global_init(CURL_GLOBAL_ALL) == 0) {
|
curl = curl_easy_init();
|
||||||
curl = curl_easy_init();
|
if (curl) {
|
||||||
if (curl) {
|
DBGP("reading curl data from '%s'", curloc->uri);
|
||||||
DBGP("reading curl data from '%s'", curloc->uri);
|
curl_easy_setopt(curl, CURLOPT_URL, curloc->uri);
|
||||||
curl_easy_setopt(curl, CURLOPT_URL, curloc->uri);
|
curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 1);
|
||||||
curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 1);
|
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, ccurl_write_memory_callback);
|
||||||
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, ccurl_write_memory_callback);
|
curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *) &chunk);
|
||||||
curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *) &chunk);
|
curl_easy_setopt(curl, CURLOPT_USERAGENT, "conky-curl/1.0");
|
||||||
curl_easy_setopt(curl, CURLOPT_USERAGENT, "conky-curl/1.0");
|
|
||||||
|
|
||||||
res = curl_easy_perform(curl);
|
res = curl_easy_perform(curl);
|
||||||
if (res == CURLE_OK && chunk.size) {
|
if (res == CURLE_OK && chunk.size) {
|
||||||
long http_status_code;
|
long http_status_code;
|
||||||
|
|
||||||
if(curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &http_status_code) == CURLE_OK && http_status_code == 200) {
|
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());
|
std::lock_guard<std::mutex> lock(handle.mutex());
|
||||||
curloc->process_function(curloc->result, chunk.memory);
|
curloc->process_function(curloc->result, chunk.memory);
|
||||||
} else {
|
|
||||||
NORM_ERR("curl: no data from server");
|
|
||||||
}
|
|
||||||
free(chunk.memory);
|
|
||||||
} else {
|
} else {
|
||||||
NORM_ERR("curl: no data from server");
|
NORM_ERR("curl: no data from server");
|
||||||
}
|
}
|
||||||
|
free(chunk.memory);
|
||||||
curl_easy_cleanup(curl);
|
} else {
|
||||||
|
NORM_ERR("curl: no data from server");
|
||||||
}
|
}
|
||||||
curl_global_cleanup();
|
|
||||||
|
curl_easy_cleanup(curl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
12
src/conky.cc
12
src/conky.cc
@ -71,6 +71,9 @@
|
|||||||
#if defined BUILD_WEATHER_XOAP || defined BUILD_RSS
|
#if defined BUILD_WEATHER_XOAP || defined BUILD_RSS
|
||||||
#include <libxml/parser.h>
|
#include <libxml/parser.h>
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef BUILD_CURL
|
||||||
|
#include <curl/curl.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
/* local headers */
|
/* local headers */
|
||||||
#include "core.h"
|
#include "core.h"
|
||||||
@ -3190,6 +3193,11 @@ int main(int argc, char **argv)
|
|||||||
g_signal_pending = 0;
|
g_signal_pending = 0;
|
||||||
clear_net_stats();
|
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 */
|
/* handle command line parameters that don't change configs */
|
||||||
#ifdef BUILD_X11
|
#ifdef BUILD_X11
|
||||||
if (!setlocale(LC_CTYPE, "")) {
|
if (!setlocale(LC_CTYPE, "")) {
|
||||||
@ -3337,6 +3345,10 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
main_loop();
|
main_loop();
|
||||||
|
|
||||||
|
#ifdef BUILD_CURL
|
||||||
|
curl_global_cleanup();
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
|
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
|
||||||
kvm_close(kd);
|
kvm_close(kd);
|
||||||
#endif
|
#endif
|
||||||
|
23
src/mail.cc
23
src/mail.cc
@ -698,6 +698,12 @@ static void imap_thread(thread_handle &handle, struct mail_s *mail)
|
|||||||
int res;
|
int res;
|
||||||
fd_set fdset;
|
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) {
|
if (!resolved_host) {
|
||||||
memset(&hints, 0, sizeof(struct addrinfo));
|
memset(&hints, 0, sizeof(struct addrinfo));
|
||||||
hints.ai_family = AF_UNSPEC;
|
hints.ai_family = AF_UNSPEC;
|
||||||
@ -714,10 +720,6 @@ static void imap_thread(thread_handle &handle, struct mail_s *mail)
|
|||||||
}
|
}
|
||||||
resolved_host = 1;
|
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 {
|
do {
|
||||||
for (rp = ai; rp != NULL; rp = rp->ai_next) {
|
for (rp = ai; rp != NULL; rp = rp->ai_next) {
|
||||||
sockfd = socket(rp->ai_family, rp->ai_socktype, rp->ai_protocol);
|
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;
|
struct timeval fetchtimeout;
|
||||||
int res;
|
int res;
|
||||||
fd_set fdset;
|
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) {
|
if (!resolved_host) {
|
||||||
memset(&hints, 0, sizeof(struct addrinfo));
|
memset(&hints, 0, sizeof(struct addrinfo));
|
||||||
hints.ai_family = AF_UNSPEC;
|
hints.ai_family = AF_UNSPEC;
|
||||||
@ -1055,11 +1064,7 @@ static void pop3_thread(thread_handle &handle, struct mail_s *mail)
|
|||||||
fail++;
|
fail++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
resolved_host = 1;
|
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);
|
|
||||||
}
|
}
|
||||||
do {
|
do {
|
||||||
for (rp = ai; rp != NULL; rp = rp->ai_next) {
|
for (rp = ai; rp != NULL; rp = rp->ai_next) {
|
||||||
|
Loading…
Reference in New Issue
Block a user