Commit Graph

144 Commits

Author SHA1 Message Date
Søren Gjesse 65872873d2 Remove server socket references
The use of server socket references was deprecated in 1.9 and marked
for removal in 1.10.

R=kustermann@google.com

BUG=http://dartbug.com/22187

Review URL: https://codereview.chromium.org/1072783003 .
2015-10-05 12:25:20 +02:00
Rico Wind c6918fb126 Refactor the io resource classes
Move stopwatch so that we will only ever need one instance

Add utility functions for doing reads and writes

The only functional change here is that I say that an except is a read
of one byte, which also updates the readcount. I think this is just as
correct as what we did before.

BUG=
R=sgjesse@google.com

Review URL: https://codereview.chromium.org//1320023008 .
2015-09-09 09:18:07 +02:00
Rico Wind 06ab2bdbdd Extract meta data about open sockets into separate class.
The current implementation only has information about tcp and udp
sockets, and we explicitly do not track internal and pipe uses of
_NativeSockets.

The testing of this is done through the service layer, which is the end user of
this.

BUG=
R=sgjesse@google.com

Committed: https://github.com/dart-lang/sdk/commit/01eff8ce18be7eceb6ce0be1097005965edf2588

Review URL: https://codereview.chromium.org//1323943003 .
2015-09-03 19:18:42 +02:00
Rico Wind 665f397bb8 Revert "Extract meta data about open sockets into separate class."
This reverts commit 01eff8ce18.

Seeing issues on windows and on dart2js

R=sgjesse@google.com
BUG=

Review URL: https://codereview.chromium.org//1323183002 .
2015-09-02 16:18:52 +02:00
Rico Wind 01eff8ce18 Extract meta data about open sockets into separate class.
The current implementation only has information about tcp and udp
sockets, and we explicitly do not track internal and pipe uses of
_NativeSockets.

The testing of this is done through the service layer, which is the end user of
this.

BUG=
R=sgjesse@google.com

Review URL: https://codereview.chromium.org//1323943003 .
2015-09-02 15:26:35 +02:00
sgjesse@google.com 48584debbd Make Socket address and port getters available after the socket is closed
There getters are used for generating eddor messages.

TBR=ajohnsen@google.com
BUG=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@44359 260f80e4-7a28-3924-810f-c04153c831b5
2015-03-10 08:54:22 +00:00
sgjesse@google.com 1d808d071b Fixed a number of bugs on RawSocket and Socket
The checking of the closed state was not present when dealing
with the properties port, remotePort, address and remoteAddress
on RawSocket and Socket. Then now all throw SocketException when
the RawSocket or Socket is closed.

* Calling port on a RawSocket would return the port even if it
  was closed

* Calling remotePort, address and remoteAddress did not check for
  OSError

* Calling remotePort, address and remoteAddress on a closed
  RawSocket caused syscalls using the already closed fd, which
  might also have been re-allocated already.

* Calling port, remotePort, address and remoteAddress on a closed
  Socket caused null pointer exception

R=ajohnsen@google.com

Correctly check for errors when getting remote address and port

BUG=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@44319 260f80e4-7a28-3924-810f-c04153c831b5
2015-03-09 13:33:28 +00:00
whesse@google.com 1d928984a3 Recommit "Fix issues with Socket shutdown.""
This recommits revision r44178, which was reverted in r44180, with changes to
fix the issues with Process.stdin.  It also adds a test for issue 22636, duplicate READ_CLOSED message.

Changes from r44187
Test tests/standalone/io/issue_22636_test.dart added.
Line "native.closedReadEventSent = true;" added to _RawSocket._writePipe() in runtime/bin/socket_patch.dart.

BUG=http://dartbug.com/22636
BUG=http://dartbug.com/22637
R=sgjesse@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@44236 260f80e4-7a28-3924-810f-c04153c831b5
2015-03-04 14:37:34 +00:00
whesse@google.com bbfd19ca02 Revert "Fix issues with Socket shutdown."
This reverts commit r44178, because it makes 10 tests about process stderr
and stdin fail with timeouts.
Original CL: https://codereview.chromium.org/975723002/

