[lkml]   [2012]   [Feb]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
    SubjectRe: compat: autofs v5 packet size ambiguity - update
    On 02/22/2012 08:10 AM, Linus Torvalds wrote:
    > Well, the kernel gives the right semantics for pipes too - writes are
    > guaranteed to be "atomic", so even in the presence of multiple writers
    > you can trivially do packetized data.
    > You just have to (a) add the length to the packet and (b) do the
    > length+packet write as a single write (which is limited to PIPE_SIZE -
    > 4kB - for the atomicity guarantee).
    > If you don't have multiple concurrent writers without locking, the (b)
    > part falls away entirely, of course.
    > Yes, for the reader side you need to be able to handle the fact that
    > you can get more than one packet in one read() call, but sorting that
    > out isn't hard either.

    What you describe above is pretty much how autofs 3 used to work; except
    it would do one read() for the header including length and then another
    read() for the body. Of course, it could just have read ahead -- if you
    read part of the next packet, it wouldn't really matter since at least
    at that time the daemon was single-threaded and would have to loop back

    The PIPE_SIZE guarantee took care of the fact that this was a multiple
    writer/single reader situation (since the writes happens in the context
    of the process requesting a mount.) Either way, SOCK_DGRAM and
    SOCK_SEQPACKET would solve all of the problems and would Just Work, and
    packet boundaries would then be explicit.

    > But yeah, writing fixed-size data and then having a reader that reads
    > fixed-size data is just not a very good approach. It's doubly bad when
    > the "fixed size" isn't an explicit size that is documented in the
    > protocol, but depends on data structures.



    H. Peter Anvin, Intel Open Source Technology Center
    I work for Intel. I don't speak on their behalf.

     \ /
      Last update: 2012-02-22 18:47    [W:0.022 / U:19.100 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site