Commit Graph

49 Commits

Author SHA1 Message Date
ajohnsen@google.com 33c74ee3d7 Remove usage of legacy inet_ntop from dart:io.
BUG=https://code.google.com/p/dart/issues/detail?id=13577
R=sgjesse@google.com

Review URL: https://codereview.chromium.org//25411003

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@28090 260f80e4-7a28-3924-810f-c04153c831b5
2013-10-01 11:27:46 +00:00
ajohnsen@google.com d11df78618 Make stdout and stderr async.
This required some minor changes to the Windows eventhandler, as we now spawn a new thread for writes (just like we do for reads).

BUG=https://code.google.com/p/dart/issues/detail?id=7218
R=sgjesse@google.com

Review URL: https://codereview.chromium.org//23609060

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@27811 260f80e4-7a28-3924-810f-c04153c831b5
2013-09-24 11:47:53 +00:00
sgjesse@google.com d1037c4493 Fix bugs in SocketAddress
The formatting of IPv6 strings was wrong on Linux and Mac OS - used
the IPv4 structure.

The fixed socket addresses for any and loopback for IPv6 was mixed up.

R=whesse@google.com
BUG=

Review URL: https://codereview.chromium.org//24269017

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@27703 260f80e4-7a28-3924-810f-c04153c831b5
2013-09-20 12:46:50 +00:00
ajohnsen@google.com 38bae0af02 Add FileSystemWatcher class to dart:io.
BUG=
R=sgjesse@google.com

Review URL: https://codereview.chromium.org//19263003

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@27048 260f80e4-7a28-3924-810f-c04153c831b5
2013-09-03 12:43:08 +00:00
cbracken@google.com a6ace331f3 Replaced strerror() calls with threadsafe strerror_r().
Mac/Android use the XSI-compliant definition of strerror_r() which stores the message in the passed-in buffer.

Linux uses the GNU-specific definition of strerror_r() which takes a buffer and returns the message in a char* (which may or may not be the passed-in buffer).

BUG=
R=iposva@google.com

Review URL: https://codereview.chromium.org//22634003

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@25943 260f80e4-7a28-3924-810f-c04153c831b5
2013-08-08 20:24:05 +00:00
cbracken@google.com 43fae66ebf Fixes to get Dart VM compiling on Ubuntu 13.04, Debian Wheezy.
* Convince gcc 4.7.x that len is initialized before use in callers of ReadFileFully()
* Cast RawObject* to intptr_t to avoid strict-aliasing error on gcc 4.7.x
* Replace two calls to strerror_r() with strerror() on Linux. When _GNU_SOURCE is
  defined to be non-zero (as it is on Dart Linux builds), strerror_r() is
  defined to return a char*, which is the correct error string to use. When
  _GNU_SOURCE is zero, the XSI-compliant definition is used and the error
  message is returned in the char* param. Surrounding error logging uses
  strerror() which solves the problem.
* Replace int literals with char literals in test string definition.
* co19 math/tan_A01_t01 passes on Ubuntu 13.04.

Original issues:
https://code.google.com/p/dart/issues/detail?id=12085
https://code.google.com/p/dart/issues/detail?id=8807

BUG=
R=asiva@google.com

Review URL: https://codereview.chromium.org//22381002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@25890 260f80e4-7a28-3924-810f-c04153c831b5
2013-08-07 17:28:04 +00:00
iposva@google.com 2229450865 - Use TCP_NODELAY when using the coverage tool and ddbg.
- Use IPPROTO_TCP instead of SOL_TCP for increased portability.

R=asiva@google.com, hausner@google.com

Review URL: https://codereview.chromium.org//18829003

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@24865 260f80e4-7a28-3924-810f-c04153c831b5
2013-07-09 21:14:31 +00:00
regis@google.com f3345c2717 Take into account virtual devices (e.g. OpenVPN tun0) when iterating network
interfaces. Their network address is NULL.

Review URL: https://codereview.chromium.org//18268003

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@24858 260f80e4-7a28-3924-810f-c04153c831b5
2013-07-09 18:42:49 +00:00
ajohnsen@google.com 6005ff6a18 Fix comment from earlier commit.
BUG=
R=iposva@google.com

Review URL: https://codereview.chromium.org//18087003

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@24526 260f80e4-7a28-3924-810f-c04153c831b5
2013-06-27 16:45:40 +00:00
iposva@google.com 2d2f1bf4ea - Use VOID_TEMP_FAILURE_RETRY where needed
Review URL: https://codereview.chromium.org//17840009

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@24505 260f80e4-7a28-3924-810f-c04153c831b5
2013-06-27 01:14:12 +00:00
ajohnsen@google.com 7aa0222b5b Avoid picking port 65535 for ServerSockets, when any is requested.
Some browsers block requests to 65535.

