new upstream release (3.3.0); modify package compatibility for Stretch
[ossec-hids.git] / src / shared / wait_op.c
old mode 100755 (executable)
new mode 100644 (file)
index 53bc664..927891d
@@ -1,6 +1,3 @@
-/* @(#) $Id: ./src/shared/wait_op.c, 2011/09/08 dcid Exp $
- */
-
 /* Copyright (C) 2009 Trend Micro Inc.
  * All rights reserved.
  *
  * Foundation
  */
 
-
 #include "shared.h"
+
 #define LOCK_LOOP   5
-int __wait_lock = 0;
+
+static int __wait_lock = 0;
 
 
-/* Creates global lock */
+/* Create global lock */
 void os_setwait()
 {
     FILE *fp = NULL;
 
-    /* For same threads. */
+    /* For same threads */
     __wait_lock = 1;
 
-
-    if(isChroot())
-    {
+    if (isChroot()) {
         fp = fopen(WAIT_FILE, "w");
-    }
-    else
-    {
+    } else {
         fp = fopen(WAIT_FILE_PATH, "w");
     }
 
-    if(fp)
-    {
+    if (fp) {
         fprintf(fp, "l");
         fclose(fp);
     }
@@ -43,25 +36,19 @@ void os_setwait()
     return;
 }
 
-
-/* Removes global lock */
+/* Remove global lock */
 void os_delwait()
 {
     __wait_lock = 0;
 
-    if(isChroot())
-    {
+    if (isChroot()) {
         unlink(WAIT_FILE);
-    }
-    else
-    {
+    } else {
         unlink(WAIT_FILE_PATH);
     }
     return;
 }
 
-
-
 /* Check for the wait file. If present, wait.
  * Works as a simple inter process lock (only the main
  * process is allowed to lock).
@@ -69,71 +56,63 @@ void os_delwait()
 #ifdef WIN32
 void os_wait()
 {
-    if(!__wait_lock)
+    if (!__wait_lock) {
         return;
+    }
 
-
-    /* Wait until the lock is gone. */
+    /* Wait until the lock is gone */
     verbose(WAITING_MSG, __local_name);
-    while(1)
-    {
-        if(!__wait_lock)
+    while (1) {
+        if (!__wait_lock) {
             break;
+        }
 
-        /* Sleep LOCK_LOOP seconds and check it lock is gone. */
+        /* Sleep LOCK_LOOP seconds and check if lock is gone */
         sleep(LOCK_LOOP);
     }
 
-
     verbose(WAITING_FREE, __local_name);
     return;
 
 }
-#else
 
+#else /* !WIN32 */
 
 void os_wait()
 {
     struct stat file_status;
 
-
-    /* If the wait file is not present, keep going.
-     */
-    if(isChroot())
-    {
-        if(stat(WAIT_FILE, &file_status) == -1)
+    /* If the wait file is not present, keep going */
+    if (isChroot()) {
+        if (stat(WAIT_FILE, &file_status) == -1) {
             return;
-    }
-    else
-    {
-        if(stat(WAIT_FILE_PATH, &file_status) == -1)
+        }
+    } else {
+        if (stat(WAIT_FILE_PATH, &file_status) == -1) {
             return;
+        }
     }
 
-
-    /* Wait until the lock is gone. */
+    /* Wait until the lock is gone */
     verbose(WAITING_MSG, __local_name);
-    while(1)
-    {
-        if(isChroot())
-        {
-            if(stat(WAIT_FILE, &file_status) == -1)
+    while (1) {
+        if (isChroot()) {
+            if (stat(WAIT_FILE, &file_status) == -1) {
                 break;
-        }
-        else
-        {
-            if(stat(WAIT_FILE_PATH, &file_status) == -1)
+            }
+        } else {
+            if (stat(WAIT_FILE_PATH, &file_status) == -1) {
                 break;
+            }
         }
 
-        /* Sleep LOCK_LOOP seconds and check it lock is gone. */
+        /* Sleep LOCK_LOOP seconds and check if lock is gone */
         sleep(LOCK_LOOP);
     }
 
     verbose(WAITING_FREE, __local_name);
     return;
 }
-#endif
 
+#endif /* !WIN32 */
 
-/* EOF */