#1 fopencookie write handler hangs on write failure

開啟中
xtofl5 年之前創建 · 0 條評論

When registering a custom stream with fopencookie(c, 'a', hooks), when the write hook reports failure, the write action will busy loop.

static ssize_t my_write(
  void *cookie,
  const char *buffer,
  size_t size)
{
  return 0; // just fail
}

....
   cookie_io_functions_t hooks = {
        .read  = &my_read,
        .write = &my_write,
        .seek  = &my_seek,
        .close = &my_close
    };

At _WRITE.c:48, we can see why it loops:

	while (todo != 0) {
		stodo = (todo <= SSIZE_MAX) ? todo : SSIZE_MAX;
		rv = __WRITE(stream, (char *) buf, stodo);
		if (rv >= 0) { ... todo-=rv; }

Am I right to think this is a non-conformance? After all, the fopencookie man page tells me I should return Zero on failure.

When registering a custom stream with `fopencookie(c, 'a', hooks)`, when the write hook reports failure, the write action will busy loop. ``` static ssize_t my_write( void *cookie, const char *buffer, size_t size) { return 0; // just fail } .... cookie_io_functions_t hooks = { .read = &my_read, .write = &my_write, .seek = &my_seek, .close = &my_close }; ``` At [_WRITE.c:48](https://git.uclibc.org/uClibc/tree/libc/stdio/_WRITE.c#n32), we can see why it loops: ``` while (todo != 0) { stodo = (todo <= SSIZE_MAX) ? todo : SSIZE_MAX; rv = __WRITE(stream, (char *) buf, stodo); if (rv >= 0) { ... todo-=rv; } ``` Am I right to think this is a non-conformance? After all, the [fopencookie man page](http://man7.org/linux/man-pages/man3/fopencookie.3.html) tells me I should return Zero on failure.
登入 才能加入這對話。
未選擇標籤
未選擇里程碑
未指派成員
1 參與者
正在加載...
取消
保存
尚未有任何內容