tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Reusing of struct uio in soo_read()



> I am using function soo_read() in kernel thread:
> [...]
> I use it in a loop for receiving small messages.

> How to reuse struct uio after soo_recv() to receive next data again
> on the beginning of iovec.iov_base buffer ? (if possible)

> Reseting members: [uio_resid, uio_iov.iovec.iov_len, uio_offset]
> to originally initialized values does not help.

Then I guess you need to reset more?  Since, as you say, another
fully-set-up struct uio works, to reuse the struct uio you have, you
must need to reset more of it.

Looking at the 5.2 code, uiomove(), the routine that (almost?)
everything using struct uio ends up calling to copy data, modifies,
under some circumstances, uio_iov, uio_iovcnt, uio_resid, uio_offset,
and the iov_base and iov_len members of the structs iovec popinted to
by uio_iov.  Your system likely is different (if nothing else, you
write uio_iov.iovec.iov_len for what 5.2 would call uio_iov->iov_len),
but, really, why not just reinitialize everything instead of expecting
just the three fields you name to be the only ones needing it?  I don't
think it's any part of uiomove()'s - or soo_read()'s - interface
contract to leave any part of the struct uio unchanged.

/~\ The ASCII				  Mouse
\ / Ribbon Campaign
 X  Against HTML		mouse%rodents-montreal.org@localhost
/ \ Email!	     7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B


Home | Main Index | Thread Index | Old Index