mirror of
https://github.com/warmcat/libwebsockets.git
synced 2025-03-09 00:00:04 +01:00
cpd: lws_system_cpd_start_defer
This commit is contained in:
parent
60b5ca649e
commit
c86e1c5b56
4 changed files with 28 additions and 2 deletions
|
@ -322,6 +322,9 @@ lws_dhcpc_status(struct lws_context *context, lws_sockaddr46 *sa46);
|
|||
LWS_EXTERN LWS_VISIBLE int
|
||||
lws_system_cpd_start(struct lws_context *context);
|
||||
|
||||
LWS_EXTERN LWS_VISIBLE void
|
||||
lws_system_cpd_start_defer(struct lws_context *cx, lws_usec_t defer_us);
|
||||
|
||||
|
||||
/**
|
||||
* lws_system_cpd_set() - report the result of the captive portal detection
|
||||
|
|
|
@ -70,11 +70,17 @@ lws_getaddrinfo46(struct lws *wsi, const char *ads, struct addrinfo **result)
|
|||
#endif
|
||||
#if defined(EAI_FAIL)
|
||||
|| n == EAI_FAIL
|
||||
#endif
|
||||
#if defined(EAI_AGAIN)
|
||||
|| n == EAI_AGAIN
|
||||
#endif
|
||||
) {
|
||||
#if defined(LWS_WITH_SECURE_STREAMS)
|
||||
|
||||
#endif
|
||||
wsi->dns_reachability = 1;
|
||||
lwsl_notice("%s: asking to recheck CPD\n", __func__);
|
||||
lws_system_cpd_start(wsi->a.context);
|
||||
lwsl_notice("%s: asking to recheck CPD in 1ms\n", __func__);
|
||||
lws_system_cpd_start_defer(wsi->a.context, LWS_US_PER_MS);
|
||||
}
|
||||
|
||||
lwsl_info("%s: getaddrinfo '%s' says %d\n", __func__, ads, n);
|
||||
|
|
|
@ -1401,6 +1401,22 @@ lws_system_cpd_start(struct lws_context *cx)
|
|||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
lws_system_deferred_cb(lws_sorted_usec_list_t *sul)
|
||||
{
|
||||
struct lws_context *cx =
|
||||
lws_container_of(sul, struct lws_context, sul_cpd_defer);
|
||||
|
||||
lws_system_cpd_start(cx);
|
||||
}
|
||||
|
||||
void
|
||||
lws_system_cpd_start_defer(struct lws_context *cx, lws_usec_t defer_us)
|
||||
{
|
||||
lws_sul_schedule(cx, 0, &cx->sul_cpd_defer,
|
||||
lws_system_deferred_cb, defer_us);
|
||||
}
|
||||
|
||||
static const char *cname[] = { "Unknown", "OK", "Captive", "No internet" };
|
||||
|
||||
void
|
||||
|
|
|
@ -397,6 +397,7 @@ struct lws_context {
|
|||
#if defined(LWS_WITH_SECURE_STREAMS)
|
||||
struct lws_ss_handle *ss_cpd;
|
||||
#endif
|
||||
lws_sorted_usec_list_t sul_cpd_defer;
|
||||
|
||||
#if defined(LWS_WITH_NETWORK)
|
||||
struct lws_context_per_thread pt[LWS_MAX_SMP];
|
||||
|
|
Loading…
Add table
Reference in a new issue