#include <unistd.h>
#include "configd.h"
#include "session.h"
__private_extern__
int
__SCDynamicStoreNotifyCancel(SCDynamicStoreRef store)
{
SCDynamicStorePrivateRef storePrivate = (SCDynamicStorePrivateRef)store;
if (storePrivate->notifyPort != MACH_PORT_NULL) {
__MACH_PORT_DEBUG(TRUE, "*** __SCDynamicStoreNotifyCancel (notify port)", storePrivate->notifyPort);
(void) mach_port_deallocate(mach_task_self(), storePrivate->notifyPort);
storePrivate->notifyPort = MACH_PORT_NULL;
}
if (storePrivate->notifyFile != -1) {
(void) close(storePrivate->notifyFile);
storePrivate->notifyFile = -1;
}
if (needsNotification) {
CFNumberRef num;
num = CFNumberCreate(NULL, kCFNumberIntType, &storePrivate->server);
CFSetRemoveValue(needsNotification, num);
CFRelease(num);
if (CFSetGetCount(needsNotification) == 0) {
CFRelease(needsNotification);
needsNotification = NULL;
}
}
storePrivate->notifyStatus = NotifierNotRegistered;
return kSCStatusOK;
}
__private_extern__
kern_return_t
_notifycancel(mach_port_t server,
int *sc_status)
{
serverSessionRef mySession = getSession(server);
if (mySession == NULL) {
*sc_status = kSCStatusNoStoreSession;
return KERN_SUCCESS;
}
__MACH_PORT_DEBUG(((SCDynamicStorePrivateRef)mySession->store)->notifyPort != MACH_PORT_NULL,
"*** _notifycancel",
((SCDynamicStorePrivateRef)mySession->store)->notifyPort);
*sc_status = __SCDynamicStoreNotifyCancel(mySession->store);
return KERN_SUCCESS;
}