• A
    Add symmetrical assertion to track c->reply_buffer infinite growth. · 5c5e8a50
    antirez 提交于
    Redis clients need to have an instantaneous idea of the amount of memory
    they are consuming (if the number is not exact should at least be
    proportional to the actual memory usage). We do that adding and
    subtracting the SDS length when pushing / popping from the client->reply
    list. However it is quite simple to add bugs in such a setup, by not
    taking the objects in the list and the count in sync. For such reason,
    Redis has an assertion to track counts near 2^64: those are always the
    result of the counter wrapping around because we subtract more than we
    add. This commit adds the symmetrical assertion: when the list is empty
    since we sent everything, the reply_bytes count should be zero. Thanks
    to the new assertion it should be simple to also detect the other
    problem, where the count slowly increases because of over-counting.
    The assertion adds a conditional in the code that sends the buffer to
    the socket but should not create any measurable performance slowdown,
    listLength() just accesses a structure field, and this code path is
    totally dominated by write(2).
    
    Related to #4100.
    5c5e8a50
networking.c 74.0 KB