Handle case where write result is zero.
This commit is contained in:
parent
d9ccb6b372
commit
425a46131a
Notes:
git
2022-06-13 13:12:45 +09:00
6
io.c
6
io.c
|
@ -1620,6 +1620,12 @@ io_binwrite_string(VALUE arg)
|
||||||
// Write as much as possible:
|
// Write as much as possible:
|
||||||
ssize_t result = io_binwrite_string_internal(p->fptr, ptr, remaining);
|
ssize_t result = io_binwrite_string_internal(p->fptr, ptr, remaining);
|
||||||
|
|
||||||
|
// If only the internal buffer is written, result will be zero [bytes of given data written]. This means we
|
||||||
|
// should try again.
|
||||||
|
if (result == 0) {
|
||||||
|
errno = EWOULDBLOCK;
|
||||||
|
}
|
||||||
|
|
||||||
if (result > 0) {
|
if (result > 0) {
|
||||||
if ((size_t)result == remaining) break;
|
if ((size_t)result == remaining) break;
|
||||||
ptr += result;
|
ptr += result;
|
||||||
|
|
Loading…
Reference in New Issue