BUG=dartbug.com/22637
BUG=dartbug.com/22636
R=kustermann@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@44180 260f80e4-7a28-3924-810f-c04153c831b5
2015-03-03 16:51:57 +00:00
whesse@google.com 7d15c8182a Fix issues with Socket shutdown.
BUG=dartbug.com/22637
BUG=dartbug.com/22636

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@44178 260f80e4-7a28-3924-810f-c04153c831b5
2015-03-03 16:19:23 +00:00
kustermann@google.com 615d1a01ac Reland "Introduce optional 'bool shared' parameter to ServerSocket.bind() ..."
R=sgjesse@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@43678 260f80e4-7a28-3924-810f-c04153c831b5
2015-02-11 10:01:20 +00:00
sgjesse@google.com 7b7ac3620a Add support to specify the source address for socket connect
BUG=http://dartbug.com/22253
R=kustermann@google.com, lrn@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@43638 260f80e4-7a28-3924-810f-c04153c831b5
2015-02-10 11:56:51 +00:00
kustermann@google.com 3ea331e741 Introduce a kSetEventMaskCommand, some cleanups in windows eventhandler
R=sgjesse@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@43547 260f80e4-7a28-3924-810f-c04153c831b5
2015-02-06 09:36:57 +00:00
kustermann@google.com 1d6231bacd Revert "Introduce optional 'bool shared' parameter to ServerSocket.bind() ..."
Review URL: https://codereview.chromium.org//896213002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@43476 260f80e4-7a28-3924-810f-c04153c831b5
2015-02-04 16:00:21 +00:00
kustermann@google.com 3c6c29fee9 Introduce optional 'bool shared' parameter to ServerSocket.bind() ...
R=sgjesse@google.com, wibling@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@43467 260f80e4-7a28-3924-810f-c04153c831b5
2015-02-04 13:41:41 +00:00
rmacnak@google.com 2fb0bb020b Reapply "Mark all private functions in dart: libraries as invisible (*sniff*). Previously these functions were only marked invisible if they were also native, a constructor, or on a black list."
Broken assumption in Dartium fixed in blink r188698.

R=hausner@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@43053 260f80e4-7a28-3924-810f-c04153c831b5
2015-01-21 20:44:04 +00:00
rmacnak@google.com ed88ac7f0c Revert "Mark all private functions in dart: libraries as invisible (*sniff*). Previously these functions were only marked invisible if they were also native, a constructor, or on a black list."
Broke Dartium.

TBR=hausner@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@43026 260f80e4-7a28-3924-810f-c04153c831b5
2015-01-20 20:56:59 +00:00
rmacnak@google.com 045bd762d7 Mark all private functions in dart: libraries as invisible (*sniff*). Previously these functions were only marked invisible if they were also native, a constructor, or on a black list.
An invisible function is hidden from stack traces, will not be enumerated
by mirrors, and cannot be directly invoked by mirrors. Note that private
classes remain accessible.

Fix a few internal dart:io functions that should be private.

Fix bug where mirrors would enumerate top-level invisible functions.

Mark observatory test that was using such private functions through
mirrors as failing.

BUG=http://dartbug.com/15274
R=hausner@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@43019 260f80e4-7a28-3924-810f-c04153c831b5
2015-01-20 18:32:19 +00:00
kustermann@google.com 360dfe4f41 Several bugfixes in dart:io's handing of sockets
This CL includes fixes for the following issues:

a) The event handler created listening socket metadata (values of a hashtable
indexed by filedescriptor) sometimes as SocketData and sometimes as
ListeningSocketData depending whether the socket has been listened to or not.
This was very buggy, in particular because multiple isolates can have a
reference to the same server socket in different states (opened, listened,
closed).

=> This should be fixed by sending the file descriptior typeMask always to the
   eventhandler.

b) A server socket cloned via the ServerSocketReference mechanism, opens a
receive port for sending (fd, address, port) to isolates/... which want to
create a server socket from the reference.
This receive port was not closed properly when calling only close() (and not
listening first).

=> This should be fixed by closing this receiveport on the ServerSocket.close()
   call as well.

c) It was assumed in the event handler that a close command needs to have the
Dart_Port in a hash table. But this is only the case if the user actually
listened to the ServerSocket. Otherwise the event handler does not know about
the server socket. This caused a NULL dereference which resulted in a SEGFAULT.

=> This should be fixed by checking if the Dart_Port is in the hashmap of the
ListeningSocketData or not.

d) Too many bits were considered when extracting token count in C++ code.

The CL includes a regression test which should trigger these issues.

