From: Eric Bollengier Date: Fri, 2 Oct 2009 07:36:40 +0000 (+0200) Subject: Cleanup new timeout code for bconsole X-Git-Tag: Release-5.0.0~294^2~1 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=aa269e0ab43682e9e62d792c509271686218c7fa;p=bacula%2Fbacula Cleanup new timeout code for bconsole --- diff --git a/bacula/src/console/console.c b/bacula/src/console/console.c index 921675dcaf..e7cdf0fd53 100644 --- a/bacula/src/console/console.c +++ b/bacula/src/console/console.c @@ -229,7 +229,7 @@ static void read_and_process_input(FILE *input, BSOCK *UA_sock) bool at_prompt = false; int tty_input = isatty(fileno(input)); int stat; - btimer_t *tid; + btimer_t *tid=NULL; for ( ;; ) { if (at_prompt) { /* don't prompt multiple times */ @@ -265,9 +265,9 @@ static void read_and_process_input(FILE *input, BSOCK *UA_sock) break; /* error or interrupt */ } else if (stat == 0) { /* timeout */ if (strcmp(prompt, "*") == 0) { - if (timeout) tid = start_bsock_timer(UA_sock, timeout); + tid = start_bsock_timer(UA_sock, timeout); bnet_fsend(UA_sock, ".messages"); - if (timeout) stop_bsock_timer(tid); + stop_bsock_timer(tid); } else { continue; } @@ -281,17 +281,17 @@ static void read_and_process_input(FILE *input, BSOCK *UA_sock) } continue; } - if (timeout) tid = start_bsock_timer(UA_sock, timeout); + tid = start_bsock_timer(UA_sock, timeout); if (!bnet_send(UA_sock)) { /* send command */ - if (timeout) stop_bsock_timer(tid); + stop_bsock_timer(tid); break; /* error */ } - if (timeout) stop_bsock_timer(tid); + stop_bsock_timer(tid); } if (strcmp(UA_sock->msg, ".quit") == 0 || strcmp(UA_sock->msg, ".exit") == 0) { break; } - if (timeout) tid = start_bsock_timer(UA_sock, timeout); + tid = start_bsock_timer(UA_sock, timeout); while ((stat = bnet_recv(UA_sock)) >= 0) { if (at_prompt) { if (!stop) { @@ -304,7 +304,7 @@ static void read_and_process_input(FILE *input, BSOCK *UA_sock) sendit(UA_sock->msg); } } - if (timeout) stop_bsock_timer(tid); + stop_bsock_timer(tid); if (usrbrk() > 1) { break; } else { diff --git a/bacula/src/lib/btimers.c b/bacula/src/lib/btimers.c index 3094a6385e..5f8a416efe 100644 --- a/bacula/src/lib/btimers.c +++ b/bacula/src/lib/btimers.c @@ -166,6 +166,9 @@ btimer_t *start_thread_timer(JCR *jcr, pthread_t tid, uint32_t wait) btimer_t *start_bsock_timer(BSOCK *bsock, uint32_t wait) { btimer_t *wid; + if (wait <= 0) { /* wait should be > 0 */ + return NULL; + } wid = btimer_start_common(wait); if (wid == NULL) { return NULL;