Revision
23578
Author
zarzycki@apple.com
Date
2008-03-27 15:48:06 -0700 (Thu, 27 Mar 2008)

Log Message

Last minute changes.

Modified Paths

Diff

Modified: trunk/launchd/src/libvproc.c (23577 => 23578)


--- trunk/launchd/src/libvproc.c	2008-03-27 21:57:51 UTC (rev 23577)
+++ trunk/launchd/src/libvproc.c	2008-03-27 22:48:06 UTC (rev 23578)
@@ -92,7 +92,7 @@
 void
 _basic_vproc_transaction_begin(void)
 {
-	int64_t newval;
+	typeof(vproc_shmem->vp_shmem_transaction_cnt) newval;
 
 	if (unlikely(vproc_shmem == NULL)) {
 		int po_r = pthread_once(&shmem_inited, vproc_shmem_init);
@@ -114,7 +114,31 @@
 	}
 }
 
+size_t
+_basic_vproc_transaction_count(void)
+{
+	return likely(vproc_shmem) ? vproc_shmem->vp_shmem_transaction_cnt : INT32_MAX;
+}
+
 void
+_basic_vproc_transaction_try_exit(int status)
+{
+	typeof(vproc_shmem->vp_shmem_transaction_cnt) newval;
+
+	if (unlikely(vproc_shmem == NULL)) {
+		return;
+	}
+
+	vproc_shmem->vp_shmem_flags |= VPROC_SHMEM_EXITING;
+
+	newval = __sync_sub_and_fetch(&vproc_shmem->vp_shmem_transaction_cnt, 1);
+
+	if (newval < 0) {
+		_exit(status);
+	}
+}
+
+void
 vproc_transaction_end(vproc_t vp __attribute__((unused)), vproc_transaction_t vpt)
 {
 	if (unlikely(vpt != (vproc_transaction_t)vproc_shmem_init)) {
@@ -128,8 +152,10 @@
 void
 _basic_vproc_transaction_end(void)
 {
-	int32_t newval = __sync_sub_and_fetch(&vproc_shmem->vp_shmem_transaction_cnt, 1);
+	typeof(vproc_shmem->vp_shmem_transaction_cnt) newval;
 
+	newval = __sync_sub_and_fetch(&vproc_shmem->vp_shmem_transaction_cnt, 1);
+
 	if (unlikely(newval < 0)) {
 		if (vproc_shmem->vp_shmem_flags & VPROC_SHMEM_EXITING) {
 			raise(SIGKILL);
@@ -145,7 +171,7 @@
 vproc_standby_begin(vproc_t vp __attribute__((unused)))
 {
 	vproc_standby_t vpsb = (vproc_standby_t)vproc_shmem_init; /* we need a "random" variable that is testable */
-	int64_t newval;
+	typeof(vproc_shmem->vp_shmem_standby_cnt) newval;
 
 	if (unlikely(vproc_shmem == NULL)) {
 		int po_r = pthread_once(&shmem_inited, vproc_shmem_init);
@@ -167,7 +193,7 @@
 void
 vproc_standby_end(vproc_t vp __attribute__((unused)), vproc_standby_t vpt)
 {
-	int32_t newval;
+	typeof(vproc_shmem->vp_shmem_standby_cnt) newval;
 
 	if (unlikely(vpt != (vproc_standby_t)vproc_shmem_init)) {
 		__crashreporter_info__ = "Bogus standby handle passed to vproc_standby_end() ";

Modified: trunk/launchd/src/libvproc_private.h (23577 => 23578)


--- trunk/launchd/src/libvproc_private.h	2008-03-27 21:57:51 UTC (rev 23577)
+++ trunk/launchd/src/libvproc_private.h	2008-03-27 22:48:06 UTC (rev 23578)
@@ -78,7 +78,10 @@
 
 void _basic_vproc_transaction_begin(void);
 void _basic_vproc_transaction_end(void);
+size_t _basic_vproc_transaction_count(void);
+void _basic_vproc_transaction_try_exit(int status);
 
+
 #pragma GCC visibility pop
 
 __END_DECLS