[launchd-changes] [23190] trunk/launchd/src

source_changes at macosforge.org source_changes at macosforge.org
Thu Mar 29 14:38:00 PDT 2007


Revision: 23190
          http://trac.macosforge.org/projects/launchd/changeset/23190
Author:   zarzycki at apple.com
Date:     2007-03-29 14:38:00 -0700 (Thu, 29 Mar 2007)

Log Message:
-----------
Avoid floating point.

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

Modified: trunk/launchd/src/launchd_core_logic.c
===================================================================
--- trunk/launchd/src/launchd_core_logic.c	2007-03-29 01:29:52 UTC (rev 23189)
+++ trunk/launchd/src/launchd_core_logic.c	2007-03-29 21:38:00 UTC (rev 23190)
@@ -1753,13 +1753,10 @@
 	}
 
 	if (j->sent_sigterm_time.tv_sec) {
-		double delta;
-
 		timersub(&tve, &j->sent_sigterm_time,  &tvd);
 
-		delta = (double)tvd.tv_sec + (double)tvd.tv_usec / (double)1000000;
-
-		job_log(j, LOG_INFO, "Exited %f seconds after SIGTERM was sent", delta);
+		job_log(j, LOG_INFO, "Exited %ld.%06d seconds after %s was sent",
+				tvd.tv_sec, tvd.tv_usec, signal_to_C_name(j->sent_sigkill ? SIGKILL : SIGTERM));
 	}
 
 #if DO_RUSAGE_SUMMATION

Modified: trunk/launchd/src/launchd_runtime.c
===================================================================
--- trunk/launchd/src/launchd_runtime.c	2007-03-29 01:29:52 UTC (rev 23189)
+++ trunk/launchd/src/launchd_runtime.c	2007-03-29 21:38:00 UTC (rev 23190)
@@ -1001,13 +1001,13 @@
 runtime_vsyslog(int priority, const char *message, va_list args)
 {
 	static pthread_mutex_t ourlock = PTHREAD_MUTEX_INITIALIZER;
-	static struct timeval shutdown_start = { 0, 0 };
+	static struct timeval shutdown_start;
+	static struct timeval prev_msg;
 	static int apple_internal_logging = 1;
-	struct timeval tvnow, tvd;
+	struct timeval tvnow, tvd_total, tvd_msg_delta;
 	struct stat sb;
 	int saved_errno = errno;
 	char newmsg[10000];
-	double float_time;
 	size_t i, j;
 
 	if (apple_internal_logging == 1) {
@@ -1052,11 +1052,15 @@
 		return;
 	}
 
-	timersub(&tvnow, &shutdown_start, &tvd);
+	timersub(&tvnow, &shutdown_start, &tvd_total);
+	timersub(&tvnow, &prev_msg, &tvd_msg_delta);
 
-	float_time = (double)tvd.tv_sec + (double)tvd.tv_usec / (double)1000000;
-	snprintf(newmsg, sizeof(newmsg), "%f\t", float_time);
+	prev_msg = tvnow;
 
+	snprintf(newmsg, sizeof(newmsg), "%3ld.%06d\t%ld.%06d\t",
+			tvd_total.tv_sec, tvd_total.tv_usec,
+			tvd_msg_delta.tv_sec, tvd_msg_delta.tv_usec);
+
 	for (i = 0, j = strlen(newmsg); message[i];) {
 		if (message[i] == '%' && message[i + 1] == 'm') {
 			char *errs = strerror(saved_errno);

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


More information about the launchd-changes mailing list