[launchd-changes] [23251] trunk/launchd/src/launchd_core_logic.c

source_changes at macosforge.org source_changes at macosforge.org
Thu May 10 14:36:14 PDT 2007


Revision: 23251
          http://trac.macosforge.org/projects/launchd/changeset/23251
Author:   zarzycki at apple.com
Date:     2007-05-10 14:36:14 -0700 (Thu, 10 May 2007)

Log Message:
-----------
socketgroup_watch() and socketgroup_ignore() are basically the same, with slightly different args.

Modified Paths:
--------------
    trunk/launchd/src/launchd_core_logic.c

Modified: trunk/launchd/src/launchd_core_logic.c
===================================================================
--- trunk/launchd/src/launchd_core_logic.c	2007-05-10 21:23:35 UTC (rev 23250)
+++ trunk/launchd/src/launchd_core_logic.c	2007-05-10 21:36:14 UTC (rev 23251)
@@ -3045,29 +3045,9 @@
 	free(sg);
 }
 
-void
-socketgroup_ignore(job_t j, struct socketgroup *sg)
+static void
+socketgroup_kevent_mod(job_t j, struct socketgroup *sg, bool do_add)
 {
-	char buf[10000];
-	unsigned int i, buf_off = 0;
-
-	if (sg->junkfds) {
-		return;
-	}
-
-	for (i = 0; i < sg->fd_cnt; i++)
-		buf_off += snprintf(buf + buf_off, sizeof(buf) - buf_off, " %d", sg->fds[i]);
-
-	job_log(j, LOG_DEBUG, "Ignoring Sockets:%s", buf);
-
-	for (i = 0; i < sg->fd_cnt; i++) {
-		job_assumes(j, kevent_mod(sg->fds[i], EVFILT_READ, EV_DELETE, 0, 0, NULL) != -1);
-	}
-}
-
-void
-socketgroup_watch(job_t j, struct socketgroup *sg)
-{
 	struct kevent kev[sg->fd_cnt];
 	char buf[10000];
 	unsigned int i, buf_off = 0;
@@ -3076,15 +3056,13 @@
 		return;
 	}
 
-	for (i = 0; i < sg->fd_cnt; i++)
-		buf_off += snprintf(buf + buf_off, sizeof(buf) - buf_off, " %d", sg->fds[i]);
-
-	job_log(j, LOG_DEBUG, "Watching sockets:%s", buf);
-
 	for (i = 0; i < sg->fd_cnt; i++) {
-		EV_SET(&kev[i], sg->fds[i], EVFILT_READ, EV_ADD, 0, 0, j);
+		EV_SET(&kev[i], sg->fds[i], EVFILT_READ, do_add ? EV_ADD : EV_DELETE, 0, 0, j);
+		buf_off += snprintf(buf + buf_off, sizeof(buf) - buf_off, " %d", sg->fds[i]);
 	}
 
+	job_log(j, LOG_DEBUG, "%s Sockets:%s", do_add ? "Watching" : "Ignoring", buf);
+
 	job_assumes(j, kevent_bulk_mod(kev, sg->fd_cnt) != -1);
 
 	for (i = 0; i < sg->fd_cnt; i++) {
@@ -3095,6 +3073,18 @@
 }
 
 void
+socketgroup_ignore(job_t j, struct socketgroup *sg)
+{
+	socketgroup_kevent_mod(j, sg, false);
+}
+
+void
+socketgroup_watch(job_t j, struct socketgroup *sg)
+{
+	socketgroup_kevent_mod(j, sg, true);
+}
+
+void
 socketgroup_callback(job_t j)
 {
 	job_dispatch(j, true);

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070510/5ba0b7c9/attachment.html


More information about the launchd-changes mailing list