• Nils Goroll's avatar
    close a potential race which could cause an out-of-bounds array access · 9edb2b65
    Nils Goroll authored
    We're only holding a read lock on the director, but we're updating
    the nxt member concurrently. This should be acceptable as a performance
    tradeoff - the only consequence is that round-robin is not strictly
    going around - it may occasionally skip a backend or hand out the same
    multiple times in a row.
    
    the race is:
    
    	thread	code
    
    	A:	rr->nxt %= rr->vd->n_backend;
    	// rr->nxt == rr->vd->n_backend - 1
    	B:	rr->nxt++;
    	// rr->nxt == rr->vd->n_backend
    	A:	be = rr->vd->backend[nxt];
    	// BOOM
    
    should fix #2024
    9edb2b65
round_robin.c 4.09 KB