fix fakebank issue with timeouts in multi-threaded mode resulting in NPE

This commit is contained in:
Christian Grothoff 2021-12-09 22:14:42 +01:00
parent 6c57b33746
commit 6dd4a90abd
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC

View File

@ -480,11 +480,14 @@ lp_trigger (struct LongPoller *lp,
MHD_resume_connection (lp->conn); MHD_resume_connection (lp->conn);
GNUNET_free (lp); GNUNET_free (lp);
h->mhd_again = true; h->mhd_again = true;
if (NULL != h->mhd_task) if (-1 != h->lp_event)
GNUNET_SCHEDULER_cancel (h->mhd_task); {
h->mhd_task = if (NULL != h->mhd_task)
GNUNET_SCHEDULER_add_now (&run_mhd, GNUNET_SCHEDULER_cancel (h->mhd_task);
h); h->mhd_task =
GNUNET_SCHEDULER_add_now (&run_mhd,
h);
}
} }
@ -2413,6 +2416,7 @@ schedule_httpd (struct TALER_FAKEBANK_Handle *h)
MHD_UNSIGNED_LONG_LONG timeout; MHD_UNSIGNED_LONG_LONG timeout;
struct GNUNET_TIME_Relative tv; struct GNUNET_TIME_Relative tv;
GNUNET_assert (-1 != h->mhd_fd);
haveto = MHD_get_timeout (h->mhd_bank, haveto = MHD_get_timeout (h->mhd_bank,
&timeout); &timeout);
if (MHD_YES == haveto) if (MHD_YES == haveto)
@ -2450,6 +2454,7 @@ schedule_httpd (struct TALER_FAKEBANK_Handle *h)
MHD_UNSIGNED_LONG_LONG timeout; MHD_UNSIGNED_LONG_LONG timeout;
struct GNUNET_TIME_Relative tv; struct GNUNET_TIME_Relative tv;
GNUNET_assert (-1 == h->lp_event);
FD_ZERO (&rs); FD_ZERO (&rs);
FD_ZERO (&ws); FD_ZERO (&ws);
FD_ZERO (&es); FD_ZERO (&es);
@ -2521,6 +2526,7 @@ run_mhd (void *cls)
h->mhd_again = false; h->mhd_again = false;
MHD_run (h->mhd_bank); MHD_run (h->mhd_bank);
} }
GNUNET_assert (-1 == h->lp_event);
schedule_httpd (h); schedule_httpd (h);
} }
@ -2554,6 +2560,7 @@ TALER_FAKEBANK_start2 (uint16_t port,
GNUNET_assert (strlen (currency) < TALER_CURRENCY_LEN); GNUNET_assert (strlen (currency) < TALER_CURRENCY_LEN);
h = GNUNET_new (struct TALER_FAKEBANK_Handle); h = GNUNET_new (struct TALER_FAKEBANK_Handle);
h->lp_event = -1; h->lp_event = -1;
h->mhd_fd = -1;
h->port = port; h->port = port;
h->ram_limit = ram_limit; h->ram_limit = ram_limit;
h->serial_counter = 0; h->serial_counter = 0;