equal
deleted
inserted
replaced
|
1 flock system call is not available on Solaris but it can be |
|
2 replaced by calling fcntl. This patch will be sent upstream |
|
3 after being reworked into a format that will be acceptable. |
|
4 |
|
5 --- wget-1.17.1/src/hsts.c.orig Tue Jan 12 09:14:54 2016 |
|
6 +++ wget-1.17.1/src/hsts.c Tue Jan 12 09:16:55 2016 |
|
7 @@ -49,6 +49,7 @@ |
|
8 #include <string.h> |
|
9 #include <stdio.h> |
|
10 #include <sys/file.h> |
|
11 +#include <fcntl.h> |
|
12 |
|
13 struct hsts_store { |
|
14 struct hash_table *table; |
|
15 @@ -498,6 +499,7 @@ |
|
16 struct_stat st; |
|
17 FILE *fp = NULL; |
|
18 int fd = 0; |
|
19 + struct flock lock_data; |
|
20 |
|
21 if (filename && hash_table_count (store->table) > 0) |
|
22 { |
|
23 @@ -506,7 +508,11 @@ |
|
24 { |
|
25 /* Lock the file to avoid potential race conditions */ |
|
26 fd = fileno (fp); |
|
27 - flock (fd, LOCK_EX); |
|
28 + lock_data.l_start = 0; |
|
29 + lock_data.l_len = 0; |
|
30 + lock_data.l_whence = SEEK_SET; |
|
31 + lock_data.l_type = F_WRLCK; |
|
32 + fcntl(fd, F_SETLKW, &lock_data); |
|
33 |
|
34 /* If the file has changed, merge the changes with our in-memory data |
|
35 before dumping them to the file. |