[launchd-changes] [23556] trunk/launchd/src/liblaunch.c
source_changes at macosforge.org
source_changes at macosforge.org
Tue Mar 18 10:46:23 PDT 2008
Revision: 23556
http://trac.macosforge.org/projects/launchd/changeset/23556
Author: zarzycki at apple.com
Date: 2008-03-18 10:46:21 -0700 (Tue, 18 Mar 2008)
Log Message:
-----------
<rdar://problem/5795236> Unix callbacks can delete the underlying connection
Modified Paths:
--------------
trunk/launchd/src/liblaunch.c
Modified: trunk/launchd/src/liblaunch.c
===================================================================
--- trunk/launchd/src/liblaunch.c 2008-03-17 17:36:16 UTC (rev 23555)
+++ trunk/launchd/src/liblaunch.c 2008-03-18 17:46:21 UTC (rev 23556)
@@ -166,6 +166,7 @@
static launch_data_t launch_msg_internal(launch_data_t d);
static void launch_mach_checkin_service(launch_data_t obj, const char *key, void *context);
+static launch_t in_flight_msg_recv_client;
static pthread_once_t _lc_once = PTHREAD_ONCE_INIT;
static struct _launch_client {
@@ -581,6 +582,10 @@
void
launchd_close(launch_t lh, typeof(close) closefunc)
{
+ if (in_flight_msg_recv_client == lh) {
+ in_flight_msg_recv_client = NULL;
+ }
+
if (lh->sendbuf)
free(lh->sendbuf);
if (lh->sendfds)
@@ -1030,8 +1035,16 @@
goto out_bad;
}
+ in_flight_msg_recv_client = lh;
+
cb(rmsg, context);
+ /* launchd and only launchd can call launchd_close() as a part of the callback */
+ if (in_flight_msg_recv_client == NULL) {
+ r = 0;
+ break;
+ }
+
lh->recvlen -= data_offset;
if (lh->recvlen > 0) {
memmove(lh->recvbuf, lh->recvbuf + data_offset, lh->recvlen);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20080318/15e23471/attachment-0001.html
More information about the launchd-changes
mailing list