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 -r188.8.131.52 sys_pipe.c
--- sys_pipe.c 6 Jun 2008 12:17:28 -0000 184.108.40.206
+++ 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;
firstname.lastname@example.org mailing list
To unsubscribe, send any mail to "email@example.com"