From d62999ebf69243b6717ae8b2f7485804dbe5b3d3 Mon Sep 17 00:00:00 2001
From: hadaq <hadaq>
Date: Mon, 16 Aug 2004 15:02:12 +0000
Subject: [PATCH] Only operate on existing workers, somewhat sloppyly tested

---
 hadaq/agent.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/hadaq/agent.c b/hadaq/agent.c
index 67a1fa0..62311aa 100644
--- a/hadaq/agent.c
+++ b/hadaq/agent.c
@@ -1,4 +1,4 @@
-static char *rcsId = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/agent.c,v 6.14 2003-08-27 13:09:03 hadaq Exp $";
+static char *rcsId = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/agent.c,v 6.15 2004-08-16 15:02:12 hadaq Exp $";
 
 #define _GNU_SOURCE
 #include <unistd.h>
@@ -71,11 +71,17 @@ int *rpcworker_start_1_svc(RpcWorker_startArgs * dummy, struct svc_req *x)
 char **rpcworker_status_1(int *id, CLIENT * cl)
 {
 	static char *retVal;
+	char *worker;
 
 	openlog("daq_agent", LOG_PID | LOG_PERROR, LOG_LOCAL0);
 	setlogmask(LOG_UPTO(LOG_INFO));
 
-	retVal = Worker_status(getWorker(*id));
+	worker = getWorker(*id);
+	if (*worker != '\0') {
+		retVal = Worker_status(worker);
+	} else {
+		retVal = "{}";
+	}
 
 	closelog();
 
@@ -90,11 +96,15 @@ char **rpcworker_status_1_svc(int *dummy, struct svc_req *x)
 int *rpcworker_stop_1(int *id, CLIENT * cl)
 {
 	static int retVal;
+	char *worker;
 
 	openlog("daq_agent", LOG_PID | LOG_PERROR, LOG_LOCAL0);
 	setlogmask(LOG_UPTO(LOG_INFO));
 
-	Worker_stop(getWorker(*id), 15);
+	worker = getWorker(*id);
+	if (*worker != '\0') {
+		Worker_stop(worker, 15);
+	}
 
 	closelog();
 
-- 
2.43.0