BUG=21384,21383
R=sgjesse@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41276 260f80e4-7a28-3924-810f-c04153c831b5
2014-10-24 08:55:50 +00:00
ajohnsen@google.com 1e731cf3e5 Don't create unused OSError in Socket_Available.
BUG=
R=iposva@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41005 260f80e4-7a28-3924-810f-c04153c831b5
2014-10-09 06:21:21 +00:00
ajohnsen@google.com 9dd4df6f9a Fix datagram issue where available is not correctly updated upon receive.
BUG=
R=sgjesse@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@40235 260f80e4-7a28-3924-810f-c04153c831b5
2014-09-15 08:21:44 +00:00
ajohnsen@google.com 7ea3f05253 Clean up socket:connect change.
BUG=
R=sgjesse@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@38918 260f80e4-7a28-3924-810f-c04153c831b5
2014-08-06 05:10:44 +00:00
ajohnsen@google.com 1984326985 In Socket:connect, start connecting to next address, after 250 (25 for loopback).
BUG=https://code.google.com/p/dart/issues/detail?id=19871
R=whesse@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@38662 260f80e4-7a28-3924-810f-c04153c831b5
2014-07-29 11:26:49 +00:00
asiva@google.com a2d7a425c9 - Remove Dart_ReceivePortGetId, Dart_GetReceivePort and Dart_PostMessage.
- Change _EventHandler._sendData to use a sendport object instead of a
  receiveport object.

R=iposva@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@37827 260f80e4-7a28-3924-810f-c04153c831b5
2014-06-30 17:46:26 +00:00
ajohnsen@google.com 8719f3834b Add Observatory test of io.
Initially a single test of a HttpServer. More will follow.

This also fixes the case where we don't 'block' when binding to a
ServerSocket. We should not close until the socket is explicitly closed.

BUG=
R=johnmccutchan@google.com, sgjesse@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@37164 260f80e4-7a28-3924-810f-c04153c831b5
2014-06-10 07:13:52 +00:00
ajohnsen@google.com 8b612e8780 Add read/write stats to Socket and RandomAccessFile.
BUG=
R=johnmccutchan@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@36738 260f80e4-7a28-3924-810f-c04153c831b5
2014-05-28 13:29:51 +00:00
johnmccutchan@google.com f5d6c4106e Fix test breakage in socket_patch.dart
Review URL: https://codereview.chromium.org//307553008

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@36736 260f80e4-7a28-3924-810f-c04153c831b5
2014-05-28 11:45:29 +00:00
johnmccutchan@google.com e46aa81943 Create a ServiceObject for a socket
R=ajohnsen@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@36735 260f80e4-7a28-3924-810f-c04153c831b5
2014-05-28 11:25:12 +00:00
johnmccutchan@google.com 1f62dad54d Add Proces owner of socket and fix printing of non-network sockets
R=ajohnsen@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@36729 260f80e4-7a28-3924-810f-c04153c831b5
2014-05-28 07:15:02 +00:00
ajohnsen@google.com 9c7979ed1f Add 'owner' field to sockets, that point to a potential IO resource using that Socket.
BUG=
R=johnmccutchan@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@36680 260f80e4-7a28-3924-810f-c04153c831b5
2014-05-27 14:10:31 +00:00
ajohnsen@google.com 217e8b8605 Add WebSockets to Observatory.
BUG=
R=johnmccutchan@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@36667 260f80e4-7a28-3924-810f-c04153c831b5
2014-05-27 11:37:51 +00:00
ajohnsen@google.com 3218f34433 Add 'Sockets' to observatory.
BUG=
R=johnmccutchan@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@36650 260f80e4-7a28-3924-810f-c04153c831b5
2014-05-27 07:49:47 +00:00
ajohnsen@google.com 44d8df4bb4 Add Socket ref to HttpServer.
BUG=
R=johnmccutchan@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@36644 260f80e4-7a28-3924-810f-c04153c831b5
2014-05-27 06:38:15 +00:00
ajohnsen@google.com c7a15b7c2b Add support for cloning server-sockets.
BUG=
R=lrn@google.com, sgjesse@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@35818 260f80e4-7a28-3924-810f-c04153c831b5
2014-05-06 19:09:44 +00:00
ajohnsen@google.com 82d1382faa Fix crash in raw_secure_server_socket_test.
We had a scenario where read&write events were requested after the socket was closed, leading to a use-after-free.

