io.ports: Make buffered-port not have a length because of Linux virtual files and TCP sockets.

Related to issues #1256 and #1259.
db4
Doug Coleman 2014-12-23 13:47:50 -08:00
parent 0b460c431b
commit c59a025288
2 changed files with 15 additions and 3 deletions

View File

@ -1,6 +1,8 @@
USING: accessors alien.c-types alien.data destructors io
io.directories io.encodings.ascii io.encodings.binary io.files
io.files.temp io.pipes kernel libc math sequences tools.test ;
io.directories io.encodings.ascii io.encodings.binary
io.encodings.string io.encodings.utf8 io.files io.files.temp
io.pipes io.sockets kernel libc math namespaces sequences
tools.test ;
IN: io.ports.tests
! Make sure that writing malloced storage to a file works, and
@ -29,3 +31,12 @@ IN: io.ports.tests
[ +byte+ ] [ binary <pipe> [ out>> stream-element-type ] with-disposal ] unit-test
[ +character+ ] [ ascii <pipe> [ stream-element-type ] with-disposal ] unit-test
[ +character+ ] [ ascii <pipe> [ out>> stream-element-type ] with-disposal ] unit-test
! Issue #1256 regression test
! Port length would be zero before data is received
{ f } [
"google.com" 80 <inet> binary [
"GET /\n" utf8 encode write flush
input-stream get stream-contents
] with-client empty?
] unit-test

View File

@ -208,8 +208,9 @@ M: output-port stream-seek
M: buffered-port stream-seekable?
handle>> can-seek-handle? ;
! Cannot be ``handle>> handle-length`` because of a race condition.
M: buffered-port stream-length
handle>> handle-length ;
drop f ;
GENERIC: shutdown ( handle -- )