Boost logo

Boost :

From: Lars Hagström (lars_at_[hidden])
Date: 2008-06-30 04:41:31


Hi,

I've just tried to use the file_locks from the boost trunk, and stumbled
across a bug (well, two related bugs, really) when using the try_lock*
metods.
The problem occurs on linux systems only.

The try_acquire_file_lock_sharable and try_acquire_file_lock functions
both have the following code in them:

    int ret = ::fcntl(hnd, F_SETLK, &lock);
    if(ret == -1){
       return (errno != EAGAIN && errno != EACCES) ?
                acquired = false, true : false;
    }

I believe this should be changed into

    int ret = ::fcntl(hnd, F_SETLK, &lock);
    if(ret == -1){
       return (errno == EAGAIN || errno == EACCES) ?
                acquired = false, true : false;
    }

(its the errno checking line that is changed)
Without my fix the result of trying to lock a lock that someone else has
is an exception.

Cheers
Lars




Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk