summaryrefslogtreecommitdiffstats
path: root/package/squashfs/squashfs-4.0-mksquashfs-race-condition-fix.patch
blob: 7f8e8e0749566193c2c32c0c288dbd97d89711ea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
[PATCH]: fix mksquashfs race condition

See http://thread.gmane.org/gmane.comp.file-systems.squashfs.devel/76
for details.
---
 squashfs-tools/mksquashfs.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Index: squashfs4.0/squashfs-tools/mksquashfs.c
===================================================================
--- squashfs4.0.orig/squashfs-tools/mksquashfs.c
+++ squashfs4.0/squashfs-tools/mksquashfs.c
@@ -1733,8 +1733,8 @@ void unlock_fragments()
 		entry->buffer->block = bytes;
 		bytes += compressed_size;
 		fragments_outstanding --;
-		pthread_mutex_unlock(&fragment_mutex);
 		queue_put(to_writer, entry->buffer);
+		pthread_mutex_unlock(&fragment_mutex);
 		pthread_mutex_lock(&fragment_mutex);
 		TRACE("fragment_locked writing fragment %d, compressed size %d"
 			"\n", entry->fragment, compressed_size);
@@ -2426,8 +2426,8 @@ void *frag_deflator(void *arg)
 			write_buffer->block = bytes;
 			bytes += compressed_size;
 			fragments_outstanding --;
-			pthread_mutex_unlock(&fragment_mutex);
 			queue_put(to_writer, write_buffer);
+			pthread_mutex_unlock(&fragment_mutex);
 			TRACE("Writing fragment %lld, uncompressed size %d, "
 				"compressed size %d\n", file_buffer->block,
 				file_buffer->size, compressed_size);
@@ -4137,7 +4137,7 @@ void read_recovery_data(char *recovery_f
 
 
 #define VERSION() \
-	printf("mksquashfs version 4.0 (2009/04/05)\n");\
+	printf("mksquashfs version 4.0-test (2009/04/05)\n");\
 	printf("copyright (C) 2009 Phillip Lougher <phillip@lougher.demon.co.uk>\n\n"); \
 	printf("This program is free software; you can redistribute it and/or\n");\
 	printf("modify it under the terms of the GNU General Public License\n");\