improve tk_istream_read_len

This commit is contained in:
lixianjing 2019-10-16 11:12:59 +08:00
parent b1a7e59a83
commit bead56eb1d

View File

@ -77,6 +77,11 @@ int32_t tk_istream_read_len(tk_istream_t* stream, uint8_t* buff, uint32_t max_si
break;
}
if (object_get_prop_bool(OBJECT(stream), TK_STREAM_PROP_IS_EOS, FALSE)) {
log_debug("stream is end\n");
break;
}
if (errno == EAGAIN || errno == 0) {
sleep_ms(10);
continue;
@ -93,6 +98,11 @@ int32_t tk_istream_read_len(tk_istream_t* stream, uint8_t* buff, uint32_t max_si
break;
}
if (object_get_prop_bool(OBJECT(stream), TK_STREAM_PROP_IS_EOS, FALSE)) {
log_debug("stream is end\n");
break;
}
now = time_now_ms();
if (now > end) {
log_debug("read timeout\n");