components/wget/patches/hsts.c.patch
author Mike Sullivan <Mike.Sullivan@Oracle.COM>
Wed, 13 Jul 2016 08:34:06 -0700
changeset 6404 776ac4e2d089
parent 5309 aa644d83002b
permissions -rw-r--r--
backout 23763310 - needs more work

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.