diff --git a/xrdpapi/connectmon.c b/xrdpapi/connectmon.c index 38b5dfc0..1e89e91f 100644 --- a/xrdpapi/connectmon.c +++ b/xrdpapi/connectmon.c @@ -112,11 +112,22 @@ main(int argc, char **argv) log_start_from_param(lc); } - if (argc > 1 && atoi(argv[1]) > 0) + if (argc > 1 && atoi(argv[1]) >= 0) { changes = atoi(argv[1]); + if (changes > 1000) + { + changes = 1000; // Use 0 for more than this + } + } + if (changes > 0) + { + printf("Connection monitor : exiting after %d state changes\n", changes); + } + else + { + printf("Connection monitor\n"); } - printf("Connection monitor : exiting after %d state changes\n", changes); print_current_connection_state(); @@ -128,7 +139,7 @@ main(int argc, char **argv) else { int count = 0; - while (count < changes && result == 0) + while (result == 0) { struct pollfd pollarg = { @@ -139,6 +150,11 @@ main(int argc, char **argv) int pollstat; LRESULT cbresult; + if (changes > 0 && count >= changes) + { + break; + } + if ((pollstat = poll(&pollarg, 1, -1)) < 0) { printf("** Error from poll() : %s\n", strerror(errno));