Fix #156: Only flock if non-blocking and we actually obtain the lock

The issue starts off regarding NFS file systems not supporting locking, but this is really careful programming. Since it is a debug log we might not want to actually still attempt to write (I left it in there) but went over the documents at http://php.net/manual/en/function.flock.php and it seems this is the correct way to go.