The main author of Bacula is Kern Sibbald, with contributions from
many others, a complete list can be found in the file AUTHORS.
This program is Free Software; you can redistribute it and/or
- modify it under the terms of version two of the GNU General Public
+ modify it under the terms of version three of the GNU Affero General Public
License as published by the Free Software Foundation and included
in the file LICENSE.
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
- You should have received a copy of the GNU General Public License
+ You should have received a copy of the GNU Affero General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
* Lock for write access, wait until locked (or error).
* Multiple nested write locking is permitted.
*/
-int devlock::writelock(int areason, bool acan_steal)
+int devlock::writelock(int areason, bool acan_take)
{
devlock *rwl = this;
int stat;
lmgr_post_lock();
}
rwl->reason = areason;
- rwl->can_steal = acan_steal;
+ rwl->can_take = acan_take;
pthread_mutex_unlock(&rwl->mutex);
return stat;
}
return (stat == 0 ? stat2 : stat);
}
+int devlock::take_lock(take_lock_t *hold, int areason)
+{
+ int stat;
+
+ if (valid != DEVLOCK_VALID) {
+ return EINVAL;
+ }
+ if ((stat = pthread_mutex_lock(&mutex)) != 0) {
+ return stat;
+ }
+ hold->reason = reason;
+ hold->prev_reason = prev_reason;
+ hold->writer_id = writer_id;
+ reason = areason;
+ writer_id = pthread_self();
+ stat = pthread_mutex_unlock(&mutex);
+ return stat;
+}
+
+int devlock::return_lock(take_lock_t *hold)
+{
+ int stat, stat2;
+
+ if (valid != DEVLOCK_VALID) {
+ return EINVAL;
+ }
+ if ((stat = pthread_mutex_lock(&mutex)) != 0) {
+ return stat;
+ }
+ reason = hold->reason;
+ prev_reason = hold->prev_reason;
+ writer_id = hold->writer_id;
+ writer_id = pthread_self();
+ stat2 = pthread_mutex_unlock(&mutex);
+ if (w_active || w_wait) {
+ stat = pthread_cond_broadcast(&write);
+ }
+ return (stat == 0 ? stat2 : stat);
+
+}
+
#ifdef TEST_RWLOCK
#define THREADS 300