Commit Graph

18 Commits

Author SHA1 Message Date
ager@google.com 4605b5ea33 Minor changes to the dart:io library files.
- Split some of the streams into an interface and an implementation file.
- Add documentation comments where missing.

R=sgjesse@google.com
BUG=
TEST=

Review URL: https://chromiumcodereview.appspot.com//9289042

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@3616 260f80e4-7a28-3924-810f-c04153c831b5
2012-01-26 10:03:19 +00:00
sgjesse@google.com 8055ffeb77 Add close to input stream and cleanup socket and streams
* All input streams now have a close method for just cutting
  the stream
* Removed interfaces FileInputStream and FileOutputStream
* Added exceptions to socket to avoid mixing stream and non-stream
  use of the same socket
* Added special handling of the socket connect handler callback

R=ager@google.com

BUG=
TEST=

Review URL: http://codereview.chromium.org//9029001

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@2893 260f80e4-7a28-3924-810f-c04153c831b5
2012-01-02 13:00:59 +00:00
sgjesse@google.com 0a3bf1c3eb Add pipe to input stream
Using the pipe method the data from an input stream can be piped
directly to an output stream.

R=whesse@google.com, ager@google.com

BUG=
TEST=

Review URL: http://codereview.chromium.org//8933029

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@2564 260f80e4-7a28-3924-810f-c04153c831b5
2011-12-19 09:14:19 +00:00
sgjesse@google.com d7c8c1f1e4 Fix a number of issues with the process handling
1. Ignore the signal SIGPIPE on Linux and Mac OS

When reading from or writing to a closed pipe the signal SIGPIPE
is raised. The default handling of this is to terminate the
program. When signal SIGPIPE is ignored the read and write
returns EPIPE.

2. Wrong return type for stdio getter

3. When there is an error on a socket mark it as closed

4. Mark the pipe used for process exit status as a one way pipe

5. Add tests to test stdin, stdout and stderr in Dart scripts

R=ager@google.com

BUG=dart:536, dart:454
TEST=

Review URL: http://codereview.chromium.org//8662006

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@1793 260f80e4-7a28-3924-810f-c04153c831b5
2011-11-23 14:49:18 +00:00
ager@google.com 5d7ee32c6e Update test scripts to deal with current VM behavior on optional constructor arguments.
Find binaries in tests based on the platform we are running on.

R=sgjesse@google.com
BUG=
TEST=

Review URL: http://codereview.chromium.org//8662004

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@1779 260f80e4-7a28-3924-810f-c04153c831b5
2011-11-23 10:22:48 +00:00
sgjesse@google.com 5950638350 Better handling of stdin/stdout/stderr
When using stdout/stderr it is no longer necessary to explicitly
close the streams for the program to terminate. The automatic
close is handled by always closing the associated receive port
for write only streams when not waiting for any events. If a
close or error handler is installed for stdout/stderr these will
still keep the program alive.

For stdin better handling of the difference between sockets and
pipes have been immplemented. As a special case for stdin when
reading from a terminal the a POLLIN signal with 0 available
bytes is treated as end-of-file. This will trigger when pressing
ctrl-d in a terminal as POLLHUP is not set in that situation.

R=ager@google.com

BUG=
TEST=

Review URL: http://codereview.chromium.org//8533005

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@1507 260f80e4-7a28-3924-810f-c04153c831b5
2011-11-14 14:47:58 +00:00
sgjesse@google.com 841221a47d Merge the two buffer list implementations
R=ager@google.com

BUG=
TEST=

Review URL: http://codereview.chromium.org//8506005

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@1342 260f80e4-7a28-3924-810f-c04153c831b5
2011-11-09 10:52:20 +00:00
sgjesse@google.com 96f822068e Fix build
TBR=ager@google.com

BUG=
TEST=

Review URL: http://codereview.chromium.org//8498005

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@1299 260f80e4-7a28-3924-810f-c04153c831b5
2011-11-08 10:02:44 +00:00
sgjesse@google.com 4a45573956 Change the default for the len argument to writeFrom on OutputStream
Fixed a bug in the writing code as a result.

Also added copyByffer argument to one of the write methods on the OutputStream interface.

R=ager@google.com

BUG=dart:292
TEST=EchoServerStreamTest.dart

Review URL: http://codereview.chromium.org//8493002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@1293 260f80e4-7a28-3924-810f-c04153c831b5
2011-11-08 09:42:20 +00:00
sgjesse@google.com 516d71ab0b Change the handling of closing sockets
Sockets now supports being half-closed for either reading or writing. When a socket is closed it is by default closed for both read and write and the underlying file descriptor is destroyed. However the socket close can be asked to only half-close the socket to send end of stream to the other end and still have the ability to receive more data.

