Skip to content
  • Simon McVittie's avatar
    GDBusWorker: combine num_writes_pending with flush_pending · a8f75f21
    Simon McVittie authored
    num_writes_pending was a counter, but it only took values 0 or 1, so make
    it a boolean: it would never make sense to be trying to write out two
    messages at the same time (they'd get interleaved).
    
    Similarly, we can never be writing and flushing at the same time (that'd
    mean we were flushing halfway through a message, which would be pointless)
    so combine it with flush_pending too, calling the result output_pending.
    
    Also assert that it takes the expected value whenever we change it,
    and document the locking discipline used for it, including a subtle
    case in write_message_in_idle_cb where it's not obvious at first glance
    why we don't need the lock.
    
    (Having the combined boolean at the top of the block of write-related
    struct members improves struct packing on 64-bit platforms, by packing
    read_num_ancillary_messages and output_pending into one word.)
    
    Bug: https://bugzilla.gnome.org/show_bug.cgi?id=651268
    
    
    Bug-NB: NB#271520
    Signed-off-by: default avatarSimon McVittie <simon.mcvittie@collabora.co.uk>
    Signed-off-by: default avatarDavid Zeuthen <davidz@redhat.com>
    a8f75f21