diff options
author | Jorge Arellano Cid <jcid@dillo.org> | 2010-02-16 11:00:16 -0300 |
---|---|---|
committer | Jorge Arellano Cid <jcid@dillo.org> | 2010-02-16 11:00:16 -0300 |
commit | c41381ed695b3553b0454adcffca0d6a0e5520e9 (patch) | |
tree | 2279a9acb44b1677621294bb38819e479cd11aa1 /dpip/dpip.c | |
parent | 836119ea6de6871a7afa044294df8b40859e3886 (diff) |
Fix a_Dpip_dsh_read_token() for long blocking reads
Diffstat (limited to 'dpip/dpip.c')
-rw-r--r-- | dpip/dpip.c | 19 |
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); } } |