diff options
-rw-r--r-- | dpid/dpid.c | 3 | ||||
-rw-r--r-- | dpip/dpip.c | 19 |
2 files changed, 16 insertions, 6 deletions
diff --git a/dpid/dpid.c b/dpid/dpid.c index fd94d380..246894ae 100644 --- a/dpid/dpid.c +++ b/dpid/dpid.c @@ -770,6 +770,9 @@ void stop_active_dpis(struct dp *dpi_attr_list, int numdpis) dFree(auth_cmd); dFree(bye_cmd); + + /* Allow child dpis some time to read dpid_comm_keys before erasing it */ + sleep (1); } /*! Removes dpis in dpi_attr_list from the 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); } } |