diff options
author | Christian Grothoff <christian@grothoff.org> | 2023-11-14 12:47:45 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2023-11-14 12:47:57 +0100 |
commit | 621592b808d1ea24cd3fb585984102bda9eccd6e (patch) | |
tree | 25273a9388865464f020bdd4f049c6741e2a2033 | |
parent | a2bc19c2e8a5a38f19d2c5da649b7ab4fca5162b (diff) | |
download | twister-621592b808d1ea24cd3fb585984102bda9eccd6e.tar.gz twister-621592b808d1ea24cd3fb585984102bda9eccd6e.tar.bz2 twister-621592b808d1ea24cd3fb585984102bda9eccd6e.zip |
-fix assertion failure
-rw-r--r-- | src/twister/taler-twister-service.c | 71 |
1 files changed, 30 insertions, 41 deletions
diff --git a/src/twister/taler-twister-service.c b/src/twister/taler-twister-service.c index e8d6204..ba6bbd1 100644 --- a/src/twister/taler-twister-service.c +++ b/src/twister/taler-twister-service.c @@ -238,7 +238,7 @@ struct HttpRequest /** * Did we suspend MHD processing? */ - int suspended; + enum GNUNET_GenericReturnValue suspended; /** * Did we pause CURL processing? @@ -490,7 +490,7 @@ curl_check_hdr (void *buffer, * its name, the struct contains response data as well. * @return #GNUNET_OK if it succeeds. */ -static int +static enum GNUNET_GenericReturnValue create_mhd_response_from_hr (struct HttpRequest *hr) { long resp_code; @@ -502,7 +502,6 @@ create_mhd_response_from_hr (struct HttpRequest *hr) "Response already set!\n"); return GNUNET_SYSERR; } - GNUNET_break (CURLE_OK == curl_easy_getinfo (hr->curl, CURLINFO_RESPONSE_CODE, @@ -510,18 +509,19 @@ create_mhd_response_from_hr (struct HttpRequest *hr) GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Creating MHD response with code %u\n", (unsigned int) resp_code); - hr->response_code = resp_code; - /* Note, will be NULL if io_buf does not represent * a JSON value. */ hr->json = json_loadb (hr->io_buf, hr->io_len, JSON_DECODE_ANY, &error); - GNUNET_assert (GNUNET_YES == hr->suspended); - MHD_resume_connection (hr->con); - hr->suspended = GNUNET_NO; + if (GNUNET_YES == hr->suspended) + { + MHD_resume_connection (hr->con); + hr->suspended = GNUNET_NO; + } + run_mhd_now (); return GNUNET_OK; } @@ -824,8 +824,6 @@ curl_task_download (void *cls) running = 0; mret = curl_multi_perform (curl_multi, &running); - - while (NULL != (msg = curl_multi_info_read (curl_multi, &msgnum))) { @@ -853,16 +851,10 @@ curl_task_download (void *cls) case CURLE_GOT_NOTHING: GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "CURL download completed.\n"); + hr->state = REQUEST_STATE_PROXY_DOWNLOAD_DONE; if (NULL == hr->response) GNUNET_assert (GNUNET_OK == create_mhd_response_from_hr (hr)); - hr->state = REQUEST_STATE_PROXY_DOWNLOAD_DONE; - if (GNUNET_YES == hr->suspended) - { - MHD_resume_connection (hr->con); - hr->suspended = GNUNET_NO; - } - run_mhd_now (); break; default: GNUNET_log (GNUNET_ERROR_TYPE_WARNING, @@ -1274,7 +1266,7 @@ flip_object (struct MHD_Connection *con, * @param hr contains the object whose field will be deleted. * @return #GNUNET_OK when the path was found, and deleted. */ -static int +static enum GNUNET_GenericReturnValue delete_object (struct MHD_Connection *con, struct HttpRequest *hr) { @@ -1417,10 +1409,10 @@ inflate_data (struct HttpRequest *request) * Unavailable" with a empty body (overriding every other mod that * the user might have given.) * - * @param request the HTTP object representing the current state. + * @param hr the HTTP object representing the current state. */ static void -create_response_with_chaos_rate (struct HttpRequest *request) +create_response_with_chaos_rate (struct HttpRequest *hr) { uint64_t random; void *resp_buf; @@ -1431,24 +1423,23 @@ create_response_with_chaos_rate (struct HttpRequest *request) TWISTER_LOG_INFO ("p: %llu, random: %llu\n", (unsigned long long) chaos_rate, (unsigned long long) random); - if (random < chaos_rate) { /* p won */ TWISTER_LOG_INFO ("Chaos probability won the case.\n"); resp_buf = "Service unavailable"; resp_len = strlen (resp_buf); - request->response_code = MHD_HTTP_SERVICE_UNAVAILABLE; + hr->response_code = MHD_HTTP_SERVICE_UNAVAILABLE; } else { - resp_len = request->io_len; - resp_buf = request->io_buf; + resp_len = hr->io_len; + resp_buf = hr->io_buf; } - request->response = MHD_create_response_from_buffer - (resp_len, - resp_buf, - MHD_RESPMEM_MUST_COPY); + hr->response + = MHD_create_response_from_buffer (resp_len, + resp_buf, + MHD_RESPMEM_MUST_COPY); } @@ -1487,7 +1478,6 @@ create_response (void *cls, void **con_cls) { struct HttpRequest *hr = *con_cls; - struct HttpResponseHeader *header; (void) cls; (void) url; @@ -1610,9 +1600,10 @@ create_response (void *cls, "Will flip path in request: %s\n", flip_path_ul); - if (GNUNET_OK == flip_object (con, - hr->json, - flip_path_ul)) + if (GNUNET_OK == + flip_object (con, + hr->json, + flip_path_ul)) { GNUNET_free (flip_path_ul); flip_path_ul = NULL; @@ -1838,6 +1829,7 @@ create_response (void *cls, if (REQUEST_STATE_PROXY_DOWNLOAD_DONE != hr->state) { + GNUNET_assert (GNUNET_NO == hr->suspended); MHD_suspend_connection (con); hr->suspended = GNUNET_YES; return MHD_YES; /* wait for curl */ @@ -1879,16 +1871,14 @@ create_response (void *cls, if (NULL != modify_path_dl) { - int ret; + enum GNUNET_GenericReturnValue ret; TWISTER_LOG_DEBUG ("Will modify path: %s to value %s\n", modify_path_dl, modify_value); - ret = modify_object (con, hr->json, modify_path_dl); - if ((GNUNET_OK == ret) || (GNUNET_SYSERR == ret)) { GNUNET_free (modify_path_dl); @@ -1921,17 +1911,16 @@ create_response (void *cls, { size_t fake_len; - TWISTER_LOG_DEBUG - ("Will (badly) truncate the response.\n"); - fake_len = GNUNET_CRYPTO_random_u32 - (GNUNET_CRYPTO_QUALITY_WEAK, hr->io_len); + TWISTER_LOG_DEBUG ("Will (badly) truncate the response.\n"); + fake_len = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, + hr->io_len); hr->io_len = fake_len; malform = GNUNET_NO; } create_response_with_chaos_rate (hr); - for (header = hr->header_head; + for (struct HttpResponseHeader *header = hr->header_head; NULL != header; header = header->next) { @@ -2227,7 +2216,7 @@ do_shutdown (void *cls) NULL != hr; hr = hr->next) { - if (hr->suspended) + if (GNUNET_YES == hr->suspended) { hr->suspended = GNUNET_NO; MHD_resume_connection (hr->con); |