- struct _CFStream *stream = NULL;
- CFOptionFlags eventMask, whatToSignal = 0;
+ __CFBitSet(stream->flags, CALLING_CLIENT);
+
+ for (eventMask = 1; eventMask <= whatToSignal; eventMask = eventMask << 1) {
+ if ((eventMask & whatToSignal) && (stream->client->when & eventMask)) {
+ stream->client->cb(stream, eventMask, stream->client->cbContext.info);
+
+ /* What happens if the callback sets the client to NULL? We're in a loop here... Hmm. */
+ /* After writing that comment, I see: <rdar://problem/6793636> CFReadStreamSetClient(..., NULL) unsafely releases info pointer immediately */
+ }
+ }