summaryrefslogtreecommitdiffstats
path: root/lib/libc_r
diff options
context:
space:
mode:
authordt <dt@FreeBSD.org>1998-09-09 16:50:33 +0000
committerdt <dt@FreeBSD.org>1998-09-09 16:50:33 +0000
commit098e5b9a897e4a7344bcb8dcc9e5e46afab391f2 (patch)
tree025056c8e9ba7d0cff90716f5b9e1a11d9fd8e94 /lib/libc_r
parentb5a6b5d023d534210c7a5cccf500519a5eafc8bd (diff)
downloadFreeBSD-src-098e5b9a897e4a7344bcb8dcc9e5e46afab391f2.zip
FreeBSD-src-098e5b9a897e4a7344bcb8dcc9e5e46afab391f2.tar.gz
Fixed bug, caused threads to wait for locks which nobody hold.
Fixed sign extension bug, caused undefined behavior if FILE live in stack.
Diffstat (limited to 'lib/libc_r')
-rw-r--r--lib/libc_r/uthread/uthread_file.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/libc_r/uthread/uthread_file.c b/lib/libc_r/uthread/uthread_file.c
index af2ed5a..0fb52a9 100644
--- a/lib/libc_r/uthread/uthread_file.c
+++ b/lib/libc_r/uthread/uthread_file.c
@@ -29,7 +29,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: uthread_file.c,v 1.4 1998/06/09 23:20:44 jb Exp $
+ * $Id: uthread_file.c,v 1.5 1998/09/07 21:55:01 alex Exp $
*
* POSIX stdio FILE locking functions. These assume that the locking
* is only required at FILE structure level, not at file descriptor
@@ -82,7 +82,7 @@ struct file_lock {
* structures. If there is a collision, a linear search of the
* dynamic list of locks linked to each static lock is perfomed.
*/
-#define file_idx(_p) ((((long) _p) >> sizeof(void *)) % NUM_HEADS)
+#define file_idx(_p) ((((u_long) _p) >> sizeof(void *)) % NUM_HEADS)
/*
* Global array of file locks. The first lock for each hash bucket is
@@ -122,7 +122,7 @@ find_lock(int idx, FILE *fp)
* Loop through the dynamic locks looking for the
* target file:
*/
- while (p != NULL && p->fp != fp && p->owner != NULL)
+ while (p != NULL && (p->fp != fp || p->owner == NULL))
/* Not this file, try the next: */
p = p->entry.le_next;
}
OpenPOWER on IntegriCloud