︙ | | | ︙ | |
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
#include <sys/time.h>
#import "OFSelectKernelEventObserver.h"
#import "OFArray.h"
#import "OFSocket+Private.h"
#import "OFInitializationFailedException.h"
#import "OFObserveFailedException.h"
#import "OFOutOfRangeException.h"
#ifdef OF_AMIGAOS
# include <proto/exec.h>
#endif
#ifdef OF_HPUX
|
|
|
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
#include <sys/time.h>
#import "OFSelectKernelEventObserver.h"
#import "OFArray.h"
#import "OFSocket+Private.h"
#import "OFInitializationFailedException.h"
#import "OFObserveKernelEventsFailedException.h"
#import "OFOutOfRangeException.h"
#ifdef OF_AMIGAOS
# include <proto/exec.h>
#endif
#ifdef OF_HPUX
|
︙ | | | ︙ | |
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
}
- (void)addObjectForReading: (id <OFReadyForReadingObserving>)object
{
int fd = object.fileDescriptorForReading;
if (fd < 0)
@throw [OFObserveFailedException exceptionWithObserver: self
errNo: EBADF];
if (fd > INT_MAX - 1)
@throw [OFOutOfRangeException exception];
#ifndef OF_WINDOWS
if (fd >= (int)FD_SETSIZE)
@throw [OFOutOfRangeException exception];
|
>
|
|
|
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
}
- (void)addObjectForReading: (id <OFReadyForReadingObserving>)object
{
int fd = object.fileDescriptorForReading;
if (fd < 0)
@throw [OFObserveKernelEventsFailedException
exceptionWithObserver: self
errNo: EBADF];
if (fd > INT_MAX - 1)
@throw [OFOutOfRangeException exception];
#ifndef OF_WINDOWS
if (fd >= (int)FD_SETSIZE)
@throw [OFOutOfRangeException exception];
|
︙ | | | ︙ | |
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
}
- (void)addObjectForWriting: (id <OFReadyForWritingObserving>)object
{
int fd = object.fileDescriptorForWriting;
if (fd < 0)
@throw [OFObserveFailedException exceptionWithObserver: self
errNo: EBADF];
if (fd > INT_MAX - 1)
@throw [OFOutOfRangeException exception];
#ifndef OF_WINDOWS
if (fd >= (int)FD_SETSIZE)
@throw [OFOutOfRangeException exception];
|
>
|
|
|
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
}
- (void)addObjectForWriting: (id <OFReadyForWritingObserving>)object
{
int fd = object.fileDescriptorForWriting;
if (fd < 0)
@throw [OFObserveKernelEventsFailedException
exceptionWithObserver: self
errNo: EBADF];
if (fd > INT_MAX - 1)
@throw [OFOutOfRangeException exception];
#ifndef OF_WINDOWS
if (fd >= (int)FD_SETSIZE)
@throw [OFOutOfRangeException exception];
|
︙ | | | ︙ | |
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
|
- (void)removeObjectForReading: (id <OFReadyForReadingObserving>)object
{
/* TODO: Adjust _maxFD */
int fd = object.fileDescriptorForReading;
if (fd < 0)
@throw [OFObserveFailedException exceptionWithObserver: self
errNo: EBADF];
#ifndef OF_WINDOWS
if (fd >= (int)FD_SETSIZE)
@throw [OFOutOfRangeException exception];
#endif
FD_CLR((OFSocketHandle)fd, &_readFDs);
[super removeObjectForReading: object];
}
- (void)removeObjectForWriting: (id <OFReadyForWritingObserving>)object
{
/* TODO: Adjust _maxFD */
int fd = object.fileDescriptorForWriting;
if (fd < 0)
@throw [OFObserveFailedException exceptionWithObserver: self
errNo: EBADF];
#ifndef OF_WINDOWS
if (fd >= (int)FD_SETSIZE)
@throw [OFOutOfRangeException exception];
#endif
|
>
|
|
>
|
|
|
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
|
- (void)removeObjectForReading: (id <OFReadyForReadingObserving>)object
{
/* TODO: Adjust _maxFD */
int fd = object.fileDescriptorForReading;
if (fd < 0)
@throw [OFObserveKernelEventsFailedException
exceptionWithObserver: self
errNo: EBADF];
#ifndef OF_WINDOWS
if (fd >= (int)FD_SETSIZE)
@throw [OFOutOfRangeException exception];
#endif
FD_CLR((OFSocketHandle)fd, &_readFDs);
[super removeObjectForReading: object];
}
- (void)removeObjectForWriting: (id <OFReadyForWritingObserving>)object
{
/* TODO: Adjust _maxFD */
int fd = object.fileDescriptorForWriting;
if (fd < 0)
@throw [OFObserveKernelEventsFailedException
exceptionWithObserver: self
errNo: EBADF];
#ifndef OF_WINDOWS
if (fd >= (int)FD_SETSIZE)
@throw [OFOutOfRangeException exception];
#endif
|
︙ | | | ︙ | |
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
|
#else
timeout.tv_sec = (long)timeInterval;
#endif
timeout.tv_usec = (int)((timeInterval - timeout.tv_sec) * 1000000);
#ifdef OF_AMIGAOS
if ((cancelSignal = AllocSignal(-1)) == (BYTE)-1)
@throw [OFObserveFailedException exceptionWithObserver: self
errNo: EAGAIN];
execSignalMask = _execSignalMask | (1ul << cancelSignal);
Forbid();
_waitingTask = FindTask(NULL);
_cancelSignal = cancelSignal;
|
>
|
|
|
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
|
#else
timeout.tv_sec = (long)timeInterval;
#endif
timeout.tv_usec = (int)((timeInterval - timeout.tv_sec) * 1000000);
#ifdef OF_AMIGAOS
if ((cancelSignal = AllocSignal(-1)) == (BYTE)-1)
@throw [OFObserveKernelEventsFailedException
exceptionWithObserver: self
errNo: EAGAIN];
execSignalMask = _execSignalMask | (1ul << cancelSignal);
Forbid();
_waitingTask = FindTask(NULL);
_cancelSignal = cancelSignal;
|
︙ | | | ︙ | |
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
|
Permit();
#else
events = select(_maxFD + 1, &readFDs, &writeFDs, NULL,
(timeInterval != -1 ? &timeout : NULL));
#endif
if (events < 0)
@throw [OFObserveFailedException
exceptionWithObserver: self
errNo: OFSocketErrNo()];
#ifdef OF_AMIGAOS
if (execSignalMask != 0 &&
[_delegate respondsToSelector: @selector(execSignalWasReceived:)])
[_delegate execSignalWasReceived: execSignalMask];
|
|
|
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
|
Permit();
#else
events = select(_maxFD + 1, &readFDs, &writeFDs, NULL,
(timeInterval != -1 ? &timeout : NULL));
#endif
if (events < 0)
@throw [OFObserveKernelEventsFailedException
exceptionWithObserver: self
errNo: OFSocketErrNo()];
#ifdef OF_AMIGAOS
if (execSignalMask != 0 &&
[_delegate respondsToSelector: @selector(execSignalWasReceived:)])
[_delegate execSignalWasReceived: execSignalMask];
|
︙ | | | ︙ | |