# HG changeset patch # User Matti Hamalainen # Date 1337970675 -10800 # Node ID 70ea06294f3fea7c78ac5ed0ae0254b7a0ae8b1d # Parent 3be600124da871d01dc5232b9a5b7e197abffa92 Possibly fix packet handling after the whole mess of refactoring. diff -r 3be600124da8 -r 70ea06294f3f main.c --- a/main.c Fri May 25 21:30:57 2012 +0300 +++ b/main.c Fri May 25 21:31:15 2012 +0300 @@ -1904,11 +1904,15 @@ nn_conn_reset(conn); while (!isError && !exitProg) { - nn_conn_reset(conn); - do { - int cres = nn_conn_pull(conn); - if (cres == 0 && *(conn->in_ptr - 1) == 0) + int cres = nn_conn_pull(conn); + if (cres == 0) + { + int retries = 3; + while (conn->ptr < conn->in_ptr && + *(conn->in_ptr - 1) == 0 && + retries > 0) { +// nn_conn_dump_buffer(stderr, conn); int result = nn_parse_protocol(conn); if (result == 0) { @@ -1917,8 +1921,16 @@ else if (result > 0) { - // Couldn't handle the message for some reason - printMsg(currWin, "Could not handle: %s\n", conn->ptr); + 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); + } } else { @@ -1927,14 +1939,9 @@ isError = TRUE; } } - else if (cres < 0) - isError = TRUE; - else - break; } - while (conn->total_bytes > 0 && !isError); - - if (!nn_conn_check(conn)) + else + if (cres < 0 || !nn_conn_check(conn)) isError = TRUE; // Handle user input