added support for locking using flock