BUG=
R=sgjesse@google.com

Review URL: https://codereview.chromium.org//17842003

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@24471 260f80e4-7a28-3924-810f-c04153c831b5
2013-06-26 15:12:56 +00:00
ajohnsen@google.com 3ad9779be6 Add reverse dns lookup as a method on InternetAddress.
BUG=
R=sgjesse@google.com

Review URL: https://codereview.chromium.org//17640008

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@24393 260f80e4-7a28-3924-810f-c04153c831b5
2013-06-25 11:27:48 +00:00
ajohnsen@google.com 63e62f6806 Update mac and android Socket::LookupAddress.
BUG=

Review URL: https://codereview.chromium.org//17341008

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@24269 260f80e4-7a28-3924-810f-c04153c831b5
2013-06-21 08:13:42 +00:00
ajohnsen@google.com 4624420914 Add NetworkAdaptor to dart:io.
NetworkAdaptor contains a static method, list, that will query the
underlaying system for active network adaptors.

BUG=
R=sgjesse@google.com

Review URL: https://codereview.chromium.org//16514010

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@24267 260f80e4-7a28-3924-810f-c04153c831b5
2013-06-21 07:58:48 +00:00
johnmccutchan@google.com 9d264aaee5 Add support for loading scripts from http
R=iposva@google.com

Review URL: https://codereview.chromium.org//15966002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@23351 260f80e4-7a28-3924-810f-c04153c831b5
2013-05-29 14:34:15 +00:00
ajohnsen@google.com 6a78c0c0b8 Add v6Only named argument to ServerSocket and etc.
BUG=
R=sgjesse@google.com

Review URL: https://codereview.chromium.org//14766003

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@22309 260f80e4-7a28-3924-810f-c04153c831b5
2013-05-02 11:23:40 +00:00
smok@google.com ebbc2020a2 Put everything in runtime/bin into '::dart::bin' namespace.
Review URL: https://codereview.chromium.org//14341015

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@22032 260f80e4-7a28-3924-810f-c04153c831b5
2013-04-25 14:22:30 +00:00
sgjesse@google.com d27309942c Fix broken Mac OS socket code
The order of the fields in the sockaddr structures on Mac OS was different and we where relying on the Linux/Windows order of fields. This should now be platform independent.

TBR=ajohnsen@google.com
BUG=

Review URL: https://codereview.chromium.org//14139032

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@21940 260f80e4-7a28-3924-810f-c04153c831b5
2013-04-24 11:51:56 +00:00
ajohnsen@google.com 55963a1a6d Add new InternetAddress class with a static lookup function (including IPv6
results).

Reapply of https://codereview.chromium.org/13880029/ with fixes.

BUG=

Review URL: https://codereview.chromium.org//14469002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@21934 260f80e4-7a28-3924-810f-c04153c831b5
2013-04-24 09:26:58 +00:00
ajohnsen@google.com 60946b53fc Revert "Add new InternetAddress class with a static lookup function (including IPv6 results)."
Revert "Attempt to fix strict align issue."
Revert "Trying another fix."

BUG=

Review URL: https://codereview.chromium.org//14036017

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@21928 260f80e4-7a28-3924-810f-c04153c831b5
2013-04-24 08:10:00 +00:00
ajohnsen@google.com 20d1f5ddda Add new InternetAddress class with a static lookup function (including IPv6 results).
Reapply of https://codereview.chromium.org/14083007/ with fixes.

BUG=

Review URL: https://codereview.chromium.org//13880029

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@21923 260f80e4-7a28-3924-810f-c04153c831b5
2013-04-24 07:12:05 +00:00
sgjesse@google.com afcb3ce69e Revert "Add new InternetAddress class with a static lookup function (including IPv6 results)"
TBR=ajohnsen@google.com

Review URL: https://codereview.chromium.org//14081024

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@21865 260f80e4-7a28-3924-810f-c04153c831b5
2013-04-23 10:07:03 +00:00
sgjesse@google.com 042dbc4793 Anoher try to avoid GCC strict-aliasing error
TBR=ajohnsen@google.com
BUG=

Review URL: https://codereview.chromium.org//14426004

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@21864 260f80e4-7a28-3924-810f-c04153c831b5
2013-04-23 10:02:01 +00:00
sgjesse@google.com 6b4d9bfb80 Try to avoid GCC strict-aliasing error
TBR=ajohnsen@google.com
BUG=

Review URL: https://codereview.chromium.org//13856013

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@21863 260f80e4-7a28-3924-810f-c04153c831b5
2013-04-23 09:51:32 +00:00
ajohnsen@google.com b33d142414 Add new InternetAddress class with a static lookup function (including IPv6 results).
Socket.connect/ServerSocket.bind now accepts IPv6 host names. If a new ServerSocket is connected to an IPv6 interface, it will (if possible) support incoming IPv4 connections as well.

