efficient rpc io using vstr

Martin Pool mbp at samba.org
Tue Jan 20 05:01:43 GMT 2004

On 19 Jan 2004, Michael B Allen <mba2000 at ioplex.com> wrote:
> Martin Pool said:
> > Here's an sketch of the kind of packet buffering using vstr that I
> > mentioned to tridge yesterday.  More discussion is in the comments.
> >
> > A sample input file is here
> >
> >   http://sourcefrog.net/projects/vstr-readpacket/
> >
> > I haven't benchmarked it other than running it under strace.
> I've had discussions with the author of vstr about his library. Personally
> I don't like it for a variety of reasons. Mainly IMHO C string
> abstractions are unncessary because of the powerful C feature that is
> pointer arithmetic.

I think you mean, "powerful way for people to take over your machine." :-)

If there is a way to get away from the security problems of char*
buffers without giving up too much speed or flexibility then I think
that's a good thing.

> More practically, one problem is that vstr has nothing
> to do with strings really. It's an I/O buffering strategy that trys to
> hide pointer arithmetic from the user by managing pointers to data that
> doesn't change. This might be useful to Samba for packet processing.

Well, that was what I was using it for here.

> I don't really know. But using it for character string manipulation
> might give you some problems because a) it is completely oblivious
> to internationalization 

It looks like there is some support but I haven't looked closely.  Is
it much harder to iconv things on top of Vstr than on top of char*?

> and b) certain manipulation is going to cause allocation and copying
> of possibly large numbers of little fragments.

Plain C strings can cause a great deal of allocation and copying too.
The question is, will Vstr be worse?  Indeed, this example addresses a
particular case of receiving on a nonblocking socket where it is quite
hard to avoid extensive copying in plain C.

> That can totally eliminate a lot of strlen/strcpy kind of work which
> is what vstr is designed to deal with.

Can you explain how suba helps?

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://lists.samba.org/archive/samba-technical/attachments/20040120/84749ee0/attachment.bin

More information about the samba-technical mailing list