Skip to content

Instantly share code, notes, and snippets.

@cyphre
Last active August 29, 2015 13:56
Show Gist options
  • Save cyphre/9122095 to your computer and use it in GitHub Desktop.
Save cyphre/9122095 to your computer and use it in GitHub Desktop.
REBOL [
title: "100% test of the bug #9910"
author: "Richard 'Cyphre' Smolak"
]
print ""
system/ports/system/awake: make function! [[
sport "System port (State block holds events)"
ports "Port list (Copy of block passed to WAIT)"
/local event port waked
][
print "SYSTEM awake begin"
waked: sport/data
loop 8 [
print ["pending req.:" length? sport/state]
unless event: take sport/state [break]
print ["event:" event/type]
port: event/port
? port
if wake-up port event [
unless find waked port [append waked port]
]
]
print ["ports:" type? ports]
unless block? ports [
print "SYSTEM awake NONE"
return none
]
print ["ports:" length? ports mold ports]
print ["waked:" length? waked]
forall ports [
if find waked first ports [print "SYSTEM awake end: TRUE" return true]
]
print "SYSTEM awake end: FALSE"
false
]]
do-download: make function! [[url /local port] [
port: make port! url
port/awake: funct [event] [
print ["HTTP awake begin: " event/type]
switch event/type [
connect [
;; Use HTTP's READ actor to send the HTTP request once we are
;; connected.
read event/port
]
read [
;; Schedule the low-level TCP port for further reading.
;; (@@ Smells! Should be taken care of by the HTTP scheme.)
read event/port/state/connection
]
done [
;; Use HTTP's COPY actor to read the full website content once
;; reading is finished. (But throw away the data immediately.)
copy event/port
close event/port
print "HTTP awake end"
return true
]
]
print "HTTP awake end"
false
]
open port
port
]]
loop 2 [
do-download http://www.rebol.com
recycle
]
wait 1
print "TEST PASSED"
halt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment