<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
- <string>1.13</string>
+ <string>1.13.1</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
- <string>1.13</string>
+ <string>1.13.1</string>
<key>Requires</key>
<array>
<string>com.apple.SystemConfiguration.IPConfiguration</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
- <string>1.13</string>
+ <string>1.13.1</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
- <string>1.13</string>
+ <string>1.13.1</string>
</dict>
</plist>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
- <string>1.13</string>
+ <string>1.13.1</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
- <string>1.13</string>
+ <string>1.13.1</string>
<key>Requires</key>
<array>
<string>com.apple.SystemConfiguration.InterfaceNamer</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
- <string>1.13</string>
+ <string>1.13.1</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
- <string>1.13</string>
+ <string>1.13.1</string>
<key>Requires</key>
<array>
<string>com.apple.SystemConfiguration.InterfaceNamer</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
- <string>1.13</string>
+ <string>1.13.1</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
- <string>1.13</string>
+ <string>1.13.1</string>
<key>Enabled</key>
<false/>
<key>Verbose</key>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
- <string>1.13</string>
+ <string>1.13.1</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
- <string>1.13</string>
+ <string>1.13.1</string>
<key>Enabled</key>
<false/>
<key>Verbose</key>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
- <string>1.13</string>
+ <string>1.13.1</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
- <string>1.13</string>
+ <string>1.13.1</string>
<key>Builtin</key>
<true/>
<key>Requires</key>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
- <string>1.13</string>
+ <string>1.13.1</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
- <string>1.13</string>
+ <string>1.13.1</string>
</dict>
</plist>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
- <string>1.13</string>
+ <string>1.13.1</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
- <string>1.13</string>
+ <string>1.13.1</string>
</dict>
</plist>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
- <string>1.13</string>
+ <string>1.13.1</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
- <string>1.13</string>
+ <string>1.13.1</string>
<key>CFPlugInDynamicRegistration</key>
<string>NO</string>
<key>CFPlugInFactories</key>
<key>CFBundleExecutable</key>
<string>SystemConfiguration</string>
<key>CFBundleGetInfoString</key>
- <string>1.13</string>
+ <string>1.13.1</string>
<key>CFBundleIdentifier</key>
<string>com.apple.SystemConfiguration</string>
<key>CFBundleInfoDictionaryVersion</key>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
- <string>1.13</string>
+ <string>1.13.1</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
- <string>1.13</string>
+ <string>1.13.1</string>
</dict>
</plist>
<key>CFBundleExecutable</key>
<string>SystemConfiguration</string>
<key>CFBundleGetInfoString</key>
- <string>1.13</string>
+ <string>1.13.1</string>
<key>CFBundleIdentifier</key>
<string>com.apple.SystemConfiguration</string>
<key>CFBundleInfoDictionaryVersion</key>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
- <string>1.13</string>
+ <string>1.13.1</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
- <string>1.13</string>
+ <string>1.13.1</string>
</dict>
</plist>
#include "SCDynamicStoreInternal.h"
#include "config.h" /* MiG generated file */
+#if !TARGET_IPHONE_SIMULATOR || (defined(IPHONE_SIMULATOR_HOST_MIN_VERSION_REQUIRED) && (IPHONE_SIMULATOR_HOST_MIN_VERSION_REQUIRED >= 1090))
+#define HAVE_MACHPORT_GUARDS
+#endif
+
static CFStringRef
notifyMPCopyDescription(const void *info)
, CFRelease
, notifyMPCopyDescription
};
+ kern_return_t kr;
mach_port_t oldNotify;
+#ifdef HAVE_MACHPORT_GUARDS
+ mach_port_options_t opts;
+#endif // HAVE_MACHPORT_GUARDS
mach_port_t port;
int sc_status;
- kern_return_t status;
#ifdef DEBUG
SCLog(_sc_verbose, LOG_DEBUG, CFSTR(" activate callback runloop source"));
#endif /* DEBUG */
- /* Allocating port (for server response) */
- status = mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE, &port);
- if (status != KERN_SUCCESS) {
- SCLog(TRUE, LOG_ERR, CFSTR("rlsSchedule mach_port_allocate(): %s"), mach_error_string(status));
- return;
+ /* allocate a mach port for the SCDynamicStore notifications */
+
+ retry_allocate :
+
+#ifdef HAVE_MACHPORT_GUARDS
+ bzero(&opts, sizeof(opts));
+ opts.flags = MPO_CONTEXT_AS_GUARD|MPO_INSERT_SEND_RIGHT;
+
+ kr = mach_port_construct(mach_task_self(), &opts, store, &port);
+#else // HAVE_MACHPORT_GUARDS
+ kr = mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE, &port);
+#endif // HAVE_MACHPORT_GUARDS
+
+ if (kr != KERN_SUCCESS) {
+ SCLog(TRUE, LOG_ERR, CFSTR("rlsSchedule could not allocate mach port: %s"), mach_error_string(kr));
+ if ((kr == KERN_NO_SPACE) || (kr == KERN_RESOURCE_SHORTAGE)) {
+ sleep(1);
+ goto retry_allocate;
+ } else {
+ return;
+ }
}
- status = mach_port_insert_right(mach_task_self(),
- port,
- port,
- MACH_MSG_TYPE_MAKE_SEND);
- if (status != KERN_SUCCESS) {
+#ifndef HAVE_MACHPORT_GUARDS
+ kr = mach_port_insert_right(mach_task_self(),
+ port,
+ port,
+ MACH_MSG_TYPE_MAKE_SEND);
+ if (kr != KERN_SUCCESS) {
/*
* We can't insert a send right into our own port! This should
* only happen if someone stomped on OUR port (so let's leave
* the port alone).
*/
- SCLog(TRUE, LOG_ERR, CFSTR("rlsSchedule mach_port_insert_right(): %s"), mach_error_string(status));
+ SCLog(TRUE, LOG_ERR, CFSTR("rlsSchedule mach_port_insert_right(): %s"), mach_error_string(kr));
return;
}
+#endif // HAVE_MACHPORT_GUARDS
/* Request a notification when/if the server dies */
- status = mach_port_request_notification(mach_task_self(),
- port,
- MACH_NOTIFY_NO_SENDERS,
- 1,
- port,
- MACH_MSG_TYPE_MAKE_SEND_ONCE,
- &oldNotify);
- if (status != KERN_SUCCESS) {
+ kr = mach_port_request_notification(mach_task_self(),
+ port,
+ MACH_NOTIFY_NO_SENDERS,
+ 1,
+ port,
+ MACH_MSG_TYPE_MAKE_SEND_ONCE,
+ &oldNotify);
+ if (kr != KERN_SUCCESS) {
/*
* We can't request a notification for our own port! This should
* only happen if someone stomped on OUR port (so let's leave
* the port alone).
*/
- SCLog(TRUE, LOG_ERR, CFSTR("rlsSchedule mach_port_request_notification(): %s"), mach_error_string(status));
+ SCLog(TRUE, LOG_ERR, CFSTR("rlsSchedule mach_port_request_notification(): %s"), mach_error_string(kr));
return;
}
retry :
__MACH_PORT_DEBUG(TRUE, "*** rlsSchedule", port);
- status = notifyviaport(storePrivate->server, port, 0, (int *)&sc_status);
+ kr = notifyviaport(storePrivate->server, port, 0, (int *)&sc_status);
if (__SCDynamicStoreCheckRetryAndHandleError(store,
- status,
+ kr,
&sc_status,
"rlsSchedule notifyviaport()")) {
goto retry;
}
- if (status != KERN_SUCCESS) {
- if ((status == MACH_SEND_INVALID_DEST) || (status == MIG_SERVER_DIED)) {
+ if (kr != KERN_SUCCESS) {
+ if ((kr == MACH_SEND_INVALID_DEST) || (kr == MIG_SERVER_DIED)) {
/* remove the send right that we tried (but failed) to pass to the server */
(void) mach_port_deallocate(mach_task_self(), port);
}
/* remove our receive right */
+#ifdef HAVE_MACHPORT_GUARDS
+ (void) mach_port_destruct(mach_task_self(), port, 0, store);
+#else // HAVE_MACHPORT_GUARDS
(void) mach_port_mod_refs(mach_task_self(), port, MACH_PORT_RIGHT_RECEIVE, -1);
+#endif // HAVE_MACHPORT_GUARDS
return;
}
if (sc_status != kSCStatusOK) {
/* something [else] didn't work, remove our receive right */
+#ifdef HAVE_MACHPORT_GUARDS
+ (void) mach_port_destruct(mach_task_self(), port, 0, store);
+#else // HAVE_MACHPORT_GUARDS
(void) mach_port_mod_refs(mach_task_self(), port, MACH_PORT_RIGHT_RECEIVE, -1);
+#endif // HAVE_MACHPORT_GUARDS
return;
}
if (n == 0) {
int sc_status;
- kern_return_t status;
+ kern_return_t kr;
#ifdef DEBUG
SCLog(_sc_verbose, LOG_DEBUG, CFSTR(" cancel callback runloop source"));
storePrivate->rlsNotifyPort = NULL;
/* and, finally, remove our receive right */
- (void)mach_port_mod_refs(mach_task_self(), mp, MACH_PORT_RIGHT_RECEIVE, -1);
+#ifdef HAVE_MACHPORT_GUARDS
+ (void) mach_port_destruct(mach_task_self(), mp, 0, store);
+#else // HAVE_MACHPORT_GUARDS
+ (void) mach_port_mod_refs(mach_task_self(), mp, MACH_PORT_RIGHT_RECEIVE, -1);
+#endif // HAVE_MACHPORT_GUARDS
}
if (storePrivate->server != MACH_PORT_NULL) {
- status = notifycancel(storePrivate->server, (int *)&sc_status);
+ kr = notifycancel(storePrivate->server, (int *)&sc_status);
(void) __SCDynamicStoreCheckRetryAndHandleError(store,
- status,
+ kr,
&sc_status,
"rlsCancel notifycancel()");
- if (status != KERN_SUCCESS) {
+ if (kr != KERN_SUCCESS) {
return;
}
}
/*
- * Copyright (c) 2000-2006, 2008-2013 Apple Inc. All rights reserved.
+ * Copyright (c) 2000-2006, 2008-2014 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
(void) SCDynamicStoreNotifyCancel(store);
if (storePrivate->server != MACH_PORT_NULL) {
- if (!storePrivate->serverNullSession) {
- /*
- * Remove our send right to the SCDynamicStore server (and that will
- * result in our session being closed).
- */
- __MACH_PORT_DEBUG(TRUE, "*** __SCDynamicStoreDeallocate", storePrivate->server);
- (void) mach_port_deallocate(mach_task_self(), storePrivate->server);
- }
-
+ /*
+ * Remove our send right to the SCDynamicStore server.
+ *
+ * In the case of a "real" session this will result in our
+ * session being closed.
+ *
+ * In the case of a "NULL" session, we just remove the
+ * the send right reference we are holding.
+ */
+ __MACH_PORT_DEBUG(TRUE, "*** __SCDynamicStoreDeallocate", storePrivate->server);
+ (void) mach_port_deallocate(mach_task_self(), storePrivate->server);
storePrivate->server = MACH_PORT_NULL;
}
pthread_mutex_lock(&_sc_lock);
if (_sc_server != MACH_PORT_NULL) {
if (*server == _sc_server) {
- // if the server we tried returned the error, deallocate
- // our send [or dead name] right
- (void)mach_port_deallocate(mach_task_self(), _sc_server);
+ mach_port_t old_port;
- // and [re-]lookup the name to the server
+ // if the server we tried returned the error, save the old port,
+ // [re-]lookup the name to the server, and deallocate the original
+ // send [or dead name] right
+
+ old_port = _sc_server;
_sc_server = __SCDynamicStoreServerPort(storePrivate, sc_status_p);
+ (void)mach_port_deallocate(mach_task_self(), old_port);
} else {
- // another thread has refreshed the SCDynamicStore server port
+ // another thread has refreshed the [main] SCDynamicStore server port
}
} else {
_sc_server = __SCDynamicStoreServerPort(storePrivate, sc_status_p);
static Boolean
__SCDynamicStoreAddSession(SCDynamicStorePrivateRef storePrivate)
{
+ kern_return_t kr = KERN_SUCCESS;
CFDataRef myName; /* serialized name */
xmlData_t myNameRef;
CFIndex myNameLen;
CFIndex myOptionsLen = 0;
int sc_status = kSCStatusFailed;
mach_port_t server;
- kern_return_t status = KERN_SUCCESS;
if (!_SCSerializeString(storePrivate->name, &myName, (void **)&myNameRef, &myNameLen)) {
goto done;
}
/* open a new session with the server */
- server = _sc_server;
+ server = MACH_PORT_NULL;
updateServerPort(storePrivate, &server, &sc_status);
- while (TRUE) {
- if (server != MACH_PORT_NULL) {
- if (!storePrivate->serverNullSession) {
- // if SCDynamicStore session
- status = configopen(server,
- myNameRef,
- myNameLen,
- myOptionsRef,
- myOptionsLen,
- &storePrivate->server,
- (int *)&sc_status);
- } else {
- // if NULL session
- if (storePrivate->server == MACH_PORT_NULL) {
- // use the [main] SCDynamicStore server port
+ while (server != MACH_PORT_NULL) {
+ // if SCDynamicStore server available
+
+ if (!storePrivate->serverNullSession) {
+ // if SCDynamicStore session
+ kr = configopen(server,
+ myNameRef,
+ (mach_msg_type_number_t)myNameLen,
+ myOptionsRef,
+ (mach_msg_type_number_t)myOptionsLen,
+ &storePrivate->server,
+ (int *)&sc_status);
+ } else {
+ // if NULL session
+ if (storePrivate->server == MACH_PORT_NULL) {
+ // use the [main] SCDynamicStore server port
+ kr = mach_port_mod_refs(mach_task_self(), server, MACH_PORT_RIGHT_SEND, +1);
+ if (kr == KERN_SUCCESS) {
storePrivate->server = server;
sc_status = kSCStatusOK;
- status = KERN_SUCCESS;
} else {
- // if the server port we used returned an error
storePrivate->server = MACH_PORT_NULL;
- status = MACH_SEND_INVALID_DEST;
}
+ } else {
+ // if the server port we used returned an error
+ storePrivate->server = MACH_PORT_NULL;
+ kr = MACH_SEND_INVALID_DEST;
}
+ }
- if (status == KERN_SUCCESS) {
- break;
- }
+ if (kr == KERN_SUCCESS) {
+ break;
+ }
- // our [cached] server port is not valid
- if ((status != MACH_SEND_INVALID_DEST) && (status != MIG_SERVER_DIED)) {
- // if we got an unexpected error, don't retry
- sc_status = status;
- break;
- }
+ // our [cached] server port is not valid
+ if ((kr != MACH_SEND_INVALID_DEST) && (kr != MIG_SERVER_DIED)) {
+ // if we got an unexpected error, don't retry
+ sc_status = kr;
+ break;
}
updateServerPort(storePrivate, &server, &sc_status);
-
- if (server == MACH_PORT_NULL) {
- // if SCDynamicStore server not available
- break;
- }
}
__MACH_PORT_DEBUG(TRUE, "*** SCDynamicStoreAddSession", storePrivate->server);
return TRUE;
case BOOTSTRAP_UNKNOWN_SERVICE :
SCLog(TRUE,
- (status == KERN_SUCCESS) ? LOG_DEBUG : LOG_ERR,
+ (kr == KERN_SUCCESS) ? LOG_DEBUG : LOG_ERR,
CFSTR("SCDynamicStore server not available"));
sc_status = kSCStatusNoStoreServer;
break;
default :
SCLog(TRUE,
- (status == KERN_SUCCESS) ? LOG_DEBUG : LOG_ERR,
+ (kr == KERN_SUCCESS) ? LOG_DEBUG : LOG_ERR,
CFSTR("SCDynamicStoreAddSession configopen(): %s"),
SCErrorString(sc_status));
break;
tsd = __SCGetThreadSpecificData();
if (tsd->_sc_store == NULL) {
-#if !TARGET_IPHONE_SIMULATOR
storePrivate = __SCDynamicStoreCreatePrivate(NULL,
CFSTR("NULL session"),
NULL,
NULL);
assert(storePrivate != NULL);
- storePrivate->server = _sc_server;
storePrivate->serverNullSession = TRUE;
-#else
- /*
- * In the simulator, this code may be talking to an older version of
- * configd that still requires a valid session. Instead of using a
- * "NULL" session that uses the server mach port, set up a "normal"
- * session in thread-local storage.
- */
- storePrivate = __SCDynamicStoreCreatePrivate(NULL,
- CFSTR("Thread local session"),
- NULL,
- NULL);
- assert(storePrivate != NULL);
- /*
- * Use MACH_PORT_NULL here to trigger the call to
- * __SCDynamicStoreAddSession below.
- */
- storePrivate->server = MACH_PORT_NULL;
-#endif /* TARGET_IPHONE_SIMULATOR */
tsd->_sc_store = (SCDynamicStoreRef)storePrivate;
}
}
if ((status == MACH_SEND_INVALID_DEST) || (status == MIG_SERVER_DIED)) {
- /* the server's gone */
- if (!storePrivate->serverNullSession) {
- /*
- * remove the session's dead name right (and not the
- * not the "server" port)
- */
- (void) mach_port_deallocate(mach_task_self(), storePrivate->server);
- }
+ /* the server's gone, remove the session's dead name right */
+ (void) mach_port_deallocate(mach_task_self(), storePrivate->server);
storePrivate->server = MACH_PORT_NULL;
/* reconnect */
sessionPrivate = (SCHelperSessionPrivateRef)session;
// create per-session port
- (void) mach_port_allocate(mach_task_self(),
- MACH_PORT_RIGHT_RECEIVE,
- &sessionPrivate->port);
+ kr = mach_port_allocate(mach_task_self(),
+ MACH_PORT_RIGHT_RECEIVE,
+ &sessionPrivate->port);
+ if (kr != KERN_SUCCESS) {
+ SCLog(TRUE, LOG_ERR, CFSTR("_helperinit(): mach_port_allocate() failed: %s"), mach_error_string(kr));
+ *status = kr;
+ goto done;
+ }
+
*newSession = sessionPrivate->port;
(void) mach_port_set_attributes(mach_task_self(),
#include <bsm/libbsm.h>
#include <sandbox.h>
+#if !TARGET_IPHONE_SIMULATOR || (defined(IPHONE_SIMULATOR_HOST_MIN_VERSION_REQUIRED) && (IPHONE_SIMULATOR_HOST_MIN_VERSION_REQUIRED >= 1090))
+#define HAVE_MACHPORT_GUARDS
+#endif
+
/* information maintained for each active session */
static serverSessionRef *sessions = NULL;
serverSessionRef
addSession(mach_port_t server, CFStringRef (*copyDescription)(const void *info))
{
- CFMachPortContext context = { 0, NULL, NULL, NULL, NULL };
- mach_port_t mp = server;
- int n = -1;
+ CFMachPortContext context = { 0, NULL, NULL, NULL, NULL };
+ kern_return_t kr;
+ mach_port_t mp = server;
+ int n = -1;
+ serverSessionRef newSession = NULL;
/* save current (SCDynamicStore) runloop */
if (sessionRunLoop == NULL) {
nSessions = 64;
sessions = malloc(nSessions * sizeof(serverSessionRef));
+
+ // allocate a new session for "the" server
+ newSession = calloc(1, sizeof(serverSession));
} else {
- int i;
+ int i;
+#ifdef HAVE_MACHPORT_GUARDS
+ mach_port_options_t opts;
+#endif // HAVE_MACHPORT_GUARDS
/* check to see if we already have an open session (note: slot 0 is the "server" port) */
for (i = 1; i <= lastSession; i++) {
- serverSessionRef thisSession = sessions[i];
+ serverSessionRef thisSession = sessions[i];
if (thisSession == NULL) {
/* found an empty slot */
}
}
+ // allocate a session for this client
+ newSession = calloc(1, sizeof(serverSession));
+
// create mach port for SCDynamicStore client
mp = MACH_PORT_NULL;
- (void) mach_port_allocate(mach_task_self(),
- MACH_PORT_RIGHT_RECEIVE,
- &mp);
- }
- // allocate a new session for this server
- sessions[n] = malloc(sizeof(serverSession));
- bzero(sessions[n], sizeof(serverSession));
+ retry_allocate :
+
+#ifdef HAVE_MACHPORT_GUARDS
+ bzero(&opts, sizeof(opts));
+ opts.flags = MPO_CONTEXT_AS_GUARD;
+
+ kr = mach_port_construct(mach_task_self(), &opts, newSession, &mp);
+#else // HAVE_MACHPORT_GUARDS
+ kr = mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE, &mp);
+#endif // HAVE_MACHPORT_GUARDS
+
+ if (kr != KERN_SUCCESS) {
+ char *err = NULL;
+
+ SCLog(TRUE, LOG_ERR, CFSTR("addSession: could not allocate mach port: %s"), mach_error_string(kr));
+ if ((kr == KERN_NO_SPACE) || (kr == KERN_RESOURCE_SHORTAGE)) {
+ sleep(1);
+ goto retry_allocate;
+ }
+
+ (void) asprintf(&err, "addSession: could not allocate mach port: %s", mach_error_string(kr));
+ _SC_crash(err != NULL ? err : "addSession: could not allocate mach port",
+ NULL,
+ NULL);
+ if (err != NULL) free(err);
+
+ free(newSession);
+ return NULL;
+ }
+ }
// create server port
- context.info = sessions[n];
+ context.info = newSession;
context.copyDescription = copyDescription;
//
// right present to ensure that CF does not establish
// its dead name notification.
//
- sessions[n]->serverPort = _SC_CFMachPortCreateWithPort("SCDynamicStore/session",
- mp,
- configdCallback,
- &context);
+ newSession->serverPort = _SC_CFMachPortCreateWithPort("SCDynamicStore/session",
+ mp,
+ configdCallback,
+ &context);
if (n > 0) {
// insert send right that will be moved to the client
- (void) mach_port_insert_right(mach_task_self(),
- mp,
- mp,
- MACH_MSG_TYPE_MAKE_SEND);
+ kr = mach_port_insert_right(mach_task_self(),
+ mp,
+ mp,
+ MACH_MSG_TYPE_MAKE_SEND);
+ if (kr != KERN_SUCCESS) {
+ /*
+ * We can't insert a send right into our own port! This should
+ * only happen if someone stomped on OUR port (so let's leave
+ * the port alone).
+ */
+ SCLog(TRUE, LOG_ERR, CFSTR("addSession mach_port_insert_right(): %s"), mach_error_string(kr));
+
+ free(newSession);
+ return NULL;
+ }
}
+ sessions[n] = newSession;
sessions[n]->key = mp;
// sessions[n]->serverRunLoopSource = NULL;
// sessions[n]->store = NULL;
sessions[n]->callerWriteEntitlement = kCFNull; /* UNKNOWN */
#endif // TARGET_OS_IPHONE || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 1080/*FIXME*/)
- return sessions[n];
+ return newSession;
}
/*
* Our send right has already been removed. Remove our receive right.
*/
+#ifdef HAVE_MACHPORT_GUARDS
+ (void) mach_port_destruct(mach_task_self(), server, 0, thisSession);
+#else // HAVE_MACHPORT_GUARDS
(void) mach_port_mod_refs(mach_task_self(), server, MACH_PORT_RIGHT_RECEIVE, -1);
+#endif // HAVE_MACHPORT_GUARDS
#if TARGET_OS_IPHONE || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 1080/*FIXME*/)
/*