]> jspc29.x-matter.uni-frankfurt.de Git - daqdata.git/commitdiff
BUGFIXES -- mm
authorhadaq <hadaq>
Wed, 27 Aug 2003 13:09:03 +0000 (13:09 +0000)
committerhadaq <hadaq>
Wed, 27 Aug 2003 13:09:03 +0000 (13:09 +0000)
hadaq/agent.c
hadaq/worker.c

index f3f7b54ddf54a62f8edf0d6d0c91ad7864cfaf97..67a1fa0d786150eb67c547585682fbe72f6f4173 100644 (file)
@@ -1,8 +1,9 @@
-static char *rcsId = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/agent.c,v 6.13 2003-05-14 13:54:42 muench Exp $";
+static char *rcsId = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/agent.c,v 6.14 2003-08-27 13:09:03 hadaq Exp $";
 
 #define _GNU_SOURCE
 #include <unistd.h>
 #include <rpc/rpc.h>
+#include <syslog.h>
 #include "agent.h"
 #include "worker.h"
 
@@ -39,7 +40,7 @@ int *rpcworker_start_1(RpcWorker_startArgs * args, CLIENT * cl)
        char **argv;
 
        /* The closing NULL in argv cannot be passed via rpc, we have to add it
-     here */
+          here */
 
        argv = malloc((args->argv.argv_len + 1) * sizeof(char *));
 
@@ -48,7 +49,13 @@ int *rpcworker_start_1(RpcWorker_startArgs * args, CLIENT * cl)
        }
        argv[i] = NULL;
 
+       openlog("daq_agent", LOG_PID | LOG_PERROR, LOG_LOCAL0);
+       setlogmask(LOG_UPTO(LOG_INFO));
+
        Worker_start(args->name, argv);
+
+       closelog();
+
        retVal = addWorker(argv[0]);
 
        free(argv);
@@ -65,7 +72,13 @@ char **rpcworker_status_1(int *id, CLIENT * cl)
 {
        static char *retVal;
 
+       openlog("daq_agent", LOG_PID | LOG_PERROR, LOG_LOCAL0);
+       setlogmask(LOG_UPTO(LOG_INFO));
+
        retVal = Worker_status(getWorker(*id));
+
+       closelog();
+
        return &retVal;
 }
 
@@ -78,7 +91,13 @@ int *rpcworker_stop_1(int *id, CLIENT * cl)
 {
        static int retVal;
 
+       openlog("daq_agent", LOG_PID | LOG_PERROR, LOG_LOCAL0);
+       setlogmask(LOG_UPTO(LOG_INFO));
+
        Worker_stop(getWorker(*id), 15);
+
+       closelog();
+
        removeWorker(*id);
 
        retVal = 0;
index be697972aafd5e4980c60475c5c0c0b3b19df706..a87cca59de4c9944c8363c09e734a36214f0ec37 100644 (file)
@@ -1,4 +1,6 @@
-static char *rcsId = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/worker.c,v 6.23 2003-08-27 12:40:39 muench Exp $";
+static char *rcsId = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/worker.c,v 6.24 2003-08-27 13:09:03 hadaq Exp $";
+
+#define WORKER_NEW_PROTOCOL
 
 #define _POSIX_C_SOURCE 199309L
 #include <unistd.h>
@@ -238,7 +240,7 @@ int Worker_start(const char *path, char *const argv[])
        } else {
                if (my->pid == 0) {             /* This is the child, we can not get out of */
                        /* this block */
-                       syslog(LOG_INFO, "Starting worker %d (%s)", my->pid, path);
+                       syslog(LOG_INFO, "Starting worker %d (%s)", getpid(), path);
                        if (0 > execvp(path, argv)) {
                                syslog(LOG_DEBUG, "%s:%d: %s", __FILE__, __LINE__, strerror(errno));
                                syslog(LOG_EMERG, "Starting %s: %s", path, strerror(errno));
@@ -329,6 +331,8 @@ void Worker_stop(const char *name, int timeout)
                        if (0 == kill(my->pid, SIGTERM)) {
                                while (0 == kill(my->pid, 0)) {
                                        struct timespec t = { 1, 0 };
+
+                                       waitpid(my->pid, NULL, WNOHANG);
                                        nanosleep(&t, NULL);
                                }
                        }