Differences From Artifact [fea66ded56]:
- File
src/OFStreamObserver_kqueue.m
— part of check-in
[e1e7ffa903]
at
2011-09-22 23:25:42
on branch trunk
— Exceptions are now autoreleased.
This is safe as an "exception loop" can't happen, since if allocating
an exception fails, it throws an OFAllocFailedException which is
preallocated and can always be thrown.So, the worst case would be that an autorelease of an exception fails,
triggering an OFOutOfMemoryException for which there is no memory,
resulting in an OFAllocFailedException to be thrown. (user: js, size: 3197) [annotate] [blame] [check-ins using]
To Artifact [b5282d84cd]:
- File
src/OFStreamObserver_kqueue.m
— part of check-in
[95fdb174f6]
at
2011-10-25 00:02:22
on branch trunk
— Always release the pool in -[OFStreamObserver observe].
Per convention, this would not be necessasry. However, a common
use case is to call -[observe] in a loop that never ends, thus
no pool below the one created in -[observe] will ever be released. (user: js, size: 3449) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
93 94 95 96 97 98 99 100 101 102 103 104 105 | EV_SET(&event, fd, EVFILT_WRITE, EV_DELETE, 0, 0, 0); [changeList addItem: &event]; } - (BOOL)observeWithTimeout: (int)timeout { struct timespec timespec = { timeout, 0 }; struct kevent eventList[EVENTLIST_SIZE]; int i, events; [self _processQueue]; | > | > > > > | > > > > > > | > > > | 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 | EV_SET(&event, fd, EVFILT_WRITE, EV_DELETE, 0, 0, 0); [changeList addItem: &event]; } - (BOOL)observeWithTimeout: (int)timeout { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; struct timespec timespec = { timeout, 0 }; struct kevent eventList[EVENTLIST_SIZE]; int i, events; [self _processQueue]; if ([self _processCache]) { [pool release]; return YES; } events = kevent(kernelQueue, [changeList cArray], (int)[changeList count], eventList, EVENTLIST_SIZE, (timeout == -1 ? NULL : ×pec)); if (events == -1) { switch (errno) { case EINTR: [pool release]; return NO; case ENOMEM: [pool release]; @throw [OFOutOfMemoryException exceptionWithClass: isa]; default: assert(0); } } [changeList removeNItems: [changeList count]]; if (events == 0) { [pool release]; return NO; } for (i = 0; i < events; i++) { if (eventList[i].ident == cancelFD[0]) { char buffer; assert(read(cancelFD[0], &buffer, 1) > 0); continue; } if (eventList[i].flags & EV_ERROR) { [delegate streamDidReceiveException: FDToStream[eventList[i].ident]]; [pool releaseObjects]; continue; } switch (eventList[i].filter) { case EVFILT_READ: [delegate streamIsReadyForReading: FDToStream[eventList[i].ident]]; [pool releaseObjects]; break; case EVFILT_WRITE: [delegate streamIsReadyForWriting: FDToStream[eventList[i].ident]]; [pool releaseObjects]; break; default: assert(0); } } [pool release]; return YES; } @end |