1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-30 00:00:16 +01:00

ss: reset retry count for explicit connection request

This differentiates between client connections for retry / writeable requests
and explicit lws_ss_client_connect() api calls.  The former effectively uses
retry / backoff, and the latter resets the retry / backoff.

If you receive ALL_RETRIES_FAILED due to the retry policy, you can do whatever
you need to do there and call lws_ss_client_connect() to try to connect again
with a fresh, reset retry / backoff state.
This commit is contained in:
Andy Green 2020-06-26 11:28:25 +01:00
parent 2ba3b7b72b
commit 64aee81ba7
3 changed files with 20 additions and 8 deletions

View file

@ -377,6 +377,9 @@ int
lws_ss_exp_cb_metadata(void *priv, const char *name, char *out, size_t *pos,
size_t olen, size_t *exp_ofs);
int
_lws_ss_client_connect(lws_ss_handle_t *h, int is_retry);
int
lws_ss_sys_cpd(struct lws_context *cx);

View file

@ -351,7 +351,7 @@ lws_ss_deserialize_parse(struct lws_ss_serialization_parser *par,
goto hangup;
par->ps = RPAR_TYPE;
if (*pss)
lws_ss_client_connect(*pss);
_lws_ss_client_connect(*pss, 0);
break;
case LWSSS_SER_TXPRE_STREAMTYPE:

View file

@ -294,12 +294,8 @@ lws_ss_smd_tx_cb(lws_sorted_usec_list_t *sul)
#endif
/*
* This is a local SS binding to a local SMD server
*/
int
lws_ss_client_connect(lws_ss_handle_t *h)
_lws_ss_client_connect(lws_ss_handle_t *h, int is_retry)
{
const char *prot, *_prot, *ipath, *_ipath, *ads, *_ads;
struct lws_client_connect_info i;
@ -323,6 +319,9 @@ lws_ss_client_connect(lws_ss_handle_t *h)
if (h->h_sink)
return 0;
if (!is_retry)
h->retry = 0;
#if defined(LWS_WITH_SYS_SMD)
if (h->policy == &pol_smd) {
@ -473,6 +472,12 @@ lws_ss_client_connect(lws_ss_handle_t *h)
return 0;
}
int
lws_ss_client_connect(lws_ss_handle_t *h)
{
return _lws_ss_client_connect(h, 0);
}
/*
* Public API
*/
@ -661,7 +666,7 @@ late_bail:
)
#endif
))
if (lws_ss_client_connect(h))
if (_lws_ss_client_connect(h, 0))
lws_ss_backoff(h);
return 0;
@ -760,7 +765,11 @@ lws_ss_request_tx(lws_ss_handle_t *h)
h->seqstate = SSSEQ_TRY_CONNECT;
lws_ss_event_helper(h, LWSSSCS_POLL);
if (lws_ss_client_connect(h))
/*
* Retries operate via lws_ss_request_tx(), explicitly ask for a
* reconnection to clear the retry limit
*/
if (_lws_ss_client_connect(h, 1))
lws_ss_backoff(h);
}