nuttx/drivers/pipes
Jussi Kivilinna ce88bc212d From c73dd8973accd312ca7675fde044df80e9cc62d5 Mon Sep 17 00:00:00 2001
From: Jussi Kivilinna <jussi.kivilinna@haltian.com>
Date: Thu, 7 Dec 2017 13:00:14 +0200
Subject: [PATCH] drivers/pipes: poll: fix off-by-one error in calculation of bytes in the buffer

Buffer calculation in pipe poll setup is off-by-one when read indexis larger than write index. This causes poll() not getting POLLINwhen buffer has one byte as calculation gives zero bytes in buffer.

Reproducible with:

  {
    char buf[8] = { 0, };
    int fds[2];
    struct pollfd in_pfd;

    pipe2(fds, 8);

    write(fds[1], buf, 7);
    read(fds[0], buf, 7);
    write(fds[1], buf, 1);

    in_pfd.fd = fds[0];
    in_pfd.events = POLLIN;
    ret = poll(&in_pfd, 1, -1); // pipe bug => stuck waiting
    assert(ret == 1);
  }
2017-12-07 07:12:11 -06:00
..
fifo.c Move driver related prototypes out of include/nuttx/fs/fs.h and into new include/drivers/drivers.h 2016-07-20 13:15:37 -06:00
Kconfig SPI driver: Correct return value in case of a certain error condition 2016-08-06 08:07:30 -06:00
Make.defs drivers/, drivers/pipes, and drivers/serial file clean-up 2012-07-15 14:56:25 +00:00
pipe_common.c From c73dd8973accd312ca7675fde044df80e9cc62d5 Mon Sep 17 00:00:00 2001 2017-12-07 07:12:11 -06:00
pipe_common.h Fix a few typos in the last commit 2016-07-19 13:40:54 -06:00
pipe.c Squashed commit of the following: 2017-10-04 15:22:27 -06:00