aboutsummaryrefslogtreecommitdiff
path: root/lib/abstract
diff options
context:
space:
mode:
authorAndy Green <andy@warmcat.com>2019-08-08 06:30:14 +0100
committerAndy Green <andy@warmcat.com>2019-08-08 09:45:09 +0100
commitfed78bef4246389cd53215ee0e2671d3bac35df1 (patch)
tree41f048d689474b1ca2cc86d955c32b17e682ebc6 /lib/abstract
parentc27c38ffbc5c7058a3622f5ad1dd66dce118eaff (diff)
downloadlibwebsockets-fed78bef4246389cd53215ee0e2671d3bac35df1.tar.gz
sequencer: upgrade timeout to use us
Adapt service loops and event libs to use microsecond waits internally, for hrtimer and sequencer. Reduce granularity according to platform / event lib wait. Add a helper so there's a single place to extend it.
Diffstat (limited to 'lib/abstract')
-rw-r--r--lib/abstract/test-sequencer.c14
-rw-r--r--lib/abstract/transports/raw-skt.c6
-rw-r--r--lib/abstract/transports/unit-test.c26
3 files changed, 24 insertions, 22 deletions
diff --git a/lib/abstract/test-sequencer.c b/lib/abstract/test-sequencer.c
index 89eefb3f..2872aef3 100644
--- a/lib/abstract/test-sequencer.c
+++ b/lib/abstract/test-sequencer.c
@@ -21,7 +21,7 @@
*
* A helper for running multiple unit tests against abstract protocols.
*
- * An lws_sequencer_t is used to base its actions in the event loop and manage
+ * An lws_seq_t is used to base its actions in the event loop and manage
* the sequencing of multiple tests. A new abstract connection is instantiated
* for each test using te
*/
@@ -35,7 +35,7 @@ struct lws_seq_test_sequencer {
struct lws_context *context;
struct lws_vhost *vhost;
- lws_sequencer_t *unit_test_seq;
+ lws_seq_t *unit_test_seq;
/* holds the per-test token for the unit-test transport to consume */
lws_token_map_t uttt[4];
@@ -88,7 +88,7 @@ unit_test_result_cb(const void *cb_user, int disposition)
return -1;
}
- lws_sequencer_queue_event(s->unit_test_seq, r, NULL, NULL);
+ lws_seq_queue_event(s->unit_test_seq, r, NULL, NULL);
((struct lws_seq_test_sequencer *)s)->instance = NULL;
@@ -115,7 +115,7 @@ test_sequencer_cb(struct lws_sequencer *seq, void *user, int event, void *data,
switch ((int)event) {
case LWSSEQ_CREATED: /* our sequencer just got started */
lwsl_notice("%s: %s: created\n", __func__,
- lws_sequencer_name(seq));
+ lws_seq_name(seq));
s->state = 0; /* first thing we'll do is the first url */
goto step;
@@ -178,7 +178,7 @@ pass:
s->args.results[s->state] = LPE_SUCCEEDED;
done:
- lws_sequencer_timeout(lws_sequencer_from_user(s), 0);
+ lws_seq_timeout_us(lws_seq_from_user(s), LWSSEQTO_NONE);
s->state++;
step:
if (!s->args.tests[s->state].name) {
@@ -233,7 +233,7 @@ int
lws_abs_unit_test_sequencer(const lws_test_sequencer_args_t *args)
{
struct lws_seq_test_sequencer *s;
- lws_sequencer_t *seq;
+ lws_seq_t *seq;
lws_seq_info_t i;
memset(&i, 0, sizeof(i));
@@ -247,7 +247,7 @@ lws_abs_unit_test_sequencer(const lws_test_sequencer_args_t *args)
* Create a sequencer in the event loop to manage the tests
*/
- seq = lws_sequencer_create(&i);
+ seq = lws_seq_create(&i);
if (!seq) {
lwsl_err("%s: unable to create sequencer\n", __func__);
return 1;
diff --git a/lib/abstract/transports/raw-skt.c b/lib/abstract/transports/raw-skt.c
index 683efad9..74f08abc 100644
--- a/lib/abstract/transports/raw-skt.c
+++ b/lib/abstract/transports/raw-skt.c
@@ -97,7 +97,7 @@ callback_abs_client_raw_skt(struct lws *wsi, enum lws_callback_reasons reason,
* our lifecycle events
*/
- lws_sequencer_queue_event(wsi->seq, LWSSEQ_WSI_CONNECTED,
+ lws_seq_queue_event(wsi->seq, LWSSEQ_WSI_CONNECTED,
wsi, NULL);
break;
@@ -112,7 +112,7 @@ callback_abs_client_raw_skt(struct lws *wsi, enum lws_callback_reasons reason,
* our lifecycle events
*/
- lws_sequencer_queue_event(wsi->seq, LWSSEQ_WSI_CONN_FAIL,
+ lws_seq_queue_event(wsi->seq, LWSSEQ_WSI_CONN_FAIL,
wsi, NULL);
goto close_path;
@@ -128,7 +128,7 @@ callback_abs_client_raw_skt(struct lws *wsi, enum lws_callback_reasons reason,
* our lifecycle events
*/
- lws_sequencer_queue_event(wsi->seq, LWSSEQ_WSI_CONN_CLOSE,
+ lws_seq_queue_event(wsi->seq, LWSSEQ_WSI_CONN_CLOSE,
wsi, NULL);
close_path:
diff --git a/lib/abstract/transports/unit-test.c b/lib/abstract/transports/unit-test.c
index 3be03ed3..c8918617 100644
--- a/lib/abstract/transports/unit-test.c
+++ b/lib/abstract/transports/unit-test.c
@@ -33,7 +33,7 @@ typedef struct lws_abstxp_unit_test_priv {
char note[128];
struct lws_abs *abs;
- lws_sequencer_t *seq;
+ lws_seq_t *seq;
lws_unit_test_t *current_test;
lws_unit_test_packet_t *expect;
lws_unit_test_packet_test_cb result_cb;
@@ -78,7 +78,7 @@ lws_unit_test_packet_dispose(abs_unit_test_priv_t *priv,
priv->disposition = disp;
- lws_sequencer_queue_event(priv->seq, UTSEQ_MSG_DISPOSITION_KNOWN,
+ lws_seq_queue_event(priv->seq, UTSEQ_MSG_DISPOSITION_KNOWN,
NULL, NULL);
return disp;
@@ -135,10 +135,10 @@ unit_test_sequencer_cb(struct lws_sequencer *seq, void *user, int event,
switch ((int)event) {
case LWSSEQ_CREATED: /* our sequencer just got started */
lwsl_notice("%s: %s: created\n", __func__,
- lws_sequencer_name(seq));
+ lws_seq_name(seq));
if (s->ai->at->client_conn(s->ai)) {
lwsl_notice("%s: %s: abstract client conn failed\n",
- __func__, lws_sequencer_name(seq));
+ __func__, lws_seq_name(seq));
return LWSSEQ_RET_DESTROY;
}
@@ -257,7 +257,8 @@ ph:
goto done;
done:
- lws_sequencer_timeout(lws_sequencer_from_user(s), 0);
+ lws_seq_timeout_us(lws_seq_from_user(s),
+ LWSSEQTO_NONE);
priv->expect++;
if (!priv->expect->buffer) {
/* the sequence has completed */
@@ -281,7 +282,7 @@ lws_atcut_close(lws_abs_transport_inst_t *ati)
lwsl_notice("%s\n", __func__);
- lws_sequencer_queue_event(priv->seq, UTSEQ_MSG_CLOSING, NULL, NULL);
+ lws_seq_queue_event(priv->seq, UTSEQ_MSG_CLOSING, NULL, NULL);
return 0;
}
@@ -333,7 +334,7 @@ lws_atcut_tx(lws_abs_transport_inst_t *ati, uint8_t *buf, size_t len)
priv->expect++;
- lws_sequencer_queue_event(priv->seq, UTSEQ_MSG_POST_TX_KICK, NULL, NULL);
+ lws_seq_queue_event(priv->seq, UTSEQ_MSG_POST_TX_KICK, NULL, NULL);
return 0;
}
@@ -378,12 +379,13 @@ lws_atcut_client_conn(const lws_abs_t *abs)
priv->disposition = LPE_CONTINUE;
priv->note[0] = '\0';
- lws_sequencer_timeout(priv->seq, priv->current_test->max_secs);
+ lws_seq_timeout_us(priv->seq, priv->current_test->max_secs *
+ LWS_US_PER_SEC);
lwsl_notice("%s: %s: test '%s': start\n", __func__, abs->ap->name,
priv->current_test->name);
- lws_sequencer_queue_event(priv->seq, UTSEQ_MSG_CONNECTING, NULL, NULL);
+ lws_seq_queue_event(priv->seq, UTSEQ_MSG_CONNECTING, NULL, NULL);
return 0;
}
@@ -402,7 +404,7 @@ lws_atcut_ask_for_writeable(lws_abs_transport_inst_t *ati)
* until we have returned to the event loop, just like a real
* callback_on_writable()
*/
- lws_sequencer_queue_event(priv->seq, UTSEQ_MSG_WRITEABLE, NULL, NULL);
+ lws_seq_queue_event(priv->seq, UTSEQ_MSG_WRITEABLE, NULL, NULL);
return 0;
}
@@ -415,7 +417,7 @@ static int
lws_atcut_create(lws_abs_t *ai)
{
abs_unit_test_priv_t *priv;
- lws_sequencer_t *seq;
+ lws_seq_t *seq;
lws_seq_info_t i;
seq_priv_t *s;
@@ -430,7 +432,7 @@ lws_atcut_create(lws_abs_t *ai)
* Create the sequencer for the steps in a single unit test
*/
- seq = lws_sequencer_create(&i);
+ seq = lws_seq_create(&i);
if (!seq) {
lwsl_err("%s: unable to create sequencer\n", __func__);