proto-shell: retry setup if the proto handler script quits without changing the state...
authorFelix Fietkau <nbd@openwrt.org>
Tue, 21 Apr 2015 12:09:48 +0000 (14:09 +0200)
committerFelix Fietkau <nbd@openwrt.org>
Tue, 21 Apr 2015 12:09:48 +0000 (14:09 +0200)
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
proto-shell.c

index 7a1896b8374b802d7c38743aed1d91d34dd73a95..bc4c658683165e0bedc29df049cb422b6f42f5cc 100644 (file)
@@ -284,9 +284,16 @@ proto_shell_task_finish(struct proto_shell_state *state,
                if (task == &state->proto_task)
                        proto_shell_handler(&state->proto, PROTO_CMD_TEARDOWN,
                                            false);
-               if (task == &state->script_task && state->renew_pending)
-                       proto_shell_handler(&state->proto, PROTO_CMD_RENEW,
-                                           false);
+               if (task == &state->script_task) {
+                       if (state->renew_pending)
+                               proto_shell_handler(&state->proto,
+                                                   PROTO_CMD_RENEW, false);
+                       else if (!state->proto_task.uloop.pending &&
+                                state->sm == S_SETUP)
+                               proto_shell_handler(&state->proto,
+                                                   PROTO_CMD_TEARDOWN,
+                                                   false);
+               }
                break;
 
        case S_SETUP_ABORT: