]> jspc29.x-matter.uni-frankfurt.de Git - daqdata.git/commitdiff
*** empty log message ***
authorhadaq <hadaq>
Fri, 7 Feb 2003 11:42:28 +0000 (11:42 +0000)
committerhadaq <hadaq>
Fri, 7 Feb 2003 11:42:28 +0000 (11:42 +0000)
hadaq/configure
hadaq/configure.in
hadaq/worker.c

index 71648065d65bf3d44480e1be4ac436208e3b80d9..d5ee6955cb67c58c7716058e1b6684da0b51d8fc 100644 (file)
@@ -803,6 +803,10 @@ Optional Packages:
   --with-param=ARG      use the given parameter source, default is "tcl"
   --with-hardware=ARG   use the given readout code, default is "soft",
                           possible values are rich, mdc, show, trig, soft
+\
+  --with-epics=ARG      indicates the epics base directory, take
+                          default from enviroment EPICS_BASE \
+
 
 Some influential environment variables:
   CC          C compiler command
@@ -1647,6 +1651,14 @@ else
   with_hardware="soft"
 fi;
 
+# Check whether --with-epics or --without-epics was given.
+if test "${with_epics+set}" = set; then
+  withval="$with_epics"
+
+else
+  with_epics="$EPICS_BASE"
+fi;
+
 ac_ext=c
 ac_cpp='$CPP $CPPFLAGS'
 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
@@ -3254,7 +3266,245 @@ if test "$ac_cv_search_syslog" != no; then
 fi
 
 
-if test x$with_param = xfile
+if test x$with_param = xca
+then
+if test -x "$with_epics/startup/HostArch"
+then
+       epics_version="3_13"
+       HOST_ARCH=$($with_epics/startup/HostArch)
+elif test -x "$with_epics/startup/EpicsHostArch"
+then
+       epics_version="3_14"
+       HOST_ARCH=$($with_epics/startup/EpicsHostArch)
+else
+       { { echo "$as_me:$LINENO: error: Missing valid EPICS version" >&5
+echo "$as_me: error: Missing valid EPICS version" >&2;}
+   { (exit 1); exit 1; }; }
+fi
+if test "x$epics_version" = "x3_13"
+then
+       LIBS="-L$with_epics/lib/$HOST_ARCH $LIBS"
+elif test "x$epics_version" = "x3_14"
+then
+       LIBS="-L$with_epics/lib/$EPICS_HOST_ARCH $LIBS"
+fi
+echo "$as_me:$LINENO: checking for library containing Tcl_CreateInterp" >&5
+echo $ECHO_N "checking for library containing Tcl_CreateInterp... $ECHO_C" >&6
+if test "${ac_cv_search_Tcl_CreateInterp+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_func_search_save_LIBS=$LIBS
+ac_cv_search_Tcl_CreateInterp=no
+cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+#include "confdefs.h"
+
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char Tcl_CreateInterp ();
+#ifdef F77_DUMMY_MAIN
+#  ifdef __cplusplus
+     extern "C"
+#  endif
+   int F77_DUMMY_MAIN() { return 1; }
+#endif
+int
+main ()
+{
+Tcl_CreateInterp ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_search_Tcl_CreateInterp="none required"
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+if test "$ac_cv_search_Tcl_CreateInterp" = no; then
+  for ac_lib in tcl; do
+    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
+    cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+#include "confdefs.h"
+
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char Tcl_CreateInterp ();
+#ifdef F77_DUMMY_MAIN
+#  ifdef __cplusplus
+     extern "C"
+#  endif
+   int F77_DUMMY_MAIN() { return 1; }
+#endif
+int
+main ()
+{
+Tcl_CreateInterp ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_search_Tcl_CreateInterp="-l$ac_lib"
+break
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+  done
+fi
+LIBS=$ac_func_search_save_LIBS
+fi
+echo "$as_me:$LINENO: result: $ac_cv_search_Tcl_CreateInterp" >&5
+echo "${ECHO_T}$ac_cv_search_Tcl_CreateInterp" >&6
+if test "$ac_cv_search_Tcl_CreateInterp" != no; then
+  test "$ac_cv_search_Tcl_CreateInterp" = "none required" || LIBS="$ac_cv_search_Tcl_CreateInterp $LIBS"
+
+fi
+
+echo "$as_me:$LINENO: checking for library containing conParam" >&5
+echo $ECHO_N "checking for library containing conParam... $ECHO_C" >&6
+if test "${ac_cv_search_conParam+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_func_search_save_LIBS=$LIBS
+ac_cv_search_conParam=no
+cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+#include "confdefs.h"
+
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char conParam ();
+#ifdef F77_DUMMY_MAIN
+#  ifdef __cplusplus
+     extern "C"
+#  endif
+   int F77_DUMMY_MAIN() { return 1; }
+#endif
+int
+main ()
+{
+conParam ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_search_conParam="none required"
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+if test "$ac_cv_search_conParam" = no; then
+  for ac_lib in caParam; do
+    LIBS="-l$ac_lib -lca -lCom $ac_func_search_save_LIBS"
+    cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+#include "confdefs.h"
+
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char conParam ();
+#ifdef F77_DUMMY_MAIN
+#  ifdef __cplusplus
+     extern "C"
+#  endif
+   int F77_DUMMY_MAIN() { return 1; }
+#endif
+int
+main ()
+{
+conParam ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_search_conParam="-l$ac_lib"
+break
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+  done
+fi
+LIBS=$ac_func_search_save_LIBS
+fi
+echo "$as_me:$LINENO: result: $ac_cv_search_conParam" >&5
+echo "${ECHO_T}$ac_cv_search_conParam" >&6
+if test "$ac_cv_search_conParam" != no; then
+  test "$ac_cv_search_conParam" = "none required" || LIBS="$ac_cv_search_conParam $LIBS"
+  LIBS="-lcaParam -lca -lCom $LIBS"
+fi
+
+elif test x$with_param = xfile
 then
 echo "$as_me:$LINENO: checking for library containing conParam" >&5
 echo $ECHO_N "checking for library containing conParam... $ECHO_C" >&6
@@ -3587,6 +3837,12 @@ else
 echo "$as_me: error: Unknown parameter source $with_param" >&2;}
    { (exit 1); exit 1; }; }
 fi
+if test x$ac_cv_search_conParam = xno
+then
+{ { echo "$as_me:$LINENO: error: Parameter library not found" >&5
+echo "$as_me: error: Parameter library not found" >&2;}
+   { (exit 1); exit 1; }; }
+fi
 
 if test x$enable_manage = xyes
 then
index 368ec5e3a8de7918cf1d06aaad5ae1c5b3da1f8f..de00bb5e370694f22113f4c4b6482d5ba80d9024 100644 (file)
@@ -11,6 +11,10 @@ AC_ARG_ENABLE(manage, [  --enable-manage         enable build of daq_manage, nee
 AC_ARG_WITH(param, [  --with-param[=ARG]      use the given parameter source, default is "tcl"],,with_param="tcl")
 AC_ARG_WITH(hardware, [  --with-hardware[=ARG]   use the given readout code, default is "soft",
                           possible values are rich, mdc, show, trig, soft],,with_hardware="soft")
+AC_ARG_WITH(epics, \
+[  --with-epics[=ARG]      indicates the epics base directory, take
+                          default from enviroment EPICS_BASE] \
+,,with_epics="$EPICS_BASE")
 
 dnl Checks for programs.
 AC_PROG_CC
@@ -34,7 +38,29 @@ AC_SEARCH_LIBS(svc_register, rpc)
 
 AC_SEARCH_LIBS(syslog, netinet)
 
-if test x$with_param = xfile
+if test x$with_param = xca
+then
+if test -x "$with_epics/startup/HostArch"
+then
+       epics_version="3_13"
+       HOST_ARCH=$($with_epics/startup/HostArch)
+elif test -x "$with_epics/startup/EpicsHostArch"
+then
+       epics_version="3_14"
+       HOST_ARCH=$($with_epics/startup/EpicsHostArch)
+else
+       AC_ERROR([Missing valid EPICS version])
+fi
+if test "x$epics_version" = "x3_13"
+then
+       LIBS="-L$with_epics/lib/$HOST_ARCH $LIBS"
+elif test "x$epics_version" = "x3_14"
+then
+       LIBS="-L$with_epics/lib/$EPICS_HOST_ARCH $LIBS"
+fi
+AC_SEARCH_LIBS(Tcl_CreateInterp, tcl)
+AC_SEARCH_LIBS(conParam, caParam, LIBS="-lcaParam -lca -lCom $LIBS",, -lca -lCom)
+elif test x$with_param = xfile
 then
 AC_SEARCH_LIBS(conParam, fileParam)
 elif test x$with_param = xtcl
@@ -44,6 +70,10 @@ AC_SEARCH_LIBS(conParam, tclParam)
 else
 AC_ERROR([Unknown parameter source $with_param])
 fi
+if test x$ac_cv_search_conParam = xno
+then
+AC_ERROR([Parameter library not found])
+fi
 
 if test x$enable_manage = xyes
 then
index 31103fc69f1270942ff46e157fb6453ca0fb22ce..c4168e54213b75d303f5c127bfb70f312fa47a2e 100644 (file)
@@ -1,5 +1,6 @@
-static char *rcsId = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/worker.c,v 6.14 2002-11-07 12:48:49 hadaq Exp $";
+static char *rcsId = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/worker.c,v 6.15 2003-02-07 11:42:28 hadaq Exp $";
 
+#undef WORKER_NEW_PROTOCOL
 
 #define _POSIX_C_SOURCE 199309L
 #include <unistd.h>
@@ -63,7 +64,9 @@ static int createStatShm(Worker *my)
                syslog(LOG_DEBUG, "%s:%d: %s", __FILE__, __LINE__, strerror(errno));
                retVal = -1;
        } else {
-               my->shm = PsxShm_open(ipcName, O_CREAT | O_RDWR, S_IRWXU, WORKER_MAX_NUM_STATS * sizeof(Statistic));
+               my->shm =
+                       PsxShm_open(ipcName, O_CREAT | O_RDWR, S_IRWXU,
+                                               WORKER_MAX_NUM_STATS * sizeof(Statistic));
                if (NULL == my->shm) {
                        syslog(LOG_DEBUG, "%s:%d: %s", __FILE__, __LINE__, strerror(errno));
                        retVal = -1;
@@ -103,9 +106,10 @@ static int openStatShm(Worker *my)
        ipcName = basename(ipcNameS);
        strcat(ipcName, ".shm");
 
-       my->shm = PsxShm_open(ipcName, O_RDWR, 0, WORKER_MAX_NUM_STATS * sizeof(Statistic));
+       my->shm =
+               PsxShm_open(ipcName, O_RDWR, 0,
+                                       WORKER_MAX_NUM_STATS * sizeof(Statistic));
        if (NULL == my->shm) {
-               syslog(LOG_DEBUG, "%s:%d: %s", __FILE__, __LINE__, strerror(errno));
                retVal = -1;
        } else {
                my->statistics = my->shm->addr;
@@ -120,12 +124,15 @@ static int closeStatShm(Worker *my)
        return PsxShm_close(my->shm);
 }
 
-static int removeSigHandlers(Worker *my) {
+static int removeSigHandlers(Worker *my)
+{
        return sigaction(my->signal0, my->oldSigAction0, NULL)
                | sigaction(my->signal1, my->oldSigAction1, NULL);
 }
 
-static int installSigHandlers(Worker *my, int s0, int s1, void (*sigHandler) (int)) {
+static int installSigHandlers(Worker *my, int s0, int s1,
+                                                         void (*sigHandler) (int))
+{
        int retVal;
        struct sigaction actS, *act = &actS;
 
@@ -146,7 +153,7 @@ static int installSigHandlers(Worker *my, int s0, int s1, void (*sigHandler) (in
                syslog(LOG_DEBUG, "%s:%d: %s", __FILE__, __LINE__, strerror(errno));
                my->oldSigAction1 = NULL;
        }
-       
+
        if (my->oldSigAction0 == NULL || my->oldSigAction1 == NULL) {
                removeSigHandlers(my);
                retVal = -1;
@@ -154,10 +161,11 @@ static int installSigHandlers(Worker *my, int s0, int s1, void (*sigHandler) (in
                retVal = 0;
        }
 
-       return retVal;  
+       return retVal;
 }
 
-Worker *Worker_initBegin(const char *name, void (*sigHandler) (int), int priority, int isStandalone)
+Worker *Worker_initBegin(const char *name, void (*sigHandler) (int),
+                                                int priority, int isStandalone)
 {
        Worker *retVal;
        Worker *my;
@@ -180,10 +188,16 @@ Worker *Worker_initBegin(const char *name, void (*sigHandler) (int), int priorit
                Worker_fini(my);
                retVal = NULL;
        } else {
+#ifndef WORKER_NEW_PROTOCOL
                unsigned long *pidP;
 
                pidP = Worker_addStatistic(my, "pid");
                *pidP = my->pid;
+#else
+               /* pid must always be first statistic */
+               Worker_addStatistic(my, "pid");
+               my->statistics[0].value = 0;
+#endif
 
                if (0 > changePriority(priority)) {
                        syslog(LOG_WARNING, "changeing priority: %s", strerror(errno));
@@ -197,12 +211,15 @@ Worker *Worker_initBegin(const char *name, void (*sigHandler) (int), int priorit
 
 void Worker_initEnd(Worker *my)
 {
+#ifndef WORKER_NEW_PROTOCOL
        if (!my->isStandalone) {
                if (0 > kill(getppid(), SIGUSR1)) {
-                       syslog(LOG_DEBUG,
-                                  "%s:%d: %s", __FILE__, __LINE__, strerror(errno));
+                       syslog(LOG_DEBUG, "%s:%d: %s", __FILE__, __LINE__, strerror(errno));
                }
        }
+#else
+       my->statistics[0].value = my->pid;
+#endif
 }
 
 void Worker_fini(Worker *my)
@@ -219,16 +236,18 @@ int Worker_start(const char *path, char *const argv[])
        Worker myS, *my = &myS;
 
        strcpy(my->name, argv[0]);
+#ifndef WORKER_NEW_PROTOCOL
 
        installSigHandlers(my, SIGCHLD, SIGUSR1, noopHandler);
 
+#endif
        my->pid = fork();
        if (0 > my->pid) {
                syslog(LOG_DEBUG, "%s:%d: %s", __FILE__, __LINE__, strerror(errno));
                retVal = -1;
        } else {
-               if (my->pid == 0) {     /* This is the child, we can not get out of */
-                                                       /* this block */
+               if (my->pid == 0) {             /* This is the child, we can not get out of */
+                       /* this block */
                        if (0 > execvp(path, argv)) {
                                syslog(LOG_DEBUG,
                                           "%s:%d: %s", __FILE__, __LINE__, strerror(errno));
@@ -236,6 +255,7 @@ int Worker_start(const char *path, char *const argv[])
                                abort();
                        }
                } else {
+#ifndef WORKER_NEW_PROTOCOL
                        sigset_t sigMaskS, *sigMask = &sigMaskS;
 
                        /* BUGBUG there should be a timeout here */
@@ -251,11 +271,34 @@ int Worker_start(const char *path, char *const argv[])
                        } else {
                                retVal = 0;
                        }
+#else
+                       /* wait until worker opens statShm and reports pid */
+                       const int timeout = 15;
+                       int workerIsStarted = 0;
+                       int i;
+
+                       for (i = 0; !workerIsStarted && i < timeout; i++) {
+                               if (0 == openStatShm(my)) {
+                                       if (my->pid == my->statistics[0].value) {
+                                               workerIsStarted = 1;
+                                       }
+                                       closeStatShm(my);
+                               }
+                               sleep(1);
+                       }
+                       if (i == timeout) {
+                               retVal = -1;
+                       } else {
+                               retVal = 0;
+                       }
+#endif
                }
        }
+#ifndef WORKER_NEW_PROTOCOL
 
        removeSigHandlers(my);
 
+#endif
        return retVal;
 }
 
@@ -274,12 +317,11 @@ char *Worker_status(const char *name)
                retVal = NULL;
        } else {
                strcpy(buf, "{}");
-               for (
-                               i = 0, p = buf;
-                               i < WORKER_MAX_NUM_STATS && strcmp(my->statistics[i].name, "") != 0;
-                               i++) {
-                       p += sprintf(p,
-                         "{ %s %lu } ", my->statistics[i].name, my->statistics[i].value);
+               for (i = 0, p = buf;
+                        i < WORKER_MAX_NUM_STATS
+                        && strcmp(my->statistics[i].name, "") != 0; i++) {
+                       p += sprintf(p, "{ %s %lu } ", my->statistics[i].name,
+                                                my->statistics[i].value);
                }
                closeStatShm(my);
                retVal = buf;
@@ -298,10 +340,11 @@ void Worker_stop(const char *name, int timeout)
                my->pid = my->statistics[0].value;
                if (my->pid > 0) {
                        if (0 == kill(my->pid, SIGTERM)) {
-                               sleep(1);
-                               wait(NULL);
+                               sleep(1);               /* LynxOS had problem without this */
+                               waitpid(my->pid, NULL, 0);
                        }
                }
+               closeStatShm(my);
        }
 }
 
@@ -310,10 +353,13 @@ unsigned long *Worker_addStatistic(Worker *my, const char *name)
        unsigned long *retVal;
        int i;
 
-       for (i = 0; i < WORKER_MAX_NUM_STATS && strcmp(my->statistics[i].name, "") != 0; i++) {
+       for (i = 0;
+                i < WORKER_MAX_NUM_STATS && strcmp(my->statistics[i].name, "") != 0;
+                i++) {
        }
        if (i == WORKER_MAX_NUM_STATS) {
-               syslog(LOG_ERR, "%s:%d: %s", __FILE__, __LINE__, "Too many statistic counters");
+               syslog(LOG_ERR, "%s:%d: %s", __FILE__, __LINE__,
+                          "Too many statistic counters");
                retVal = NULL;
        } else {
                strcpy(my->statistics[i].name, name);
@@ -339,7 +385,9 @@ void Worker_dump(Worker *my, time_t interval)
        }
 }
 
-int Worker_getStatistic(const char *name, const char *stat, unsigned long int *value) {
+int Worker_getStatistic(const char *name, const char *stat,
+                                               unsigned long int *value)
+{
        int retVal = -1;
        int i;
        Worker myS, *my = &myS;
@@ -348,7 +396,9 @@ int Worker_getStatistic(const char *name, const char *stat, unsigned long int *v
        if (-1 == openStatShm(my)) {
                *value = 0;
        } else {
-               for (i = 0; i < WORKER_MAX_NUM_STATS && strcmp(my->statistics[i].name, "") != 0; i++) {
+               for (i = 0;
+                        i < WORKER_MAX_NUM_STATS
+                        && strcmp(my->statistics[i].name, "") != 0; i++) {
                        if (strcmp(stat, my->statistics[i].name) == 0) {
                                *value = my->statistics[i].value;
                                retVal = 0;
@@ -359,4 +409,3 @@ int Worker_getStatistic(const char *name, const char *stat, unsigned long int *v
        }
        return retVal;
 }
-