}
}
-
-//
-// Handle a port death or deallocation by removing all Listeners using that port.
-// Returns true iff we had one.
-//
-bool Listener::remove(Port port)
-{
- typedef ListenerMap::iterator Iterator;
- StLock<Mutex> _(setLock);
- pair<Iterator, Iterator> range = listeners.equal_range(port);
- if (range.first == range.second)
- return false; // not one of ours
-
- assert(range.first != listeners.end());
- secinfo("notify", "remove port %d", port.port());
-#if !defined(NDEBUG)
- for (Iterator it = range.first; it != range.second; it++) {
- assert(it->first == port);
- secinfo("notify", "%p listener removed", it->second.get());
- }
-#endif //NDEBUG
- listeners.erase(range.first, range.second);
- port.destroy();
- return true; // got it
-}
-
-
//
// Notification message objects
//
SharedMemoryListener::SharedMemoryListener(const char* segmentName, SegmentOffsetType segmentSize, uid_t uid, gid_t gid) :
Listener (kNotificationDomainAll, kNotificationAllEvents),
SharedMemoryServer (segmentName, segmentSize, uid, gid),
- mActive (false)
+ mActive (false), mMutex()
{
}
case kSecUnlockEvent: // kNotificationEventUnlocked
case kSecPasswordChangedEvent: // kNotificationEventPassphraseChanged
case kSecDefaultChangedEvent:
- case kSecDataAccessEvent:
case kSecKeychainListChangedEvent:
case kSecTrustSettingsChangedEvent:
return false;
+ case kSecDataAccessEvent:
case kSecAddEvent:
case kSecDeleteEvent:
case kSecUpdateEvent:
WriteMessage (notification->domain, notification->event, data, int_cast<size_t, UInt32>(length));
+ StLock<Mutex> lock(mMutex);
if (!mActive)
{
Server::active().setTimer (this, Time::Interval(kServerWait));
void SharedMemoryListener::action ()
{
+ StLock<Mutex> lock(mMutex);
+ notify_post (mSegmentName.c_str ());
secinfo("notify", "Posted notification to clients.");
secdebug("MDSPRIVACY","[%03d] Posted notification to clients", mUID);
- notify_post (mSegmentName.c_str ());
mActive = false;
}