BUG=

Review URL: https://codereview.chromium.org//14083007

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@21862 260f80e4-7a28-3924-810f-c04153c831b5
2013-04-23 09:36:18 +00:00
sgjesse@google.com e40ce105af Fix a number of issues with determining the type of stdio
* Fix checked mode exception when _getSocketType returns an OSError
 * Treat any character device as terminal (this includes /dev/null)
 * Fix detecting of file redirection af file
 * Don't turn an unkonwn device type into an OSError (wth value for an unknown was -1)

Expanded an existing test to catch some of this.

R=ager@google.com

BUG=https://code.google.com/p/dart/issues/detail?id=9637

Review URL: https://codereview.chromium.org//13636003

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@20960 260f80e4-7a28-3924-810f-c04153c831b5
2013-04-05 11:13:24 +00:00
ajohnsen@google.com fb53f40e65 Add setOption method on Socket/RawSocket.
This will allow the user to enable TCP_NODELAY on the native sockets.

BUG=

Review URL: https://codereview.chromium.org//12614014

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@20014 260f80e4-7a28-3924-810f-c04153c831b5
2013-03-14 12:46:54 +00:00
tball@google.com ca8b23183b Added Socket::SetBlocking() and Socket::SetNonBlocking().
Review URL: https://codereview.chromium.org//12380032

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@19334 260f80e4-7a28-3924-810f-c04153c831b5
2013-03-01 18:33:17 +00:00
sgjesse@google.com 488b016a2f Merge IO v2 branch to bleeding edge
R=ager@google.com, ajohnsen@google.com, whesse@google.com

BUG=

Review URL: https://codereview.chromium.org//12316036

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@18820 260f80e4-7a28-3924-810f-c04153c831b5
2013-02-21 11:58:11 +00:00
iposva@google.com 9046a44a37 Prepare for removal of source_filter.gypi:
- Guard OS-dependent source files with #if TARGET_OS_* in a similar
  fashion to the architecture dependent sources.
Review URL: https://codereview.chromium.org//12282051

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@18786 260f80e4-7a28-3924-810f-c04153c831b5
2013-02-20 21:17:38 +00:00
tball@google.com 898ec7731f Added Socket::Close() function.
Review URL: https://codereview.chromium.org//12209047

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@18199 260f80e4-7a28-3924-810f-c04153c831b5
2013-02-07 00:44:55 +00:00
sgjesse@google.com 800b4b6c37 Add function for finding what a InputStream or OutputStream is attached to
For the dart:io types InputStream and OutputStream the top level
function stdioType will return whether the stream is attached to a
terminal, pipe, file or something else.

BUG=dart:2789

R=ager@google.com

Review URL: https://codereview.chromium.org//11773041

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@16839 260f80e4-7a28-3924-810f-c04153c831b5
2013-01-09 09:17:07 +00:00
gram@google.com 3601944836 Revised CL for customisable logging (replacing printfs).
Review URL: https://codereview.chromium.org//11312242

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@15096 260f80e4-7a28-3924-810f-c04153c831b5
2012-11-19 17:38:15 +00:00
kustermann@google.com 6d1cda397c Added FD_CLOEXEC flag to client/server socket file descriptors
Without the FD_CLOEXEC, all subprocesses will inherit the open socket
file descriptors of the current process due to the default behavior
of fork()+exec().

Review URL: https://codereview.chromium.org//11416006

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@14952 260f80e4-7a28-3924-810f-c04153c831b5
2012-11-15 11:27:33 +00:00
sgjesse@google.com c304bb491e Use the thread safe gethostbyname function on Linux
On Mac OS and Windows gethostbyname is already thread safe (according
to the documentation).

R=ager@google.com

BUG=

Review URL: https://codereview.chromium.org//11262006

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@14010 260f80e4-7a28-3924-810f-c04153c831b5
2012-10-24 11:38:02 +00:00
jackpal@google.com 5ef2b814bd Don't use TEMP_FAILURE_RETRY macro with inet_addr
inet_addr is not a syscall, therefore it should not be used with the
TEMP_FAILURE_RETRY macro.

This fixes a warning in the Android build.

