You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by mt...@apache.org on 2010/05/20 07:12:37 UTC
svn commit: r946527 - /trafficserver/traffic/trunk/libinktomi++/SimpleDBM.cc
Author: mturk
Date: Thu May 20 05:12:36 2010
New Revision: 946527
URL: http://svn.apache.org/viewvc?rev=946527&view=rev
Log:
TS-358: Implement removed ink_file_lock directly
Modified:
trafficserver/traffic/trunk/libinktomi++/SimpleDBM.cc
Modified: trafficserver/traffic/trunk/libinktomi++/SimpleDBM.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/libinktomi%2B%2B/SimpleDBM.cc?rev=946527&r1=946526&r2=946527&view=diff
==============================================================================
--- trafficserver/traffic/trunk/libinktomi++/SimpleDBM.cc (original)
+++ trafficserver/traffic/trunk/libinktomi++/SimpleDBM.cc Thu May 20 05:12:36 2010
@@ -767,11 +767,20 @@ SimpleDBM::lock(bool shared_lock)
return (-EBADF);
}
ink_ProcessMutex_release(&_lock);
+ struct flock lock;
+
+ lock.l_type = shared_lock ? F_RDLCK : F_WRLCK;
+ lock.l_start = 0;
+ lock.l_whence = SEEK_SET;
+ lock.l_len = 0; // XXX: Shouldn't that be 1?
+
//
// ink_file_lock can block, so we shouldn't leave the mutex acquired,
// or we might never be able to unlock the file lock.
//
- return_code = ink_file_lock(_dbm_fd, (shared_lock ? F_RDLCK : F_WRLCK));
+ while ((return_code = fcntl(_dbm_fd, F_SETLKW, &lock)) < 0 &&
+ errno == EINTR)
+ continue;
if (return_code > 0)
return_code = 0;
#else // libdb not supported
@@ -832,7 +841,22 @@ SimpleDBM::unlock()
}
ink_ProcessMutex_release(&_lock);
- return_code = ink_file_lock(_dbm_fd, F_UNLCK);
+ struct flock lock;
+
+ lock.l_type = F_UNLCK;
+ lock.l_start = 0;
+ lock.l_whence = SEEK_SET;
+ lock.l_len = 0; // XXX: Shouldn't that be 1?
+
+ //
+ // ink_file_lock can block, so we shouldn't leave the mutex acquired,
+ // or we might never be able to unlock the file lock.
+ //
+ return_code = fcntl(_dbm_fd, F_SETLKW, &lock);
+ while ((return_code = fcntl(_dbm_fd, F_SETLKW, &lock)) < 0 &&
+ errno == EINTR)
+ continue;
+
if (return_code > 0)
return_code = 0;
#else // libdb not supported