]> gitweb.factorcode.org Git - factor.git/commitdiff
io.ports: Make buffered-port not have a length because of Linux virtual files and...
authorDoug Coleman <doug.coleman@gmail.com>
Tue, 23 Dec 2014 21:47:50 +0000 (13:47 -0800)
committerDoug Coleman <doug.coleman@gmail.com>
Tue, 23 Dec 2014 21:47:50 +0000 (13:47 -0800)
Related to issues #1256 and #1259.

basis/io/ports/ports-tests.factor
basis/io/ports/ports.factor

index 9fb5a5826b71b25e862230eac9f686722717b96f..ae63b650d97505c87cfa5deed9026cc230e1a99e 100644 (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
index 8646d3b609cd629ecdd7a475aae8de1032ab7438..208e023e08348ae5f1df529d46769a4aa680d901 100644 (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 -- )