}
}
+static bool finished;
+
/****************************************************************************
Make sure we swallow keepalives during idle time.
****************************************************************************/
DEBUG(0, ("Read from server failed, maybe it closed "
"the connection\n"));
+ finished = true;
+ smb_readline_done();
if (NT_STATUS_EQUAL(status, NT_STATUS_END_OF_FILE)) {
set_smb_read_error(&cli->smb_rw_error,
SMB_READ_EOF);
{
unsigned char garbage[16];
memset(garbage, 0xf0, sizeof(garbage));
- cli_echo(cli, 1, data_blob_const(garbage, sizeof(garbage)));
+ if (!cli_echo(cli, 1, data_blob_const(garbage, sizeof(garbage)))) {
+ DEBUG(0, ("SMBecho failed. Maybe server has closed "
+ "the connection\n"));
+ finished = true;
+ smb_readline_done();
+ }
}
}
{
int rc = 0;
- while (1) {
+ while (!finished) {
TALLOC_CTX *frame = talloc_stackframe();
char *tok = NULL;
char *the_prompt = NULL;
/* The following definitions come from lib/readline.c */
+void smb_readline_done(void);
char *smb_readline(const char *prompt, void (*callback)(void),
char **(completion_fn)(const char *text, int start, int end));
const char *smb_readline_get_line_buffer(void);
# define RL_COMPLETION_CAST
#endif /* HAVE_NEW_LIBREADLINE */
+static bool smb_rl_done;
+
+void smb_readline_done(void)
+{
+ smb_rl_done = true;
+#if HAVE_LIBREADLINE
+ rl_done = 1;
+#endif
+}
+
/****************************************************************************
Display the prompt and wait for input. Call callback() regularly
****************************************************************************/
return NULL;
}
- while (1) {
+ while (!smb_rl_done) {
timeout.tv_sec = 5;
timeout.tv_usec = 0;
callback();
}
}
+ return NULL;
}
/****************************************************************************