Some cleanups/fixes for the syslogd circular buffer code
authorEric Andersen <andersen@codepoet.org>
Thu, 5 Apr 2001 20:55:17 +0000 (20:55 -0000)
committerEric Andersen <andersen@codepoet.org>
Thu, 5 Apr 2001 20:55:17 +0000 (20:55 -0000)
from Gennady Feldman.

sysklogd/syslogd.c
syslogd.c

index e83ce48ae46e9444cc4cbe8d386e69908425feb5..6aec78b4ef8ceab59e3d3dd3a6e7ef3da2aa2795 100644 (file)
@@ -119,7 +119,7 @@ static inline void sem_up(int semid)
  */
 static inline void sem_down(int semid)
 {
-       if ( semop(semid, SMwdn, 2) == -1 )
+       if ( semop(semid, SMwdn, 3) == -1 )
                perror_msg_and_die("semop[SMwdn]");
 }
 
@@ -155,6 +155,8 @@ void ipcsyslog_init(void){
                    perror_msg_and_die("semget");
                }else
                        perror_msg_and_die("semget");
+           } else {
+                   sem_up(s_semid);
            }
        }else{
                printf("Buffer already allocated just grab the semaphore?");
@@ -514,6 +516,12 @@ static void doSyslogd (void)
        FD_ZERO (&fds);
        FD_SET (sock_fd, &fds);
 
+#ifdef BB_FEATURE_IPC_SYSLOG
+       if (circular_logging == TRUE ){
+          ipcsyslog_init();
+       }
+#endif
+
         #ifdef BB_FEATURE_REMOTE_LOG
         if (doRemoteLog == TRUE){
           init_RemoteLog();
@@ -619,12 +627,6 @@ extern int syslogd_main(int argc, char **argv)
 
        umask(0);
 
-#ifdef BB_FEATURE_IPC_SYSLOG
-       if (circular_logging == TRUE ){
-          ipcsyslog_init();
-       }
-#endif
-
        if (doFork == TRUE) {
                if (daemon(0, 1) < 0)
                        perror_msg_and_die("daemon");
index e83ce48ae46e9444cc4cbe8d386e69908425feb5..6aec78b4ef8ceab59e3d3dd3a6e7ef3da2aa2795 100644 (file)
--- a/syslogd.c
+++ b/syslogd.c
@@ -119,7 +119,7 @@ static inline void sem_up(int semid)
  */
 static inline void sem_down(int semid)
 {
-       if ( semop(semid, SMwdn, 2) == -1 )
+       if ( semop(semid, SMwdn, 3) == -1 )
                perror_msg_and_die("semop[SMwdn]");
 }
 
@@ -155,6 +155,8 @@ void ipcsyslog_init(void){
                    perror_msg_and_die("semget");
                }else
                        perror_msg_and_die("semget");
+           } else {
+                   sem_up(s_semid);
            }
        }else{
                printf("Buffer already allocated just grab the semaphore?");
@@ -514,6 +516,12 @@ static void doSyslogd (void)
        FD_ZERO (&fds);
        FD_SET (sock_fd, &fds);
 
+#ifdef BB_FEATURE_IPC_SYSLOG
+       if (circular_logging == TRUE ){
+          ipcsyslog_init();
+       }
+#endif
+
         #ifdef BB_FEATURE_REMOTE_LOG
         if (doRemoteLog == TRUE){
           init_RemoteLog();
@@ -619,12 +627,6 @@ extern int syslogd_main(int argc, char **argv)
 
        umask(0);
 
-#ifdef BB_FEATURE_IPC_SYSLOG
-       if (circular_logging == TRUE ){
-          ipcsyslog_init();
-       }
-#endif
-
        if (doFork == TRUE) {
                if (daemon(0, 1) < 0)
                        perror_msg_and_die("daemon");