1 This patch fixes debug logging so that it works on solaris. |
|
2 This patch has not been contributed upstream, but is planned to be done by |
|
3 2013-Jul-12. |
|
4 |
|
5 --- openscap-0.8.1/src/common/debug.c.orig 2012-11-19 10:04:47.622821073 -0800 |
|
6 +++ openscap-0.8.1/src/common/debug.c 2012-11-19 09:58:03.173819234 -0800 |
|
7 @@ -150,7 +150,11 @@ |
|
8 else |
|
9 f = file; |
|
10 |
|
11 +#if defined(__SVR4) && defined (__sun) |
|
12 + if (lockf(fileno(__debuglog_fp), F_LOCK, 0L) == -1) { |
|
13 +#else |
|
14 if (flock(fileno(__debuglog_fp), LOCK_EX) == -1) { |
|
15 +#endif |
|
16 __UNLOCK_FP; |
|
17 return; |
|
18 } |
|
19 @@ -178,7 +182,11 @@ |
|
20 #endif |
|
21 vfprintf(__debuglog_fp, fmt, ap); |
|
22 |
|
23 +#if defined(__SVR4) && defined (__sun) |
|
24 + if (lockf(fileno(__debuglog_fp), F_ULOCK, 0L) == -1) { |
|
25 +#else |
|
26 if (flock(fileno(__debuglog_fp), LOCK_UN) == -1) { |
|
27 +#endif |
|
28 /* __UNLOCK_FP; */ |
|
29 abort(); |
|
30 } |
|
31 @@ -232,8 +240,11 @@ |
|
32 fprintf (__debuglog_fp, "=============== LOG: %.24s ===============\n", st); |
|
33 atexit(&__oscap_debuglog_close); |
|
34 } |
|
35 - |
|
36 +#if defined(__SVR4) && defined (__sun) |
|
37 + if (lockf (fileno (__debuglog_fp), F_LOCK, 0L) == -1) { |
|
38 +#else |
|
39 if (flock (fileno (__debuglog_fp), LOCK_EX | LOCK_NB) == -1) { |
|
40 +#endif |
|
41 __UNLOCK_FP; |
|
42 return; |
|
43 } |
|
44 @@ -251,8 +262,11 @@ |
|
45 } |
|
46 |
|
47 fprintf(__debuglog_fp, "\n-----------\n"); |
|
48 - |
|
49 +#if defined(__SVR4) && defined (__sun) |
|
50 + if (lockf (fileno (__debuglog_fp), F_ULOCK, 0L) == -1) { |
|
51 +#else |
|
52 if (flock (fileno (__debuglog_fp), LOCK_UN | LOCK_NB) == -1) { |
|
53 +#endif |
|
54 /* __UNLOCK_FP; */ |
|
55 abort (); |
|
56 } |
|