-static char *rcsId = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/agent.c,v 6.9 2002-10-28 07:41:18 hadaq Exp $";
+static char *rcsId = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/agent.c,v 6.10 2002-11-09 10:03:18 hadaq Exp $";
#define _GNU_SOURCE
#include <unistd.h>
return rpcworker_stop_1(dummy, NULL);
}
-int *rpcsystem_1(char **command, CLIENT * cl)
+void *rpcsystem_1(char **command, CLIENT * cl)
{
static int retVal;
return &retVal;
}
-int * rpcsystem_1_svc(char **dummy, struct svc_req *x)
+void * rpcsystem_1_svc(char **dummy, struct svc_req *x)
{
return rpcsystem_1(dummy, NULL);
}
+
+int *rpcjoin_1(int *dummy, CLIENT * cl)
+{
+ static int retVal;
+
+ retVal = 0;
+
+ return &retVal;
+}
+
+int * rpcjoin_1_svc(int *dummy, struct svc_req *x)
+{
+ return rpcjoin_1(dummy, NULL);
+}
-static char *rcsId = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/tcldaq.c,v 6.8 2002-11-08 15:16:03 hadaq Exp $";
+static char *rcsId = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/tcldaq.c,v 6.9 2002-11-09 10:03:18 hadaq Exp $";
#define _GNU_SOURCE
#include <unistd.h>
#include "worker.h"
#include "agent.h"
+#define MAX_NTHR 16
+static nThr = 0;
+static char agents[MAX_NTHR][512];
+
+typedef struct ThrArgsS {
+ int id;
+ char *agent;
+ char *command;
+} ThrArgs;
+
int AgentCmd(ClientData clientData, Tcl_Interp * interp, int argc, char *argv[])
{
CLIENT *cl;
int SystemCmd(ClientData clientData, Tcl_Interp * interp, int argc, char *argv[])
{
+ int SystemCmdR = 0;
CLIENT *cl;
- int res, *resP;
if (argc < 3) {
Tcl_AppendResult(interp, "usage: c_system <agent> command", NULL);
return TCL_ERROR;
}
- sscanf(argv[1], "%p", &cl);
- if (NULL == (resP = rpcsystem_1(&argv[2], cl))) {
- Tcl_AppendResult(interp, clnt_sperror(cl, "rpcsystem_1"), NULL);
- return TCL_ERROR;
+ strcpy(agents[nThr++], argv[1]);
+ if (NULL == (cl = clnt_create(argv[1], DAQAGENTPROG, DAQAGENTVERS, "tcp"))) {
+ clnt_pcreateerror("clnt_create");
+ SystemCmdR = -1;
+ } else {
+ static struct timeval TIMEOUT = { 0, 0 };
+ clnt_control(cl, CLSET_TIMEOUT, (char *)&TIMEOUT);
+ if (NULL == rpcsystem_1(&argv[2], cl)) {
+ clnt_perror(cl, "rpcsystem_1");
+ SystemCmdR = 0;
+ } else {
+ SystemCmdR = 0;
+ }
+ clnt_destroy(cl);
}
- res = *resP;
- sprintf(interp->result, "%d", res);
+ sprintf(interp->result, "%d", SystemCmdR);
- return TCL_OK;
+ return SystemCmdR == 0 ? TCL_OK : TCL_ERROR;
+}
+
+int JoinAllCmd(ClientData clientData, Tcl_Interp * interp, int argc, char *argv[])
+{
+ int JoinAllCmdR;
+ CLIENT *cl;
+ int res;
+
+ JoinAllCmdR = 0;
+ while (nThr > 0) {
+ --nThr;
+ if (NULL == (cl = clnt_create(agents[nThr], DAQAGENTPROG, DAQAGENTVERS, "tcp"))) {
+ clnt_pcreateerror("clnt_create");
+ JoinAllCmdR = -1;
+ } else {
+ static struct timeval TIMEOUT = { 120, 0 };
+ clnt_control(cl, CLSET_TIMEOUT, (char *)&TIMEOUT);
+ if (NULL == rpcjoin_1(&res, cl)) {
+ clnt_perror(cl, "rpcjoin_1");
+ JoinAllCmdR = -1;
+ } else {
+ JoinAllCmdR = 0;
+ }
+ clnt_destroy(cl);
+ }
+ }
+ sprintf(interp->result, "%d", JoinAllCmdR);
+
+ return JoinAllCmdR == 0 ? TCL_OK : TCL_ERROR;
}
int Daq_Init(Tcl_Interp * interp)
Tcl_CreateCommand(interp, "c_worker", WorkerCmd, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
Tcl_CreateCommand(interp, "c_agent", AgentCmd, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
Tcl_CreateCommand(interp, "c_system", SystemCmd, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
+ Tcl_CreateCommand(interp, "c_joinall", JoinAllCmd, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
/*
* Specify a user-specific startup file to invoke if the application