File: fix-num-free-blocks-224984

package info (click to toggle)
buffer 1.19-12
  • links: PTS
  • area: main
  • in suites: bookworm, bullseye, buster, jessie, jessie-kfreebsd, stretch
  • size: 500 kB
  • sloc: ansic: 8,475; makefile: 124; sh: 35
file content (21 lines) | stat: -rw-r--r-- 815 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
--- a/buffer.c
+++ b/buffer.c
@@ -528,8 +528,17 @@
 	pbuffer->blocks_free_lock = 1;
 	/* start this off so lock() can be called on it for each block
 	 * till all the blocks are used up */
+	/* Initializing the semaphore to "blocks - 1" causes a hang when using option
+	 * "-p 100" because it always keeps one block free, so we'll never reach 100% fill
+	 * level. However, there doesn't seem to be a good reason to keep one block free,
+	 * so we initialize the semaphore to "blocks" instead.
+	 * <mbuck@debian.org> 2004-01-11
+	 */	
+#if 0
 	sem_set( pbuffer->semid, pbuffer->blocks_free_lock, blocks - 1 );
-
+#else
+	sem_set( pbuffer->semid, pbuffer->blocks_free_lock, blocks );
+#endif
 	/* Detattach the shared memory so the fork doesnt do anything odd */
 	shmdt( (char *)pbuffer );
 	pbuffer = NO_BUFFER;