mirror of
https://github.com/warmcat/libwebsockets.git
synced 2025-03-09 00:00:04 +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:
parent
c9e698ab02
commit
c4327e7f8e
4 changed files with 29 additions and 5 deletions
5
.gitignore
vendored
5
.gitignore
vendored
|
@ -57,3 +57,8 @@ doc
|
|||
/bb/
|
||||
/openssl3/
|
||||
/bb-linkit/
|
||||
/bq/
|
||||
/cros/
|
||||
/q/
|
||||
/b1/
|
||||
/destdir/
|
||||
|
|
|
@ -318,6 +318,12 @@ 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);
|
||||
|
||||
typedef int (* const secstream_protocol_connect_munge_t)(lws_ss_handle_t *h,
|
||||
char *buf, size_t len, struct lws_client_connect_info *i,
|
||||
union lws_ss_contemp *ct);
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -183,7 +183,7 @@ lws_ss_backoff(lws_ss_handle_t *h)
|
|||
}
|
||||
|
||||
int
|
||||
lws_ss_client_connect(lws_ss_handle_t *h)
|
||||
_lws_ss_client_connect(lws_ss_handle_t *h, int is_retry)
|
||||
{
|
||||
struct lws_client_connect_info i;
|
||||
const struct ss_pcols *ssp;
|
||||
|
@ -205,6 +205,9 @@ lws_ss_client_connect(lws_ss_handle_t *h)
|
|||
if (h->h_sink)
|
||||
return 0;
|
||||
|
||||
if (!is_retry)
|
||||
h->retry = 0;
|
||||
|
||||
memset(&i, 0, sizeof i); /* otherwise uninitialized garbage */
|
||||
i.context = h->context;
|
||||
|
||||
|
@ -289,6 +292,11 @@ 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
|
||||
|
@ -435,8 +443,9 @@ lws_ss_create(struct lws_context *context, int tsi, const lws_ss_info_t *ssi,
|
|||
|
||||
lws_ss_event_helper(h, LWSSSCS_CREATING);
|
||||
|
||||
if (!ssi->register_sink && (h->policy->flags & LWSSSPOLF_NAILED_UP))
|
||||
if (lws_ss_client_connect(h))
|
||||
if (!ssi->register_sink &&
|
||||
((h->policy->flags & LWSSSPOLF_NAILED_UP)))
|
||||
if (_lws_ss_client_connect(h, 0))
|
||||
lws_ss_backoff(h);
|
||||
|
||||
return 0;
|
||||
|
@ -503,7 +512,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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue