File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1114,6 +1114,7 @@ int cli_loop(struct cli_def *cli, int sockfd) {
11141114
11151115 // Set the last action now so we don't time immediately
11161116 if (cli -> idle_timeout ) time (& cli -> last_action );
1117+ if (cli -> regular_callback ) time (& cli -> last_regular );
11171118
11181119 // Start off in unprivileged mode
11191120 cli_set_privilege (cli , PRIVILEGE_UNPRIVILEGED );
@@ -1186,6 +1187,16 @@ int cli_loop(struct cli_def *cli, int sockfd) {
11861187 cli -> showprompt = 0 ;
11871188 }
11881189
1190+ if (cli -> regular_callback ) {
1191+ if (time (NULL ) - cli -> last_regular >= cli -> timeout_tm .tv_sec ) {
1192+ if (cli -> regular_callback (cli ) != CLI_OK ) {
1193+ l = -1 ;
1194+ break ;
1195+ }
1196+ time (& cli -> last_regular );
1197+ }
1198+ }
1199+
11891200 if ((sr = cli_socket_wait (sockfd , & tm )) < 0 ) {
11901201 if (errno == EINTR ) continue ;
11911202 perror (CLI_SOCKET_WAIT_PERROR );
@@ -1194,12 +1205,6 @@ int cli_loop(struct cli_def *cli, int sockfd) {
11941205 }
11951206
11961207 if (sr == 0 ) {
1197- // Timeout every second
1198- if (cli -> regular_callback && cli -> regular_callback (cli ) != CLI_OK ) {
1199- l = -1 ;
1200- break ;
1201- }
1202-
12031208 if (cli -> idle_timeout ) {
12041209 if (time (NULL ) - cli -> last_action >= cli -> idle_timeout ) {
12051210 if (cli -> idle_timeout_callback ) {
Original file line number Diff line number Diff line change @@ -83,6 +83,7 @@ struct cli_def {
8383 time_t idle_timeout ;
8484 int (* idle_timeout_callback )(struct cli_def * );
8585 time_t last_action ;
86+ time_t last_regular ;
8687 int telnet_protocol ;
8788 void * user_context ;
8889 struct cli_optarg_pair * found_optargs ;
You can’t perform that action at this time.
0 commit comments