#1 fopencookie write handler hangs on write failure

オープン
5 年 前xtofl によって開かれました · 0 コメント
xtofl5 年 前 にコメントしました

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.
Waldemar Brodkorb この課題がコミット 2 年 前 から参照されました
会話に参加するには サインイン してください。
ラベルなし
マイルストーンなし
担当者なし
1 参加者
読み込み中…
キャンセル
保存
まだコンテンツがありません