flock system call is not available on Solaris but it can be
replaced by calling fcntl. This patch will be sent upstream
after being reworked into a format that will be acceptable.
--- wget-1.17.1/src/hsts.c.orig Tue Jan 12 09:14:54 2016
+++ wget-1.17.1/src/hsts.c Tue Jan 12 09:16:55 2016
@@ -49,6 +49,7 @@
#include <string.h>
#include <stdio.h>
#include <sys/file.h>
+#include <fcntl.h>
struct hsts_store {
struct hash_table *table;
@@ -498,6 +499,7 @@
struct_stat st;
FILE *fp = NULL;
int fd = 0;
+ struct flock lock_data;
if (filename && hash_table_count (store->table) > 0)
{
@@ -506,7 +508,11 @@
{
/* Lock the file to avoid potential race conditions */
fd = fileno (fp);
- flock (fd, LOCK_EX);
+ lock_data.l_start = 0;
+ lock_data.l_len = 0;
+ lock_data.l_whence = SEEK_SET;
+ lock_data.l_type = F_WRLCK;
+ fcntl(fd, F_SETLKW, &lock_data);
/* If the file has changed, merge the changes with our in-memory data
before dumping them to the file.