ObjFW  Diff

Differences From Artifact [905345cfde]:

To Artifact [9e96dde949]:


14
15
16
17
18
19
20
21

22

23
24
25
26
27
28
29
30

31
32
33
34
35
36
37
14
15
16
17
18
19
20

21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39







-
+

+








+







 * file.
 */

#define __NO_EXT_QNX

#include "config.h"

#include <string.h>
#include <errno.h>
#include <math.h>
#include <string.h>

#include <sys/time.h>

#import "OFKernelEventObserver.h"
#import "OFKernelEventObserver+Private.h"
#import "OFKernelEventObserver_select.h"
#import "OFArray.h"

#import "OFObserveFailedException.h"
#import "OFOutOfRangeException.h"

#import "socket_helpers.h"

@implementation OFKernelEventObserver_select
- init
{
80
81
82
83
84
85
86

87
88
89
90
91
92
93
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96







+







- (bool)observeForTimeInterval: (of_time_interval_t)timeInterval
{
	void *pool = objc_autoreleasePoolPush();
	id const *objects;
	fd_set readFDs;
	fd_set writeFDs;
	struct timeval timeout;
	int events;
	size_t i, count, realEvents = 0;

	[self OF_processQueueAndStoreRemovedIn: nil];

	if ([self OF_processCache]) {
		objc_autoreleasePoolPop(pool);
		return true;
112
113
114
115
116
117
118
119
120








121
122
123
124
125
126
127
115
116
117
118
119
120
121


122
123
124
125
126
127
128
129
130
131
132
133
134
135
136







-
-
+
+
+
+
+
+
+
+







#ifndef _WIN32
	timeout.tv_sec = (time_t)timeInterval;
#else
	timeout.tv_sec = (long)timeInterval;
#endif
	timeout.tv_usec = (int)lrint((timeInterval - timeout.tv_sec) * 1000);

	if (select((int)_maxFD + 1, &readFDs, &writeFDs, NULL,
	    (timeInterval != -1 ? &timeout : NULL)) < 1)
	events = select((int)_maxFD + 1, &readFDs, &writeFDs, NULL,
	    (timeInterval != -1 ? &timeout : NULL));

	if (events < 0)
		@throw [OFObserveFailedException exceptionWithObserver: self
								 errNo: errno];

	if (events == 0)
		return false;

	if (FD_ISSET(_cancelFD[0], &readFDs)) {
		char buffer;
#ifndef _WIN32
		OF_ENSURE(read(_cancelFD[0], &buffer, 1) > 0);
#else