Skip to content

Commit 3034c77

Browse files
authored
Merge pull request #86 from dparrish/revert-80-dev/regular-cb-improve
Revert "Regular callback improvements"
2 parents 589c718 + b983098 commit 3034c77

2 files changed

Lines changed: 6 additions & 12 deletions

File tree

libcli.c

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1114,7 +1114,6 @@ 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);
11181117

11191118
// Start off in unprivileged mode
11201119
cli_set_privilege(cli, PRIVILEGE_UNPRIVILEGED);
@@ -1187,16 +1186,6 @@ int cli_loop(struct cli_def *cli, int sockfd) {
11871186
cli->showprompt = 0;
11881187
}
11891188

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-
12001189
if ((sr = cli_socket_wait(sockfd, &tm)) < 0) {
12011190
if (errno == EINTR) continue;
12021191
perror(CLI_SOCKET_WAIT_PERROR);
@@ -1205,6 +1194,12 @@ int cli_loop(struct cli_def *cli, int sockfd) {
12051194
}
12061195

12071196
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+
12081203
if (cli->idle_timeout) {
12091204
if (time(NULL) - cli->last_action >= cli->idle_timeout) {
12101205
if (cli->idle_timeout_callback) {

libcli.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ struct cli_def {
7878
time_t idle_timeout;
7979
int (*idle_timeout_callback)(struct cli_def *);
8080
time_t last_action;
81-
time_t last_regular;
8281
int telnet_protocol;
8382
void *user_context;
8483
struct cli_optarg_pair *found_optargs;

0 commit comments

Comments
 (0)