ObjFW  Check-in [52102a2906]

Overview
Comment:Check nfds against OPEN_MAX before calling poll.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 52102a2906ef9a75e2081d99494b1ed72218db946f00b77a0703d83e9bd70693
User & Date: js on 2011-04-01 16:06:48
Other Links: manifest | tags
Context
2011-04-01
16:54
Make OFStreamObserver thread-safe. check-in: 35aab77af3 user: js tags: trunk
16:06
Check nfds against OPEN_MAX before calling poll. check-in: 52102a2906 user: js tags: trunk
2011-03-31
12:32
Add -[setChildren:] and -[setStringValue:] to OFXMLElement. check-in: caef9fbb2e user: js tags: trunk
Changes

Modified src/OFStreamObserver.m from [ec16112800] to [3eaeff6179].

237
238
239
240
241
242
243
244

245
246
247
248
249

250
251
252
253
254
255
256
237
238
239
240
241
242
243

244





245
246
247
248
249
250
251
252







-
+
-
-
-
-
-
+







- (BOOL)observeWithTimeout: (int)timeout
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	BOOL foundInCache = NO;
	OFStream **cArray;
	size_t i, count;
#ifdef OF_HAVE_POLL
	struct pollfd *fds_c = [fds cArray];
	struct pollfd *fds_c;
	/*
	 * There is no way to find out the maximum number of fds, so we just
	 * cast.
	 */
	nfds_t nfds = (nfds_t)[fds count];
	nfds_t nfds;
#else
	fd_set readfds_;
	fd_set writefds_;
	fd_set exceptfds_;
	struct timeval tv;
#endif

268
269
270
271
272
273
274






275

276
277
278
279
280
281
282
264
265
266
267
268
269
270
271
272
273
274
275
276

277
278
279
280
281
282
283
284







+
+
+
+
+
+
-
+







	 * As long as we have data in the cache for any stream, we don't want
	 * to block.
	 */
	if (foundInCache)
		return YES;

#ifdef OF_HAVE_POLL
	fds_c = [fds cArray];
	nfds = [fds count];

	if (nfds > OPEN_MAX)
		@throw [OFOutOfRangeException newWithClass: isa];

	if (poll(fds_c, nfds, timeout) < 1)
	if (poll(fds_c, (nfds_t)nfds, timeout) < 1)
		return NO;

	for (i = 0; i < nfds; i++) {
		OFNumber *num;
		OFStream *stream;

		if (fds_c[i].revents & POLLIN) {