# HG changeset patch # User Matti Hamalainen # Date 1337974970 -10800 # Node ID 7e46f2f0ba349ab5c2efe9441c25c9396c2af492 # Parent 29a341fa80a19513f397160b306c50fd271daef2 Cleanup packet retrying a bit. diff -r 29a341fa80a1 -r 7e46f2f0ba34 main.c --- a/main.c Fri May 25 22:02:24 2012 +0300 +++ b/main.c Fri May 25 22:42:50 2012 +0300 @@ -1904,13 +1904,15 @@ nn_conn_reset(conn); while (!isError && !exitProg) { - int cres = nn_conn_pull(conn); + int retries = 3, cres; + +packet_retry: + cres = nn_conn_pull(conn); if (cres == 0) { - int retries = 3; while (conn->ptr < conn->in_ptr && *(conn->in_ptr - 1) == 0 && - retries > 0) + retries > 0 && !isError) { // nn_conn_dump_buffer(stderr, conn); int result = nn_parse_protocol(conn); @@ -1921,16 +1923,13 @@ else if (result > 0) { + // Retry if possible if (--retries > 0) - { - cres = nn_conn_pull(conn); - } - else - { - // Couldn't handle the message for some reason - printMsg(currWin, "Could not handle: %s\n", conn->ptr); - nn_conn_buf_skip(conn, strlen(conn->ptr) + 1); - } + goto packet_retry; + + // Couldn't handle the message for some reason + printMsg(currWin, "Could not handle: %s\n", conn->ptr); + nn_conn_buf_skip(conn, strlen(conn->ptr) + 1); } else {