bytevector size for doing select has been fixed. It used to be 8
times larger than needed.
This commit is contained in:
parent
df4b31af1f
commit
9438328f55
|
@ -2208,51 +2208,52 @@
|
||||||
|
|
||||||
(define (do-select)
|
(define (do-select)
|
||||||
(let ([n (add1 (get-max-fd))])
|
(let ([n (add1 (get-max-fd))])
|
||||||
(let ([rbv (make-bytevector n 0)]
|
(let ([vecsize (div (+ n 7) 8)])
|
||||||
[wbv (make-bytevector n 0)]
|
(let ([rbv (make-bytevector vecsize 0)]
|
||||||
[xbv (make-bytevector n 0)])
|
[wbv (make-bytevector vecsize 0)]
|
||||||
;;; add all fds to their bytevectors depending on type
|
[xbv (make-bytevector vecsize 0)])
|
||||||
(for-each
|
;;; add all fds to their bytevectors depending on type
|
||||||
(lambda (t)
|
(for-each
|
||||||
(let ([fd (t-fd t)])
|
(lambda (t)
|
||||||
(let ([i (div fd 8)] [j (mod fd 8)])
|
(let ([fd (t-fd t)])
|
||||||
(let ([bv (case (t-type t)
|
(let ([i (div fd 8)] [j (mod fd 8)])
|
||||||
[(r) rbv]
|
(let ([bv (case (t-type t)
|
||||||
[(w) wbv]
|
[(r) rbv]
|
||||||
[(x) xbv]
|
[(w) wbv]
|
||||||
[else
|
[(x) xbv]
|
||||||
(error 'do-select "invalid type" t)])])
|
[else
|
||||||
(bytevector-u8-set! bv i
|
(error 'do-select "invalid type" t)])])
|
||||||
(fxlogor (fxsll 1 j)
|
(bytevector-u8-set! bv i
|
||||||
(bytevector-u8-ref bv i)))))))
|
(fxlogor (fxsll 1 j)
|
||||||
pending)
|
(bytevector-u8-ref bv i)))))))
|
||||||
;;; do select
|
pending)
|
||||||
(let ([rv (foreign-call "ikrt_select" n rbv wbv xbv)])
|
;;; do select
|
||||||
(when (< rv 0)
|
(let ([rv (foreign-call "ikrt_select" n rbv wbv xbv)])
|
||||||
(io-error 'select #f rv)))
|
(when (< rv 0)
|
||||||
;;; go through fds again and see if they're selected
|
(io-error 'select #f rv)))
|
||||||
(for-each
|
;;; go through fds again and see if they're selected
|
||||||
(lambda (t)
|
(for-each
|
||||||
(let ([fd (t-fd t)])
|
(lambda (t)
|
||||||
(let ([i (div fd 8)] [j (mod fd 8)])
|
(let ([fd (t-fd t)])
|
||||||
(let ([bv (case (t-type t)
|
(let ([i (div fd 8)] [j (mod fd 8)])
|
||||||
[(r) rbv]
|
(let ([bv (case (t-type t)
|
||||||
[(w) wbv]
|
[(r) rbv]
|
||||||
[(x) xbv]
|
[(w) wbv]
|
||||||
[else
|
[(x) xbv]
|
||||||
(error 'do-select "invalid type" t)])])
|
[else
|
||||||
(cond
|
(error 'do-select "invalid type" t)])])
|
||||||
[(fxzero?
|
(cond
|
||||||
(fxlogand (fxsll 1 j)
|
[(fxzero?
|
||||||
(bytevector-u8-ref bv i)))
|
(fxlogand (fxsll 1 j)
|
||||||
;;; not selected
|
(bytevector-u8-ref bv i)))
|
||||||
(set! pending (cons t pending))]
|
;;; not selected
|
||||||
[else
|
(set! pending (cons t pending))]
|
||||||
;;; ready
|
[else
|
||||||
(set! in-queue (cons t in-queue))])))))
|
;;; ready
|
||||||
(let ([ls pending])
|
(set! in-queue (cons t in-queue))])))))
|
||||||
(set! pending '())
|
(let ([ls pending])
|
||||||
ls)))))
|
(set! pending '())
|
||||||
|
ls))))))
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
1500
|
1501
|
||||||
|
|
Loading…
Reference in New Issue