trondn / memcached

Where I put all my changes :)
http://code.google.com/p/memcached/
BSD 3-Clause "New" or "Revised" License
33 stars 5 forks source link

The <delay> option of flush_all command might have a negative value. It's operation is undefined. #3

Open jhpark816 opened 13 years ago

jhpark816 commented 13 years ago

The flush_all command has "delay" option, whose value might be a negative integer. In that case, the correct operation of flush_all is not defined. I think, immediate invalidation might be proper in that case..

Just for your reference, google's memcached-1.4.5 performs immediate invalidation in case that "delay" option has a negative value..

So, following code update is needed in your engine branch.


void item_flush_expired(struct default_engine *engine, time_t when) {
    . . .

#if 1 // NEW CODE
    if (when <= 0) { // In case that the value of "delay" is 0 or a negative value.
#else // OLD CODE
    if (when == 0) {
#endif
        engine->config.oldest_live = engine->server.core->get_current_time() - 1;
    } else {
        engine->config.oldest_live = engine->server.core->realtime(when) - 1;
    }

    . . .
}