aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ssh/tomsg_clientlib.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/ssh/tomsg_clientlib.c b/ssh/tomsg_clientlib.c
index df22a1e..260b785 100644
--- a/ssh/tomsg_clientlib.c
+++ b/ssh/tomsg_clientlib.c
@@ -938,12 +938,18 @@ enum tomsg_retval tomsg_next_event(struct tomsg_client *client, struct tomsg_eve
enum tomsg_retval ret = find_handle_next_line(client, eventp);
if (ret != TOMSG_ERR_AGAIN) return ret;
- // Otherwise, try to receive more data.
- ret = receive_more_data(client);
- if (ret != TOMSG_OK) return ret;
-
- // And then handle any line that might be completed at this point.
- return find_handle_next_line(client, eventp);
+ // Otherwise, try to receive more data until either there is no more data
+ // anymore, or we have a complete event.
+ while (true) {
+ ret = receive_more_data(client);
+ if (ret != TOMSG_OK) return ret;
+
+ // Handle any line that might be completed at this point. If that
+ // produces an event or an error, return it; otherwise loop and receive
+ // more data.
+ ret = find_handle_next_line(client, eventp);
+ if (ret != TOMSG_ERR_AGAIN) return ret;
+ }
}
#define SEND_FMT0(client, tag, fmt) do { \