The need for a special SMB receive system call

David Collier-Brown davecb at canada.sun.com
Wed Sep 25 13:14:00 GMT 2002


Andrew Bartlett wrote:
> Why can't we do a non-blocking read on the socket, into a (large)
> buffer?
> 
> We would then process the commands one-by one, until we reached one that
> had a length beyond the end of the buffer.  Then we memmove it to the
> start, read to it's end, process and start the game again.

	I use a similar trick in an old readline library
	(which I need to find again): do a non-blocking read
	into a large buffer, structurally identical to a 
	stdio buffer, then call individual
	read-record  or read-line functions that use it.

	The gotcha is that the caller of the read-record
	function MUST check the pointer returned for null, and
	if it's null, check to see if its EOF or just
	not ready, and in the latter case do something that
	blocks. If not, and you use it in a loop, you'll
	busy-wait on the fd and eat a CPU (;-))

	I should have used select/poll, I suspect, but
	I didn't have that on CP/M-80 (I sead it was
	a long time ago (:-))

--dave
-- 
David Collier-Brown,           | Always do right. This will gratify 
Performance & Engineering      | some people and astonish the rest.
Opcom/ACE/SIS in Toronto       |                      -- Mark Twain
(905) 415-2849                 | davecb at canada.sun.com



More information about the samba-technical mailing list