Bug 17898 - Patch to new version of healthd
Summary: Patch to new version of healthd
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-ports (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2000-04-10 13:00 UTC by James E. Housley
Modified: 2000-04-14 23:13 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description James E. Housley 2000-04-10 13:00:00 UTC

Fix: 

--- healthd.c	2000/04/09 20:59:07	1.1.1.6
+++ healthd.c	2000/04/10 11:52:57	1.1.1.7
@@ -30,7 +30,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $Id: healthd.c,v 1.1.1.6 2000/04/09 20:59:07 housley Exp $
+ * $Id: healthd.c,v 1.1.1.7 2000/04/10 11:52:57 housley Exp $
  *
  * $FreeBSD$
  */
@@ -604,8 +604,10 @@
 
     case 'c':
       count = atoi(optarg);
-      if (count < 1)
+      if (count < 1) {
          count = 0;
+      }
+      debug=1;
       break;
 
     case 'd':
@@ -668,68 +670,79 @@
     }
   }
 
-  /* Create socket from which to read. */
-  sock = socket(AF_INET, SOCK_STREAM, 0);
-  if (sock < 0) {
-    perror("opening datagram socket");
-    exit(1);
-  }
-  /* Create name with wildcards. */
-  server.sin_family = AF_INET;
-  server.sin_addr.s_addr = INADDR_ANY;
-  server.sin_port = htons(9669);
-  if (bind(sock, (struct sockaddr *)&server, sizeof(struct sockaddr_in))) {
-    perror("binding datagram socket");
-    exit(1);
-  }
-  /* Find assigned port value and print it out. */
-  length = sizeof(server);
-  if (getsockname(sock, (struct sockaddr *)&server, &length)) {
-    perror("getting socket name");
-    exit(1);
+  if (debug == 0) {
+    /* Create socket from which to read. */
+    sock = socket(AF_INET, SOCK_STREAM, 0);
+    if (sock < 0) {
+      perror("opening datagram socket");
+      exit(1);
+    }
+    /* Create name with wildcards. */
+    server.sin_family = AF_INET;
+    server.sin_addr.s_addr = INADDR_ANY;
+    server.sin_port = htons(9669);
+    if (bind(sock, (struct sockaddr *)&server, sizeof(struct sockaddr_in))) {
+      perror("binding datagram socket");
+      exit(1);
+    }
+    /* Find assigned port value and print it out. */
+    length = sizeof(server);
+    if (getsockname(sock, (struct sockaddr *)&server, &length)) {
+      perror("getting socket name");
+      exit(1);
+    }
   }
   ReadCurrentValues();
   time(&now);
   time(&tloc);
-  /* Start accepting connections */
-  listen(sock, 5);
+  if (debug == 0) {
+    /* Start accepting connections */
+    listen(sock, 5);
+  }
   while ((iter<count) || (count==0)) {
     FD_ZERO(&ready);
-    FD_SET(sock, &ready);
+    if (debug == 1) {
+      FD_SET(fileno(stdin), &ready);
+    } else {
+      FD_SET(sock, &ready);
+    }
     to.tv_sec = 0;
     to.tv_usec = 100;
     if (select(50, &ready, 0, 0, &to) < 0) {
       continue;
     }
-    if (FD_ISSET(sock, &ready)) {
-      msgsock = accept(sock, 0, 0);
-      if (msgsock == -1) {
-      } else {
-	do {
-	  bzero(buf, sizeof(buf));
-	  bzero(outbuf, sizeof(outbuf));
-	  if ((rval = read(msgsock, buf, 1024)) < 0) {
-	  }
-	  if (rval == 0) {
-	  } else {
-	    GetAnswer(buf, outbuf);
-	    write(msgsock, outbuf, strlen(outbuf));
-	  }
-	} while (rval != 0);
-	close(msgsock);
-      }
-    } else {
-      time(&tloc);
-      if (sec <= (int)difftime(tloc, now)) {
-	if (count > 0) {
-	  iter++;
+    if (debug == 0) {
+      if (FD_ISSET(sock, &ready)) {
+	msgsock = accept(sock, 0, 0);
+	if (msgsock == -1) {
+	} else {
+	  do {
+	    bzero(buf, sizeof(buf));
+	    bzero(outbuf, sizeof(outbuf));
+	    if ((rval = read(msgsock, buf, 1024)) < 0) {
+	    }
+	    if (rval == 0) {
+	    } else {
+	      GetAnswer(buf, outbuf);
+	      write(msgsock, outbuf, strlen(outbuf));
+	    }
+	  } while (rval != 0);
+	  close(msgsock);
 	}
-	ReadCurrentValues();
-	time(&now);
       }
     }
+    time(&tloc);
+    if (sec <= (int)difftime(tloc, now)) {
+      if (count > 0) {
+	iter++;
+      }
+      ReadCurrentValues();
+      time(&now);
+    }
+  }
+  if (debug == 0) {
+    close(sock);
   }
-  close(sock);
 }
 
 void
Comment 1 James Housley 2000-04-10 13:09:08 UTC
My mistake.  This should be in ports.

Jim
-- 
"Eagles may soar, but weasels don't get sucked into jet engines"
        -- Anon
Comment 2 John Baldwin freebsd_committer freebsd_triage 2000-04-10 16:48:33 UTC
Responsible Changed
From-To: freebsd-sparc->freebsd-ports

Misfiled PR. 

Comment 3 James Housley 2000-04-14 22:50:41 UTC
Please close this pr it is superceeded by ports/18015

-- 
Unix is like a wigwam -- no Gates, no Windows, and an Apache inside.
Comment 4 Akinori MUSHA freebsd_committer freebsd_triage 2000-04-14 23:10:27 UTC
State Changed
From-To: open->closed

At the originator's request.  Superceded by ports/18015.