diff options
author | Andy Green <andy@warmcat.com> | 2019-08-07 10:41:03 +0100 |
---|---|---|
committer | Andy Green <andy@warmcat.com> | 2019-08-08 09:45:09 +0100 |
commit | 1d954d52a3066e0f6271c19ac2d216a9d9c855ce (patch) | |
tree | 095d5e75c6ca9074521bbf0d4b282d9b520727af /lib/abstract | |
parent | 20923db2b56d4a2800a18e46f31c06a2ad9359a4 (diff) | |
download | libwebsockets-1d954d52a3066e0f6271c19ac2d216a9d9c855ce.tar.gz |
sequencer: add second aux message arg
Since the messages are queued and then read in order from the event loop
thread, it's not generally safe to pass pointers to argument structs,
since there's no guarantee the lifetime of the thing sending the message
lasted until the sequencer read the message.
This puts pressure on the single void * argument-passed-as-value... this patch
adds a second void * argument-passed-as-value so it's more possible to put
what's needed directly in the argument.
It's also possible to alloc the argument on the heap and have the sequencer
callback free it after it has read it.
Diffstat (limited to 'lib/abstract')
-rw-r--r-- | lib/abstract/test-sequencer.c | 5 | ||||
-rw-r--r-- | lib/abstract/transports/raw-skt.c | 11 | ||||
-rw-r--r-- | lib/abstract/transports/unit-test.c | 13 |
3 files changed, 16 insertions, 13 deletions
diff --git a/lib/abstract/test-sequencer.c b/lib/abstract/test-sequencer.c index 92387054..89eefb3f 100644 --- a/lib/abstract/test-sequencer.c +++ b/lib/abstract/test-sequencer.c @@ -88,7 +88,7 @@ unit_test_result_cb(const void *cb_user, int disposition) return -1; } - lws_sequencer_event(s->unit_test_seq, r, NULL); + lws_sequencer_queue_event(s->unit_test_seq, r, NULL, NULL); ((struct lws_seq_test_sequencer *)s)->instance = NULL; @@ -103,7 +103,8 @@ unit_test_result_cb(const void *cb_user, int disposition) */ static lws_seq_cb_return_t -test_sequencer_cb(struct lws_sequencer *seq, void *user, int event, void *data) +test_sequencer_cb(struct lws_sequencer *seq, void *user, int event, void *data, + void *aux) { struct lws_seq_test_sequencer *s = (struct lws_seq_test_sequencer *)user; diff --git a/lib/abstract/transports/raw-skt.c b/lib/abstract/transports/raw-skt.c index f51d73fa..683efad9 100644 --- a/lib/abstract/transports/raw-skt.c +++ b/lib/abstract/transports/raw-skt.c @@ -97,7 +97,8 @@ callback_abs_client_raw_skt(struct lws *wsi, enum lws_callback_reasons reason, * our lifecycle events */ - lws_sequencer_event(wsi->seq, LWSSEQ_WSI_CONNECTED, wsi); + lws_sequencer_queue_event(wsi->seq, LWSSEQ_WSI_CONNECTED, + wsi, NULL); break; case LWS_CALLBACK_CLIENT_CONNECTION_ERROR: @@ -111,8 +112,8 @@ callback_abs_client_raw_skt(struct lws *wsi, enum lws_callback_reasons reason, * our lifecycle events */ - lws_sequencer_event(wsi->seq, LWSSEQ_WSI_CONN_FAIL, - wsi); + lws_sequencer_queue_event(wsi->seq, LWSSEQ_WSI_CONN_FAIL, + wsi, NULL); goto close_path; @@ -127,8 +128,8 @@ callback_abs_client_raw_skt(struct lws *wsi, enum lws_callback_reasons reason, * our lifecycle events */ - lws_sequencer_event(wsi->seq, LWSSEQ_WSI_CONN_CLOSE, - wsi); + lws_sequencer_queue_event(wsi->seq, LWSSEQ_WSI_CONN_CLOSE, + wsi, NULL); close_path: lwsl_debug("LWS_CALLBACK_RAW_CLOSE\n"); diff --git a/lib/abstract/transports/unit-test.c b/lib/abstract/transports/unit-test.c index c8a8860f..3be03ed3 100644 --- a/lib/abstract/transports/unit-test.c +++ b/lib/abstract/transports/unit-test.c @@ -78,7 +78,8 @@ lws_unit_test_packet_dispose(abs_unit_test_priv_t *priv, priv->disposition = disp; - lws_sequencer_event(priv->seq, UTSEQ_MSG_DISPOSITION_KNOWN, NULL); + lws_sequencer_queue_event(priv->seq, UTSEQ_MSG_DISPOSITION_KNOWN, + NULL, NULL); return disp; } @@ -125,7 +126,7 @@ process_expect(abs_unit_test_priv_t *priv) static lws_seq_cb_return_t unit_test_sequencer_cb(struct lws_sequencer *seq, void *user, int event, - void *data) + void *data, void *aux) { seq_priv_t *s = (seq_priv_t *)user; abs_unit_test_priv_t *priv = (abs_unit_test_priv_t *)s->ai->ati; @@ -280,7 +281,7 @@ lws_atcut_close(lws_abs_transport_inst_t *ati) lwsl_notice("%s\n", __func__); - lws_sequencer_event(priv->seq, UTSEQ_MSG_CLOSING, NULL); + lws_sequencer_queue_event(priv->seq, UTSEQ_MSG_CLOSING, NULL, NULL); return 0; } @@ -332,7 +333,7 @@ lws_atcut_tx(lws_abs_transport_inst_t *ati, uint8_t *buf, size_t len) priv->expect++; - lws_sequencer_event(priv->seq, UTSEQ_MSG_POST_TX_KICK, NULL); + lws_sequencer_queue_event(priv->seq, UTSEQ_MSG_POST_TX_KICK, NULL, NULL); return 0; } @@ -382,7 +383,7 @@ lws_atcut_client_conn(const lws_abs_t *abs) lwsl_notice("%s: %s: test '%s': start\n", __func__, abs->ap->name, priv->current_test->name); - lws_sequencer_event(priv->seq, UTSEQ_MSG_CONNECTING, NULL); + lws_sequencer_queue_event(priv->seq, UTSEQ_MSG_CONNECTING, NULL, NULL); return 0; } @@ -401,7 +402,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_event(priv->seq, UTSEQ_MSG_WRITEABLE, NULL); + lws_sequencer_queue_event(priv->seq, UTSEQ_MSG_WRITEABLE, NULL, NULL); return 0; } |