components/openscap/patches/debug.c.patch
author Rich Burridge <rich.burridge@oracle.com>
Mon, 05 Jan 2015 13:33:36 -0800
changeset 3581 ac4a2e93e035
parent 1369 20813e08fff3
permissions -rw-r--r--
20231085 problem in UTILITY/ERLANG

This patch fixes debug logging so that it works on solaris.
This patch has not been contributed upstream, but is planned to be done by
 2013-Jul-12.

--- openscap-0.8.1/src/common/debug.c.orig	2012-11-19 10:04:47.622821073 -0800
+++ openscap-0.8.1/src/common/debug.c	2012-11-19 09:58:03.173819234 -0800
@@ -150,7 +150,11 @@
 	else
 		f = file;
 
+#if defined(__SVR4) && defined (__sun)
+	if (lockf(fileno(__debuglog_fp), F_LOCK, 0L) == -1) {
+#else
 	if (flock(fileno(__debuglog_fp), LOCK_EX) == -1) {
+#endif
 		__UNLOCK_FP;
 		return;
 	}
@@ -178,7 +182,11 @@
 #endif
 	vfprintf(__debuglog_fp, fmt, ap);
 
+#if defined(__SVR4) && defined (__sun)
+	if (lockf(fileno(__debuglog_fp), F_ULOCK, 0L) == -1) {
+#else
 	if (flock(fileno(__debuglog_fp), LOCK_UN) == -1) {
+#endif
 		/* __UNLOCK_FP; */
 		abort();
 	}
@@ -232,8 +240,11 @@
                 fprintf (__debuglog_fp, "=============== LOG: %.24s ===============\n", st);
                 atexit(&__oscap_debuglog_close);
         }
-
+#if defined(__SVR4) && defined (__sun)
+        if (lockf (fileno (__debuglog_fp), F_LOCK, 0L) == -1) {
+#else
         if (flock (fileno (__debuglog_fp), LOCK_EX | LOCK_NB) == -1) {
+#endif
                 __UNLOCK_FP;
                 return;
         }
@@ -251,8 +262,11 @@
         }
 
         fprintf(__debuglog_fp, "\n-----------\n");
-
+#if defined(__SVR4) && defined (__sun)
+        if (lockf (fileno (__debuglog_fp), F_ULOCK, 0L) == -1) {
+#else
         if (flock (fileno (__debuglog_fp), LOCK_UN | LOCK_NB) == -1) {
+#endif
                 /* __UNLOCK_FP; */
                 abort ();
         }