Subject: | test for whether file is being opened for writing is broken |
This code is not doing what you'd think, and will _always_ be true:
$dbfile_data[1] && O_RDWR or $dbfile_data[1] && O_WRONLY
You need to use bitwise-and (&), like this:
$dbfile_data[1] & O_RDWR or $dbfile_data[1] & O_WRONLY