This is a discussion on Re: Pipes, cat buffer size - FreeBSD ; On Sunday 19 October 2008 02:50:22 Dan Nelson wrote: > > But if it works in general, it may simply be that it isn't really > > applicable to my purpose (and I should modify the reader to read > ...
On Sunday 19 October 2008 02:50:22 Dan Nelson wrote:
> > But if it works in general, it may simply be that it isn't really
> > applicable to my purpose (and I should modify the reader to read
> > multiple blocks).
> That's my suggestion, yes. That way your program would also work when
> passed data from an internet socket (where you will get varying read()
> sizes too). It wouldn't add more than 10 lines to wrap your read in a
> loop that exits when your preferred size has been reached.
Since you mention a socket, would this patch be a good idea and use kqueue to
read from the pipe?
I would think that having the kernel fill the buffer, rather then a busy loop
kernel/userland would improve speed, but I'm not too familiar with the code
to know if this causes any problems.
diff -u -r220.127.116.11 sys_pipe.c
--- sys_pipe.c 6 Jun 2008 12:17:28 -0000 18.104.22.168
+++ sys_pipe.c 20 Oct 2008 14:04:18 -0000
@@ -1594,7 +1609,10 @@
- ret = kn->kn_data > 0;
+ if ( kn->kn_sfflags & NOTE_LOWAT)
+ ret = kn->kn_data >= kn->kn_sdata;
+ ret = kn->kn_data > 0;
email@example.com mailing list
To unsubscribe, send any mail to "firstname.lastname@example.org"