+bool Listener::JitterBuffer::inSequence(Notification *message)
+{
+ if (message->sequence == mNotifyLast + 1) { // next in sequence
+ mNotifyLast++; // record next sequence
+ return true; // go ahead
+ } else {
+ secdebug("notify-jit", "%p out of sequence (last %ld got %ld); buffering",
+ message, mNotifyLast, message->sequence);
+ mBuffer[message->sequence] = message; // save for later
+ return false; // hold your fire
+ }
+}
+
+RefPointer<Listener::Notification> Listener::JitterBuffer::popNotification()
+{
+ JBuffer::iterator it = mBuffer.find(mNotifyLast + 1); // have next message?
+ if (it == mBuffer.end())
+ return NULL; // nothing here
+ else {
+ RefPointer<Notification> result = it->second; // save value
+ mBuffer.erase(it); // remove from buffer
+ secdebug("notify-jit", "%p retrieved from jitter buffer", result.get());
+ return result; // return it
+ }
+}
+
+/*
+ * Shared memory listener
+ */
+
+
+SharedMemoryListener::SharedMemoryListener(const char* segmentName, SegmentOffsetType segmentSize) :
+ Listener (kNotificationDomainAll, kNotificationAllEvents),
+ SharedMemoryServer (segmentName, segmentSize),
+ mActive (false)
+{
+ if (segmentName == NULL)
+ {
+ secdebug("notify", "Attempted to start securityd with a NULL segmentName");
+ exit(1);
+ }
+}
+
+SharedMemoryListener::~SharedMemoryListener ()
+{
+}
+
+const double kServerWait = 0.005; // time in seconds before clients will be notified that data is available
+
+void SharedMemoryListener::notifyMe(Notification* notification)
+{
+ const void* data = notification->data.data();
+ UInt32 length = notification->data.length();
+ WriteMessage (notification->domain, notification->event, data, length);
+
+ if (!mActive)
+ {
+ Server::active().setTimer (this, Time::Interval(kServerWait));
+ mActive = true;
+ }
+}
+
+void SharedMemoryListener::action ()