diff options
| author | yangwei <[email protected]> | 2024-04-11 17:09:16 +0800 |
|---|---|---|
| committer | yangwei <[email protected]> | 2024-04-11 19:05:09 +0800 |
| commit | 66ff45a932d7e05798542f60ae3c1ae227d453cc (patch) | |
| tree | 0cfdfe7943858269df0b6ecf3c68eb7f8d4aee13 | |
| parent | ee878b4ce9b52e730351a4b08ce5b8d0a9dd4d2b (diff) | |
🐞 fix(events dispatch): fix control pkt state filterv1.0.19
| -rw-r--r-- | examples/stellar_plugin/simple_stellar_plugin.c | 4 | ||||
| -rw-r--r-- | src/adapter/session_manager.c | 5 |
2 files changed, 5 insertions, 4 deletions
diff --git a/examples/stellar_plugin/simple_stellar_plugin.c b/examples/stellar_plugin/simple_stellar_plugin.c index c5798eb..878ea97 100644 --- a/examples/stellar_plugin/simple_stellar_plugin.c +++ b/examples/stellar_plugin/simple_stellar_plugin.c @@ -130,7 +130,7 @@ void *simple_stellar_event_plugin_init(struct stellar *st) plugin_env->st = st; plugin_env->exdata_idx = stellar_session_get_ex_new_index(st, "SIMPLE_EVENT_PLUGIN", simple_exdata_free, NULL); if(plugin_env->exdata_idx < 0)exit(-1); - int plugin_id=stellar_plugin_register(st, (SESS_EV_TCP|SESS_EV_UDP|SESS_EV_OPENING|SESS_EV_PACKET|SESS_EV_CLOSING), simple_event_plugin_entry, plugin_env); + int plugin_id=stellar_plugin_register(st, (SESS_EV_TCP|SESS_EV_UDP|SESS_EV_OPENING|SESS_EV_PACKET|SESS_EV_CLOSING|SESS_EV_CONTROL), simple_event_plugin_entry, plugin_env); if(plugin_id < 0)exit(-1); plugin_env->plugin_id=plugin_id; @@ -187,7 +187,7 @@ static int session_mq_plugin_sub_fn(struct session *sess, int topic_id, const vo else { struct session_event *i_ev=session_get_intrinsic_event(sess, plugin_ctx->plugin_id); - session_event_assign(i_ev, plugin_ctx->st, sess, (SESS_EV_TCP|SESS_EV_UDP|SESS_EV_OPENING|SESS_EV_PACKET|SESS_EV_CLOSING), simple_mq_plugin_entry, plugin_ctx); + session_event_assign(i_ev, plugin_ctx->st, sess, (SESS_EV_TCP|SESS_EV_UDP|SESS_EV_OPENING|SESS_EV_CLOSING), simple_mq_plugin_entry, plugin_ctx); printf("%s(plug:%d)session_event_assign-----------%20s\n", __FUNCTION__, plugin_ctx->plugin_id, session_get0_readable_addr(sess)); } diff --git a/src/adapter/session_manager.c b/src/adapter/session_manager.c index b62eaff..f24e92e 100644 --- a/src/adapter/session_manager.c +++ b/src/adapter/session_manager.c @@ -347,12 +347,13 @@ void session_dispatch(struct session *sess, enum session_state state, struct pa if(sess->st->intrinsic_session_event_schema_array == NULL)return; unsigned int len = utarray_len(sess->st->intrinsic_session_event_schema_array); sess->state = state; - // TODO: improve state to events logic int events=(1<<state|(sess->type==SESSION_TYPE_TCP?SESS_EV_TCP:SESS_EV_UDP)); + if(state==SESSION_STATE_CONTROL)events=SESS_EV_CONTROL; + for(unsigned i = 0; i < len; i++) { p = (intrinsic_events+i); - if(p->session_event_cb != NULL && (p->events & events) && (p->is_delete == 0)) + if(p->session_event_cb != NULL && ((events & p->events)!=0) && (p->is_delete == 0)) { p->session_event_cb(sess, events, pkt, p->cb_arg); } |
