One possible solution to your problem would be to have a DBF file with a list of all files that are currently locked. The files themselves would not be locked via flock() but access to the DBF file would be gated through flock().
locks will be maintained even if your server/client crashes and is then restarted;
having all processes use the same file may create a bottleneck. To minimize the probability of this happening, make sure the DBF file is locked only when necessary.