*
*/
/*
- Copyright (C) 2000-2003 Kern Sibbald and John Walker
+ Copyright (C) 2000-2004 Kern Sibbald and John Walker
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
rwl->w_wait--; /* we are no longer waiting */
}
if (stat == 0) {
- rwl->w_active = 1; /* we are running */
+ rwl->w_active++; /* we are running */
rwl->writer_id = pthread_self(); /* save writer thread's id */
}
pthread_mutex_unlock(&rwl->mutex);
if ((stat = pthread_mutex_lock(&rwl->mutex)) != 0) {
return stat;
}
+ if (rwl->w_active <= 0) {
+ Emsg0(M_ABORT, 0, "rwl_writeunlock called too many times.\n");
+ }
rwl->w_active--;
- if (rwl->w_active < 0 || !pthread_equal(pthread_self(), rwl->writer_id)) {
+ if (!pthread_equal(pthread_self(), rwl->writer_id)) {
Emsg0(M_ABORT, 0, "rwl_writeunlock by non-owner.\n");
}
if (rwl->w_active > 0) {