1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-09 00:00:00 +01:00

do not interrupt curl_perform() during shutdown (leads to inconsistent state of Curl handle)

This commit is contained in:
Steffen Vogel 2015-10-13 16:11:58 +02:00
parent b26a92165d
commit 3b437c1c0c
2 changed files with 8 additions and 3 deletions

View file

@ -19,6 +19,7 @@
#include <curl/curl.h>
#include <uuid/uuid.h>
#include <jansson.h>
#include <pthread.h>
#include "ngsi.h"
#include "utils.h"
@ -96,9 +97,13 @@ static int ngsi_request(CURL *handle, const char *endpoint, const char *operatio
curl_easy_setopt(handle, CURLOPT_POSTFIELDSIZE, strlen(post));
curl_easy_setopt(handle, CURLOPT_POSTFIELDS, post);
debug(20, "Request to context broker:\n%s", post);
debug(18, "Request to context broker: %s\n%s", url, post);
int old; /* We don't want to leave the CUrl handle in an invalid state */
pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &old);
CURLcode ret = curl_easy_perform(handle);
pthread_setcancelstate(old, NULL);
if (ret)
error("HTTP request failed: %s", curl_easy_strerror(ret));

View file

@ -48,7 +48,7 @@ static void quit()
list_destroy(&nodes);
config_destroy(&config);
info("Goodbye!");
info(GRN("Goodbye!"));
_exit(EXIT_SUCCESS);
}