- lock.l_start = 0;
- lock.l_whence = SEEK_SET;
- lock.l_len = 0;
- lock.l_type = F_WRLCK;
-
- if (fcntl(lockfd, F_SETLK, &lock) < 0) {
- if (errno == EACCES || errno == EAGAIN) {
- if (exclusive) {
- dbd_log(LOGSTD, "Database is in use and exlusive was requested");
+ lock.l_start = 0;
+ lock.l_whence = SEEK_SET;
+ lock.l_len = 0;
+ if (cmd == LOCK_EXCL)
+ lock.l_type = F_WRLCK;
+ else
+ lock.l_type = F_RDLCK;
+
+ if (fcntl(lockfd, F_SETLK, &lock) < 0) {
+ if (errno == EACCES || errno == EAGAIN) {
+ dbd_log(LOGDEBUG, "get_lock: couldn't lock");
+ return 0;
+ } else {
+ dbd_log( LOGSTD, "Error getting fcntl F_WRLCK on lockfile: %s",
+ strerror(errno));