summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dpip/dpip.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/dpip/dpip.c b/dpip/dpip.c
index bfc543fb..215543d2 100644
--- a/dpip/dpip.c
+++ b/dpip/dpip.c
@@ -440,13 +440,20 @@ char *a_Dpip_dsh_read_token(Dsh *dsh, int blocking)
if (dsh->mode & DPIP_LAST_TAG)
dsh->mode = DPIP_RAW;
- if (blocking && dsh->mode & DPIP_TAG) {
- /* Only wait for data when the tag is incomplete */
- if (!strstr(dsh->rdbuf->str, DPIP_TAG_END)) {
- do {
+ if (blocking) {
+ if (dsh->mode & DPIP_TAG) {
+ /* Only wait for data when the tag is incomplete */
+ if (!strstr(dsh->rdbuf->str, DPIP_TAG_END)) {
+ do {
+ Dpip_dsh_read(dsh, 1);
+ p = strstr(dsh->rdbuf->str, DPIP_TAG_END);
+ } while (!p && dsh->status == EAGAIN);
+ }
+
+ } else if (dsh->mode & DPIP_RAW) {
+ /* Wait for data when the buffer is empty and there's no EOF yet */
+ while (dsh->rdbuf->len == 0 && dsh->status != DPIP_EOF)
Dpip_dsh_read(dsh, 1);
- p = strstr(dsh->rdbuf->str, DPIP_TAG_END);
- } while (!p && dsh->status == EAGAIN);
}
}