summaryrefslogtreecommitdiffstats
path: root/src/fsm.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/fsm.c')
-rw-r--r--src/fsm.c18
1 files changed, 6 insertions, 12 deletions
diff --git a/src/fsm.c b/src/fsm.c
index 9301918..d161145 100644
--- a/src/fsm.c
+++ b/src/fsm.c
@@ -12,6 +12,7 @@ static int process_release(struct tsnif_handle *h, struct tsnif_term *term)
term->state = TSNIF_INTF_STATE_DONE;
+ TSNIF_DEBUG("type %d, idx %d\n", term->type, term->idx);
return h->ops->cb_release(term);
}
@@ -75,10 +76,6 @@ static int attach(struct tsnif_handle *h,
err = process_tgroup(h, term, msg->group);
break;
- case TSNIF_CMD_RELEASE:
- err = process_release(h, term);
- break;
-
case TSNIF_CMD_ATTACH:
/* got attach ack, do nothing */
if (msg->ack)
@@ -118,10 +115,6 @@ static int detach(struct tsnif_handle *h,
err = process_error(h, term, msg->error);
break;
- case TSNIF_CMD_RELEASE:
- err = process_release(h, term);
- break;
-
case TSNIF_CMD_DATA:
/* ignore DATA msg when in DETACH state */
break;
@@ -143,10 +136,6 @@ static int data(struct tsnif_handle *h,
return 0;
switch(msg->cmd) {
- case TSNIF_CMD_RELEASE:
- err = process_release(h, term);
- break;
-
case TSNIF_CMD_DATA:
err = process_data(h, term, msg);
break;
@@ -165,6 +154,11 @@ int fsm_process(struct tsnif_handle *h,
TSNIF_DEBUG("got cmd %d for term type %d, idx %d, state %d\n",
msg->cmd, term->type, term->idx, term->state);
+ /* we can get the release command in any state,
+ * so let's handle it globaly here */
+ if (msg->cmd == TSNIF_CMD_TTY_RELEASE)
+ return process_release(h, term);
+
switch(term->state) {
case TSNIF_INTF_STATE_NEW:
return new(h, term, msg);