ObjFW  Diff

Differences From Artifact [4a4c51ed64]:

To Artifact [bb3d801549]:


71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
}

- (void)OF_addObject: (id)object
      fileDescriptor: (int)fd
	      events: (short)events
{
	struct pollfd *FDs = [_FDs items];
	size_t i, count = [_FDs count];
	bool found = false;

	for (i = 0; i < count; i++) {
		if (FDs[i].fd == fd) {
			FDs[i].events |= events;
			found = true;
			break;
		}
	}








|


|







71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
}

- (void)OF_addObject: (id)object
      fileDescriptor: (int)fd
	      events: (short)events
{
	struct pollfd *FDs = [_FDs items];
	size_t count = [_FDs count];
	bool found = false;

	for (size_t i = 0; i < count; i++) {
		if (FDs[i].fd == fd) {
			FDs[i].events |= events;
			found = true;
			break;
		}
	}

102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
}

- (void)OF_removeObject: (id)object
	 fileDescriptor: (int)fd
		 events: (short)events
{
	struct pollfd *FDs = [_FDs items];
	size_t i, nFDs = [_FDs count];

	for (i = 0; i < nFDs; i++) {
		if (FDs[i].fd == fd) {
			FDs[i].events &= ~events;

			if (FDs[i].events == 0) {
				/*
				 * TODO: Remove from and resize _FDToObject,
				 *	 adjust _maxFD.







|

|







102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
}

- (void)OF_removeObject: (id)object
	 fileDescriptor: (int)fd
		 events: (short)events
{
	struct pollfd *FDs = [_FDs items];
	size_t nFDs = [_FDs count];

	for (size_t i = 0; i < nFDs; i++) {
		if (FDs[i].fd == fd) {
			FDs[i].events &= ~events;

			if (FDs[i].events == 0) {
				/*
				 * TODO: Remove from and resize _FDToObject,
				 *	 adjust _maxFD.
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
}

- (void)observeForTimeInterval: (of_time_interval_t)timeInterval
{
	void *pool = objc_autoreleasePoolPush();
	struct pollfd *FDs;
	int events;
	size_t i, nFDs;

	[self OF_processQueue];
	[self OF_processReadBuffers];

	objc_autoreleasePoolPop(pool);

	FDs = [_FDs items];







|







158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
}

- (void)observeForTimeInterval: (of_time_interval_t)timeInterval
{
	void *pool = objc_autoreleasePoolPush();
	struct pollfd *FDs;
	int events;
	size_t nFDs;

	[self OF_processQueue];
	[self OF_processReadBuffers];

	objc_autoreleasePoolPop(pool);

	FDs = [_FDs items];
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
	events = poll(FDs, (nfds_t)nFDs,
	    (int)(timeInterval != -1 ? timeInterval * 1000 : -1));

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

	for (i = 0; i < nFDs; i++) {
		assert(FDs[i].fd <= _maxFD);

		if (FDs[i].revents & POLLIN) {
			if (FDs[i].fd == _cancelFD[0]) {
				char buffer;

#ifdef OF_HAVE_PIPE







|







180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
	events = poll(FDs, (nfds_t)nFDs,
	    (int)(timeInterval != -1 ? timeInterval * 1000 : -1));

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

	for (size_t i = 0; i < nFDs; i++) {
		assert(FDs[i].fd <= _maxFD);

		if (FDs[i].revents & POLLIN) {
			if (FDs[i].fd == _cancelFD[0]) {
				char buffer;

#ifdef OF_HAVE_PIPE