Review URL: https://codereview.chromium.org//10907248

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@12447 260f80e4-7a28-3924-810f-c04153c831b5
2012-09-17 18:48:33 +00:00
ajohnsen@google.com 0c17bf126c Throw an error if the ServerSocket host argument is invalid.
BUG=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@11769 260f80e4-7a28-3924-810f-c04153c831b5
2012-09-03 14:39:47 +00:00
asiva@google.com 2393f17f1a Fix win32 Socket test errors
SocketInfoTest and SocketPortTest are failing on windows.
Review URL: https://chromiumcodereview.appspot.com//10014037

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@6390 260f80e4-7a28-3924-810f-c04153c831b5
2012-04-10 23:29:02 +00:00
ajohnsen@google.com 4ecf48b601 Add remoteHost to Socket.
This is merging the native calls into one, GetRemotePeer, thus
eliminating a potentiel extra call to getpeername.

BUG=
TEST=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@6353 260f80e4-7a28-3924-810f-c04153c831b5
2012-04-10 12:18:12 +00:00
ajohnsen@google.com 1dd508bd44 Add remotePort getter to Socket.
Review URL: https://chromiumcodereview.appspot.com//9963053

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@6090 260f80e4-7a28-3924-810f-c04153c831b5
2012-04-02 13:54:03 +00:00
ager@google.com 1ffc9b84a2 Treat EAGAIN/EWOULDBLOCK as requests for retry on socket accept.
On Linux there are a number of protocol errors that can be
returned from accept. According to the linux man pages they
should be treated as EAGAIN.

This should hopefully fix the flakiness of EchoServerStreamTest.

R=iposva@google.com,sgjesse@google.com
BUG=2262
TEST=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@5797 260f80e4-7a28-3924-810f-c04153c831b5
2012-03-23 22:39:27 +00:00
sgjesse@google.com 0b3f4a1190 Extend dart:io error handling to all socket functions
There are currently no tests of the error handling, as it is hard to
create consistent tests. I have done some manual tests locally:

* Lowering the number of file descriptors available (ulimit -n) and hitting that limit
* Running two dart programs communicating and terminating one (using Ctrl-C)
* Running two dart programs communicating on two machines and pulling out the network cable.

If there is an error we always call the onError callback and never the onClosed callback.

On Windows there is the issue that both closing the connection correctly and terminating one end gives the same error (ERROR_NETNAME_DELETED) so both are reported as connection close. Pulling out the network cable gives a different (real) error on Windows though.

On Mac OS it turned out the for kqueue EV_EOF is also used to indicate errors with the error code set in the fflags field. EV_ERROR is only reported if there is an internal error in  kevent processing (see http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man2/kqueue.2.html).

R=ager@google.com

BUG=
TEST=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@5709 260f80e4-7a28-3924-810f-c04153c831b5
2012-03-21 09:39:47 +00:00
sgjesse@google.com 168ae8c785 Start better error reporting for sockets
Changed the onError callback for sockets to take an exception argument.

First area to report errors for is name resolution.

Changed the IP address resolution from being synchronous with the
creation of the socket to being asynchronous thsough a lookup
service running on a native port. Currently this lookup service
is static on the socket class as we need to call it from a
factory method. We should probably add a separate name lookup
service at some point.

R=ager@google.com

BUG=
TEST=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@5640 260f80e4-7a28-3924-810f-c04153c831b5
2012-03-19 11:26:41 +00:00
sgjesse@google.com 0122a33a76 Handle EINTR on all IO operations
There have been spurious FileIOExceptions seen on some Mac OS machines.

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

BUG=
TEST=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@3185 260f80e4-7a28-3924-810f-c04153c831b5
2012-01-11 15:12:27 +00:00
ager@google.com 946b015d0a Fix memory leak in MacOS process handling.
Report error for failing writes. We used to enter a poll loop
because we kept on attempting to write.

Currently the error handling in the socket interface is inconsistent.
We have a big TODO item on general error handling including the socket
interface.

R=sgjesse@google.com
BUG=
TEST=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@1887 260f80e4-7a28-3924-810f-c04153c831b5
2011-11-29 10:10:07 +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
sgjesse@google.com 04bc611751 Handle stdin/stdout/stderr on Windows
Create handle objects for stdin/stdout/stderr. For Mac OS and
Linus the file descriptor numbers are used but on Windows the
handles are wrapped in an object.

The system handles for stdin/stdout/stderr on Windows does not
support overlapped IO. To mittigate this the write calls are
performed synchronously and the read calls are preformed in a
thread which posts the result through the completion potr where
it is handled as if it originated from overlapped IO through the
completion port. For now each call to read starts a new thread.

R=ager@google.com

BUG=
TEST=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@1533 260f80e4-7a28-3924-810f-c04153c831b5
2011-11-15 13:19:07 +00:00
ager@google.com 86284155b9 Improve error handling in the process library.
Verify that the arguments have the types expected by the
implementation. Require a List instance containing builtin
Strings as the arguments. Require a builtin String path.

R=sgjesse@google.com
BUG=
TEST=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@690 260f80e4-7a28-3924-810f-c04153c831b5
2011-10-25 12:16:04 +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