• Tom Lane's avatar
    Code review for shm_toc.h/.c. · 3e60c6f7
    Tom Lane authored
    Declare the toc_nentry field as uint32 not Size.  Since shm_toc_lookup()
    reads the field without any lock, it has to be atomically readable, and
    we do not assume that for fields wider than 32 bits.  Performance would
    be impossibly bad for entry counts approaching 2^32 anyway, so there is
    no need to try to preserve maximum width here.
    
    This is probably an academic issue, because even if reading int64 isn't
    atomic, the high order half would never change in practice.  Still, it's
    a coding rule violation, so let's fix it.
    
    Adjust some other not-terribly-well-chosen data types too, and copy-edit
    some comments.  Make shm_toc_attach's Asserts consistent with
    shm_toc_create's.
    
    None of this looks to be a live bug, so no need for back-patch.
    
    Discussion: https://postgr.es/m/16984.1496679541@sss.pgh.pa.us
    3e60c6f7
shm_toc.h 2.2 KB