git-svn: trunk@4405
Török Edvin authored on 2008/11/14 06:59:13... | ... |
@@ -1,3 +1,7 @@ |
1 |
+Thu Nov 13 23:00:39 EET 2008 (edwin) |
|
2 |
+------------------------------------ |
|
3 |
+ * contrib/clamdtop/clamdtop.c: fix reconnect logic |
|
4 |
+ |
|
1 | 5 |
Thu Nov 13 19:06:47 CET 2008 (tk) |
2 | 6 |
--------------------------------- |
3 | 7 |
* libclamav, clamd, clamscan: use cl_engine_set() to control AC settings |
... | ... |
@@ -186,6 +186,7 @@ static void resize(void) |
186 | 186 |
OOM_CHECK(queue_header); |
187 | 187 |
clamd_header = malloc(maxx + 1); |
188 | 188 |
OOM_CHECK(clamd_header); |
189 |
+ assert(clamd_header && queue_header); |
|
189 | 190 |
strncpy(queue_header, global.num_clamd>1 ? CMDHEAD2 : CMDHEAD, maxx); |
190 | 191 |
strncpy(clamd_header, SUMHEAD, maxx); |
191 | 192 |
queue_header[maxx] = '\0'; |
... | ... |
@@ -386,9 +387,10 @@ static void cleanup(void) |
386 | 386 |
} |
387 | 387 |
curses_inited = 0; |
388 | 388 |
for (i=0;i<global.num_clamd;i++) { |
389 |
- if (global.conn[i].sd && global.conn[i].sd != -1) |
|
389 |
+ if (global.conn[i].sd && global.conn[i].sd != -1) { |
|
390 | 390 |
send_string_noreconn(&global.conn[i], "END\n"); |
391 |
- close(global.conn[i].sd); |
|
391 |
+ close(global.conn[i].sd); |
|
392 |
+ } |
|
392 | 393 |
free(global.conn[i].version); |
393 | 394 |
} |
394 | 395 |
free(global.all_stats); |
... | ... |
@@ -404,8 +406,13 @@ static void cleanup(void) |
404 | 404 |
} |
405 | 405 |
} |
406 | 406 |
|
407 |
+#ifdef __GNUC__ |
|
408 |
+#define __noreturn __attribute__((noreturn)) |
|
409 |
+#else |
|
410 |
+#define __noreturn |
|
411 |
+#endif |
|
407 | 412 |
|
408 |
-static void exit_program(enum exit_reason reason, const char *func, unsigned line) |
|
413 |
+static void __noreturn exit_program(enum exit_reason reason, const char *func, unsigned line) |
|
409 | 414 |
{ |
410 | 415 |
switch(reason) { |
411 | 416 |
case FAIL_INITIAL_CONN: |
... | ... |
@@ -564,7 +571,7 @@ static void reconnect(conn_t *conn) |
564 | 564 |
} |
565 | 565 |
if (make_connection(conn->remote, conn) < 0) { |
566 | 566 |
print_con_info(conn, "Unable to reconnect to %s: %s", conn->remote, strerror(errno)); |
567 |
- exit(3); |
|
567 |
+ EXIT_PROGRAM(RECONNECT_FAIL); |
|
568 | 568 |
} |
569 | 569 |
tries = 0; |
570 | 570 |
} |
... | ... |
@@ -797,7 +804,7 @@ static int output_stats(struct stats *stats, unsigned idx) |
797 | 797 |
if (sel) { |
798 | 798 |
wattron(win, COLOR_PAIR(selected_color)); |
799 | 799 |
} |
800 |
- mvwprintw(win, i++, 0, "%s", line); |
|
800 |
+ mvwprintw(win, i, 0, "%s", line); |
|
801 | 801 |
if (sel) { |
802 | 802 |
wattroff(win, COLOR_PAIR(selected_color)); |
803 | 803 |
} |
... | ... |
@@ -997,6 +1004,8 @@ static void read_version(conn_t *conn) |
997 | 997 |
for (i=0;i<strlen(conn->version);i++) |
998 | 998 |
if (conn->version[i] == '\n') |
999 | 999 |
conn->version[i] = ' '; |
1000 |
+ } else { |
|
1001 |
+ reconnect(conn); |
|
1000 | 1002 |
} |
1001 | 1003 |
} |
1002 | 1004 |
|
... | ... |
@@ -1133,10 +1142,10 @@ int main(int argc, char *argv[]) |
1133 | 1133 |
|
1134 | 1134 |
memset(&tv_last, 0, sizeof(tv_last)); |
1135 | 1135 |
do { |
1136 |
+ if (ch == KEY_F(1)) { |
|
1137 |
+ ch = show_help(); |
|
1138 |
+ } |
|
1136 | 1139 |
switch(ch) { |
1137 |
- case KEY_F(1): |
|
1138 |
- ch = show_help(); |
|
1139 |
- break; |
|
1140 | 1140 |
case KEY_RESIZE: |
1141 | 1141 |
resize(); |
1142 | 1142 |
endwin(); |