437 evaluated when input on aFileDescriptor arrives. |
437 evaluated when input on aFileDescriptor arrives. |
438 This is a leftover support for pure-event systems and may vanish." |
438 This is a leftover support for pure-event systems and may vanish." |
439 |
439 |
440 |idx "{Class: SmallInteger }" |
440 |idx "{Class: SmallInteger }" |
441 wasBlocked| |
441 wasBlocked| |
|
442 |
|
443 aFileDescriptor < 0 ifTrue:[ |
|
444 'Processor [warning]: ignored invalid fd for IO action.' errorPrintCR. |
|
445 thisContext fullPrintAll. |
|
446 ^ self |
|
447 ]. |
442 |
448 |
443 wasBlocked := OperatingSystem blockInterrupts. |
449 wasBlocked := OperatingSystem blockInterrupts. |
444 (readFdArray identityIndexOf:aFileDescriptor startingAt:1) == 0 ifTrue:[ |
450 (readFdArray identityIndexOf:aFileDescriptor startingAt:1) == 0 ifTrue:[ |
445 idx := readFdArray identityIndexOf:nil startingAt:1. |
451 idx := readFdArray identityIndexOf:nil startingAt:1. |
446 idx ~~ 0 ifTrue:[ |
452 idx ~~ 0 ifTrue:[ |
1952 (This is req'd for buffered input, where a select may not detect |
1958 (This is req'd for buffered input, where a select may not detect |
1953 data which has already been read into a buffer - as in Xlib. |
1959 data which has already been read into a buffer - as in Xlib. |
1954 Or on systems, where we cannot select on a displays eventQ, such as windows)" |
1960 Or on systems, where we cannot select on a displays eventQ, such as windows)" |
1955 |
1961 |
1956 |idx "{ Class: SmallInteger }" |
1962 |idx "{ Class: SmallInteger }" |
1957 wasBlocked| |
1963 fd wasBlocked| |
1958 |
1964 |
1959 aFileDescriptor isNil ifTrue:[ |
1965 fd := aFileDescriptor. |
1960 'ProcessorScheduler [info]: no fd to select on - polling with checkBlock' infoPrintCR |
1966 fd < 0 ifTrue:[ |
|
1967 'Processor [warning]: invalid fd for IO signal' errorPrintCR. |
|
1968 fd := nil. |
1961 ]. |
1969 ]. |
1962 |
1970 |
1963 wasBlocked := OperatingSystem blockInterrupts. |
1971 wasBlocked := OperatingSystem blockInterrupts. |
1964 (readFdArray identityIndexOf:aFileDescriptor startingAt:1) == 0 ifTrue:[ |
1972 |
1965 idx := readFdArray identityIndexOf:nil startingAt:1. |
1973 fd isNil ifTrue:[ |
1966 idx ~~ 0 ifTrue:[ |
1974 'Processor [info]: no fd to select on - polling with checkBlock' infoPrintCR. |
1967 readFdArray at:idx put:aFileDescriptor. |
1975 (readCheckArray identityIndexOf:aBlock startingAt:1) == 0 ifTrue:[ |
1968 readSemaphoreArray at:idx put:aSemaphore. |
1976 readFdArray := readFdArray copyWith:nil. |
1969 readCheckArray at:idx put:aBlock |
1977 readSemaphoreArray := readSemaphoreArray copyWith:aSemaphore. |
1970 ] ifFalse:[ |
1978 readCheckArray := readCheckArray copyWith:aBlock. |
1971 readFdArray := readFdArray copyWith:aFileDescriptor. |
1979 ] |
1972 readSemaphoreArray := readSemaphoreArray copyWith:aSemaphore. |
1980 ] ifFalse:[ |
1973 readCheckArray := readCheckArray copyWith:aBlock. |
1981 (readFdArray identityIndexOf:aFileDescriptor startingAt:1) == 0 ifTrue:[ |
1974 ]. |
1982 idx := readFdArray identityIndexOf:nil startingAt:1. |
1975 useIOInterrupts ifTrue:[ |
1983 idx ~~ 0 ifTrue:[ |
1976 OperatingSystem enableIOInterruptsOn:aFileDescriptor |
1984 readFdArray at:idx put:aFileDescriptor. |
1977 ]. |
1985 readSemaphoreArray at:idx put:aSemaphore. |
1978 |
1986 readCheckArray at:idx put:aBlock |
|
1987 ] ifFalse:[ |
|
1988 readFdArray := readFdArray copyWith:aFileDescriptor. |
|
1989 readSemaphoreArray := readSemaphoreArray copyWith:aSemaphore. |
|
1990 readCheckArray := readCheckArray copyWith:aBlock. |
|
1991 ]. |
|
1992 useIOInterrupts ifTrue:[ |
|
1993 OperatingSystem enableIOInterruptsOn:aFileDescriptor |
|
1994 ]. |
|
1995 ] |
1979 ]. |
1996 ]. |
1980 wasBlocked ifFalse:[OperatingSystem unblockInterrupts]. |
1997 wasBlocked ifFalse:[OperatingSystem unblockInterrupts]. |
1981 |
1998 |
1982 "Modified: 4.8.1997 / 15:20:45 / cg" |
1999 "Modified: 4.8.1997 / 15:20:45 / cg" |
1983 ! |
2000 ! |
2321 wasBlocked ifTrue:[ |
2338 wasBlocked ifTrue:[ |
2322 OperatingSystem blockInterrupts. |
2339 OperatingSystem blockInterrupts. |
2323 ]. |
2340 ]. |
2324 |
2341 |
2325 fd isNil ifTrue:[ |
2342 fd isNil ifTrue:[ |
|
2343 "/ either still nothing to do, |
|
2344 "/ or error (which should not happen) |
|
2345 |
2326 (err := OperatingSystem lastErrorSymbol) notNil ifTrue:[ |
2346 (err := OperatingSystem lastErrorSymbol) notNil ifTrue:[ |
2327 err == #EBADF ifTrue:[ |
2347 err == #EBADF ifTrue:[ |
2328 |
2348 |
2329 "/ mhmh - one of the fd's given to me is corrupt. |
2349 "/ mhmh - one of the fd's given to me is corrupt. |
2330 "/ find out which one .... and remove it |
2350 "/ find out which one .... and remove it |
2331 |
2351 |
2332 'OperatingSystem [warning]: bad FD in select - clearing' infoPrintCR. |
2352 'Processor [warning]: bad FD in select - clearing' infoPrintCR. |
2333 OperatingSystem clearLastErrorNumber. |
2353 OperatingSystem clearLastErrorNumber. |
2334 self removeCorruptedFds |
2354 self removeCorruptedFds |
2335 ] ifFalse:[ |
2355 ] ifFalse:[ |
2336 'OperatingSystem [warning]: error in select: ' infoPrint. err infoPrintCR. |
2356 err == #ENOENT ifTrue:[ |
|
2357 'Processor ENOENT in select; rd=' infoPrint. |
|
2358 readFdArray infoPrint. |
|
2359 ' wr=' infoPrint. |
|
2360 writeFdArray infoPrintCR. |
|
2361 ] ifFalse:[ |
|
2362 'Processor [warning]: error in select: ' infoPrint. err infoPrintCR. |
|
2363 ] |
2337 ]. |
2364 ]. |
2338 ] |
2365 ] |
2339 ] ifFalse:[ |
2366 ] ifFalse:[ |
2340 index := readFdArray indexOf:fd. |
2367 index := readFdArray indexOf:fd. |
2341 index ~~ 0 ifTrue:[ |
2368 index ~~ 0 ifTrue:[ |