This also fixes a scenario where we didn't delete client sockets, when accepted sockets are ignored when closing a listening socket.

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

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@35732 260f80e4-7a28-3924-810f-c04153c831b5
2014-05-05 09:17:26 +00:00
ajohnsen@google.com deccfaf042 Make Socket::connect try all addresses given.
BUG=
R=sgjesse@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@35619 260f80e4-7a28-3924-810f-c04153c831b5
2014-05-01 08:42:57 +00:00
ajohnsen@google.com 8f41c24471 Make server-sockets level triggered.
BUG=
R=sgjesse@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@35302 260f80e4-7a28-3924-810f-c04153c831b5
2014-04-23 06:05:46 +00:00
ajohnsen@google.com 94f53d4d2b Fix *ServerSocket's handling of zones.
A stream's zone is the one it has when listening to. Use that, and not
the one active when creating the socket.

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

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@35071 260f80e4-7a28-3924-810f-c04153c831b5
2014-04-15 18:44:14 +00:00
ajohnsen@google.com 1a8f76beb3 Only return eventhandler tokens in stacks of 8, to avoid runtime calls.
BUG=
R=sgjesse@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@34359 260f80e4-7a28-3924-810f-c04153c831b5
2014-03-25 13:44:01 +00:00
ajohnsen@google.com 4cf3726fe6 Close(destroy) Socket on user-generated write error.
BUG=
R=sgjesse@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@34109 260f80e4-7a28-3924-810f-c04153c831b5
2014-03-19 09:23:17 +00:00
ajohnsen@google.com 0c157cd31e Move signal_blocker to platform and use it by default in TEMP_FAILURE_RETRY.
BUG=http://code.google.com/p/dart/issues/detail?id=16927
R=johnmccutchan@google.com, sgjesse@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@33745 260f80e4-7a28-3924-810f-c04153c831b5
2014-03-17 13:51:11 +00:00
ajohnsen@google.com 9a71498127 Make the event-handler handle backpreasure.
We now limit the number of active events per fd to 8.

BUG=
R=whesse@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@33649 260f80e4-7a28-3924-810f-c04153c831b5
2014-03-13 12:02:47 +00:00
sgjesse@google.com 1e3e88769f Socket I/O statistics for Observatory
This is the first part of adding I/O statistics to the observatory.

R=ajohnsen@google.com, johnmccutchan@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@33366 260f80e4-7a28-3924-810f-c04153c831b5
2014-03-06 11:12:08 +00:00
ajohnsen@google.com ce266f9435 Merge all http-outgoing transfomers into _HttpOutgoing, including simpler(better) buffering.
This speeds up the system by:
- Using a simpler buffering mechanism, where we fill up a 8kb buffer, pass it on, and allocating a new.
- Avoiding up to 4 streams for each stream added to the http-outgoing. We now only create one extra stream.

BUG=
R=sgjesse@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@33272 260f80e4-7a28-3924-810f-c04153c831b5
2014-03-04 13:58:46 +00:00
ajohnsen@google.com fc5af7b7b4 Add InternetAddress:rawAddress, to return the raw address as a list of bytes.
BUG=https://code.google.com/p/dart/issues/detail?id=17137
R=sgjesse@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@33235 260f80e4-7a28-3924-810f-c04153c831b5
2014-03-03 18:33:56 +00:00
ajohnsen@google.com 9635777fe0 Don't try to call read, if len i 0.
Also fix a Socket_Read to handle -1 from read.

BUG=
R=sgjesse@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@32849 260f80e4-7a28-3924-810f-c04153c831b5
2014-02-20 12:23:20 +00:00
ajohnsen@google.com 140fddd06e Make event-handlers edge-triggered and move socket-state to Dart.
This eliminates to pause/resume calls made in the previous one-shot based model.

BUG=
R=sgjesse@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@32780 260f80e4-7a28-3924-810f-c04153c831b5
2014-02-19 09:44:26 +00:00
ajohnsen@google.com 0f52be7f63 Make std* blocking file-descriptors.
This will most likely be a performance regression when piping, that
we'll have to look into in the future (copying data through
    message-passing).

BUG=
R=sgjesse@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@32715 260f80e4-7a28-3924-810f-c04153c831b5
2014-02-17 10:06:35 +00:00
ajohnsen@google.com 7e49953c19 Avoid over-use of futures in socket.
BUG=
R=sgjesse@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@32571 260f80e4-7a28-3924-810f-c04153c831b5
2014-02-11 19:14:05 +00:00
ajohnsen@google.com 5558bb0d1f Fix most UDP issues on Mac OS
We still do not test getting SO_BROADCAST, as it (at least on my laptop)
returns false even if it has just been turned on.

Setting SO_REUSEADDR for datagram sockets also behaves differently
compared to Linux and Windows.

IPv6 multicast as I could not test it on my laptop.

R=ajohnsen@google.com
BUG=http://dartbug.com/1975

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@31223 260f80e4-7a28-3924-810f-c04153c831b5
2013-12-18 12:23:40 +00:00