The close event on a socket is only emitted when the socket is closed by the other end. Both half-close and full-close by the other end is reported as a close event. If a socket is already half closed the close event will automatically destroy the socket.

The streams on the sockets also takes advantage of this. A socket input stream will report a close event when the other end closed. A socket output stream will half-close the socket when close is called making it possible to still receive data on the input stream. When both streams have been closed the socket is destroyed.

For sockets operating on pipes they are initially created as half-closed for either reading or writing depending on which type of pipe a socket object is based on. A pipe for writing will start half-closed for reading so if it is only half-closed for writing the socket will still be destroyed. Same with a pipe for reading that will start half-closed for writing and when a close event is received half-closing the other direction will destroy the socket. Socket objects based on pipes are only exposed through streams.

Extended the socket close test to test a number of different scenarios.

Also refactor the socket data C++ object to encapsulate more socket information and operations.

Now the Linux and Mac OS versions are 100% the same as it turned out that using POLLRDHUP on Linux was not required any more.

R=ager@google.com

BUG=
TEST=

Review URL: http://codereview.chromium.org//8437090

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@1196 260f80e4-7a28-3924-810f-c04153c831b5
2011-11-04 12:34:43 +00:00
ager@google.com 362d04f9af Consistently use setters to set event handlers in native APIs.
R=sgjesse@google.com
BUG=
TEST=

Review URL: http://codereview.chromium.org//8386029

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@1083 260f80e4-7a28-3924-810f-c04153c831b5
2011-11-02 12:12:43 +00:00
sgjesse@google.com 18e5ef8da5 New OutputStream interface
R=ager@google.com

BUG=
TEST=

Review URL: http://codereview.chromium.org//8413034

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@997 260f80e4-7a28-3924-810f-c04153c831b5
2011-11-01 10:10:37 +00:00
srdjan@google.com 8d69118676 More strict non-equal cleanups in library code
Review URL: http://codereview.chromium.org//8413018

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@892 260f80e4-7a28-3924-810f-c04153c831b5
2011-10-28 15:21:42 +00:00
srdjan@google.com 959f4b519d Use strict equality when comparing with null, especially when null is a default value.
Review URL: http://codereview.chromium.org//8400038

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@859 260f80e4-7a28-3924-810f-c04153c831b5
2011-10-27 22:11:16 +00:00
sgjesse@google.com 00a00bcdb4 This contains a new InputStream and StringInputStream interfaces.
The readUntil is only supported through readLine on the StringInputStream.

The StringInputStream implementation in string_stream.dart could live outside the VM as it is plain Dart code.

BUG=
TEST=

Review URL: http://codereview.chromium.org//8318009

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@747 260f80e4-7a28-3924-810f-c04153c831b5
2011-10-26 13:17:28 +00:00
sgjesse@google.com 1cd5459f7b Add the ability to run tests with several sets of VM flags
The test-option VMOptions that can be placed in .dart test files can now be specified several times like this:

// VMOptions=
// VMOptions=--short_socket_read
// VMOptions=--short_socket_write
// VMOptions=--short_socket_read --short_socket_write

For each time VMOptions is specified a seperate test will be bun with the specified flags.

Used this to run the tests that uses sockets with short read and writes. Fixed a number of bugs in both stream implementation and in tests revealed by this.

R=iposva@google.com, ngeoffray@google.com

Review URL: http://codereview.chromium.org//8226016

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@388 260f80e4-7a28-3924-810f-c04153c831b5
2011-10-13 10:14:31 +00:00
sgjesse@google.com 6abaad8aa1 Restructured socket tests and fixed readUntil on InputStream
Most of the socket tests where written with closing both the server and client ends of the socket. However on Windows this can lead to errors once in a while (WSAECONNRESET). The tests now closes the socket in the client and and waits for a close event on the server side.

The readUntil on InputStream did not take data in the internal buffer into account. This has been fixed and the related test have been rewritten to check for two patterns which together will match all the input.

R=ager@google.com

BUG=
TEST=

Review URL: https://chromereviews.googleplex.com/3536016

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@126 260f80e4-7a28-3924-810f-c04153c831b5
2011-10-06 14:47:49 +00:00
dgrove@google.com 4c0f559d23 Initial checkin.
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@15 260f80e4-7a28-3924-810f-c04153c831b5
2011-10-05 05:20:07 +00:00