On Wed, 25 Jun 2025 19:55:34 +0900
Takashi Yano wrote:
> Hi Johannes,
>
> On Wed, 25 Jun 2025 09:38:17 +0200 (CEST)
> Johannes Schindelin wrote:
> > Hi Takashi,
> >
> > On Wed, 25 Jun 2025, Johannes Schindelin wrote:
> >
> > > On Wed, 25 Jun 2025, Takashi Yano wrote:
> > >
> > > > I'd revise the patch as follows. Could you please test if the
> > > > following patch also solves the issue?
> > >
> > > Will do.
> >
> > For the record, in my tests, this fixed the hangs, too.
>
> Thanks for testing.
> However, I noticed that this patch changes the behavior Corinna was
> concerned about.
The behaviour change can be checked using attached test case.
--
Takashi Yano <[email protected]>
#include <unistd.h>
#include <stdio.h>
#include <limits.h>
#include <fcntl.h>
#define PIPE_SIZE 65536
int main()
{
int fd[2];
char buf[PIPE_SIZE];
int flags;
pipe(fd);
/* Set non-blocking */
flags = fcntl(fd[1], F_GETFL);
flags |= O_NONBLOCK;
fcntl(fd[1], F_SETFL, flags);
/* Fill pipe */
printf("w:%d\n", write(fd[1], buf, PIPE_SIZE));
/* Free PIPE_BUF/2 bytes */
printf("r:%d\n", read(fd[0], buf, PIPE_BUF/2));
/* Write PIPE_BUF bytes */
printf("w:%d\n", write(fd[1], buf, 1));
printf("w:%d\n", write(fd[1], buf, PIPE_BUF-1));
printf("w:%d\n", write(fd[1], buf, PIPE_BUF));
printf("w:%d\n", write(fd[1], buf, PIPE_BUF+1));
printf("w:%d\n", write(fd[1], buf, PIPE_BUF*2));
printf("w:%d\n", write(fd[1], buf, PIPE_BUF*2));
printf("w:%d\n", write(fd[1], buf, PIPE_BUF*2));
printf("w:%d\n", write(fd[1], buf, PIPE_BUF*2));
printf("w:%d\n", write(fd[1], buf, PIPE_BUF*2));
printf("w:%d\n", write(fd[1], buf, PIPE_BUF*2));
return 0;
}