Commit Graph

106 Commits

Author SHA1 Message Date
Zachary Anderson 747868f2b1 [dart:io] Remove DART_IO_DISABLED
This was only used by Dartium.

Review-Url: https://codereview.chromium.org/3009523002 .
2017-08-24 11:17:52 -07:00
Zachary Anderson 6cd8a79078 VM: Re-format to use at most one newline between functions
R=asiva@google.com

Review-Url: https://codereview.chromium.org/2974233002 .
2017-07-13 08:08:37 -07:00
Ben Konyi ddc4f30d75 Re-land socket refactor with fixes for Windows.
BUG=
R=zra@google.com

Review-Url: https://codereview.chromium.org/2797993005 .
2017-04-05 12:45:31 -07:00
Zachary Anderson 8c9c54d833 [dart:io] Don't close stdin with a socket finalizer
If an Isolate touches the 'stdio' getter, a _NativeSocket with
attached finalizer is created for it. Previously, when such an
Isolate exited, the finalizer would close the underlying
file descriptor. This CL changes the finalizer for stdin such
that the native objects will be cleaned up, but the underlying
file descriptor will not be closed. The underlying file
descriptor will now only be closed if the stdin stream
subscription is explicitly canceled.

Accessing the stdin getter after the stream is explicitly
canceled will result in a FileSystemException.

See also: https://github.com/dart-lang/test/issues/583

fixes #29229

R=rmacnak@google.com

Review-Url: https://codereview.chromium.org/2791423002 .
2017-04-04 13:57:42 -07:00
Zachary Anderson 89dba57bcf [dart:io] Adds a finalizer to _NativeSocket to avoid socket leaks
The finalizer sends the "close" message to the EventHandler for the
file descriptor in the _NativeSocket's native field. To avoid races and
spurious messages, this CL stores a pointer to a wrapper object in the
native field instead of the file descriptor. All messsages about the
_NativeSocket sent to the EventHandler use the wrapper object instead of
the file descriptor. When the EventHandler closes the file, the file
descriptor in the wrapper object is set to -1 so that the finalizer will
instead do nothing.

On Windows, there is another level of indirection since the OS HANDLEs
were already wrapped in various kinds of Handle objects. As an additional
complication, ClientSocket close on Windows is asynchronous, so the
EventHandler may shutdown before all of the ClientSocket Handles can be
destroyed.

related #27898, #28081

R=johnmccutchan@google.com

Review-Url: https://codereview.chromium.org/2760293002 .
2017-03-28 07:44:05 -07:00
Ryan Macnak 877284947b Rename TARGET_OS_* to HOST_OS_*.
Like HOST_ARCH_*, HOST_OS_* describes the OS the VM is running on, which may be different from the OS the VM is generating code for during AOT compilation.

Currently we conflate the two when emitting AOT as assembly, and we get away with it because Flutter only uses assembly for targeting iOS and one can only target iOS from a Mac, but we expect to use assembly for Android as well so native tools can unwind Dart frames.

R=zra@google.com

Review-Url: https://codereview.chromium.org/2750843003 .
2017-03-15 13:11:05 -07:00
Florian Schneider 5c75e37ae4 Fix potential unprotected use of handle in Windows event handler.
The lock should be held across the use of handle_.

Attempt to resolve #28523.

R=rmacnak@google.com

Review-Url: https://codereview.chromium.org/2664073002 .
2017-01-30 18:18:09 -08:00
Florian Schneider c1e4e8ef72 Fix Windows debug assertion when cancelling pending i/o
When no pending i/o requests are found, CancelIoEx returns ERROR_NOT_FOUND.

This is ok, since there is nothing else to do before closing the handle.

Related to #22940.

TBR=zra@google.com

Review-Url: https://codereview.chromium.org/2651033004 .
2017-01-24 17:33:51 -08:00
Florian Schneider 2e1eeaf446 Cancel pending i/o when closing stdin on Windows
When cancelling a subscription to stdin, there may be pending I/O operation
that need to be explicitly cancelled before closing the stdin handle.

Otherwise the program would sit waiting for input (until CR is pressed).

Fixes dart-lang/pub#1502
Fixes #22940

R=zra@google.com

Review-Url: https://codereview.chromium.org/2650063003 .
2017-01-24 14:47:39 -08:00
Zachary Anderson 479a97b129 clang-format runtime/bin
R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org/2480793002 .
2016-11-04 12:30:56 -07:00
Zach Anderson 18ec8dddd9 Add back join of windows eventhandler threads
These threads are polluting the exit code despite using the better
ExitProcess call. Instead of adding back Thread::Join, I've instead
inlined the call into the eventhandler to make it easier to be sure
the open handles are closed.

R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org/1989463003 .
2016-05-17 14:53:54 -07:00
Zach Anderson 5f59a954f8 Uses an open thread handle as the ThreadJoinId on Windows.
Also:
- Reaps exited threads in the thread pool before putting
a thread on the idle list so that a new arriving task
isn't blocked on a supposedly idle thread in the middle
of a join.
- Stops trying to join eventhandler threads on
Windows. Now that we're using the correct exit() call,
we probably don't have to worry about exit code pollution,
so joining the threads is unnecessary.

related #26400

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

Review URL: https://codereview.chromium.org/1978153002 .
2016-05-17 13:18:13 -07:00
Zachary Anderson 7308e58c3f Really remove io support when dart:io is unsupported.
Previously we would compile in implementaitions of native calls for
IO functions that would never be used. This CL provides implementations
that throw a Dart exception if they're called by mistake. It also uses
a DART_IO_DISABLED preprocessor define to clean up the build files and
check that we're not including code we shouldn't.

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

Review URL: https://codereview.chromium.org/1839463002 .
2016-03-29 11:22:03 -07:00
Zachary Anderson 45661a7091 Cleanup in //runtime/bin
R=iposva@google.com

Review URL: https://codereview.chromium.org/1800863002 .
2016-03-16 10:01:00 -07:00
Ryan Macnak 9387fead15 Use a monotonic clock in the implementation of Timer.
Ask the embedder for the current time, since it is the embedder who later compares the deadline with current time when deciding when to send a wake up message.

BUG=http://dartbug.com/25055
BUG=http://dartbug.com/25216
R=iposva@google.com, zra@google.com

Review URL: https://codereview.chromium.org/1519563003 .
2015-12-11 12:39:56 -08:00
Soren Gjesse 33e2d9cd7e Increase the datagram receive buffer on Windows to 64k
A datagram can can be up to 64k, and if the buffer is too small the received data is truncated.

This change also correctly handles errors when receiving datagrams on Windows.

BUG= #24426
R=kustermann@google.com, iposva@google.com

Review URL: https://codereview.chromium.org/1381233003.
2015-10-06 08:42:51 +02:00
Zachary Anderson 9395a5b86f Join embedder threads on Windows.
BUG=
R=sgjesse@google.com

Review URL: https://codereview.chromium.org//1291163002 .
2015-09-01 17:53:03 -07:00
John McCutchan 864f9a3c9b Cap the number of pending accepts on Windows
BUG=
R=sgjesse@google.com

Review URL: https://codereview.chromium.org//1151753008
2015-06-01 06:38:22 -07:00
kustermann@google.com e06874c751 Fix potential use-after-free bug in windows eventhandler
R=sgjesse@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@43725 260f80e4-7a28-3924-810f-c04153c831b5
2015-02-12 13:47:45 +00:00
kustermann@google.com 70ca358a33 Send destroy events for each closed listening socket instead of waiting for all listening sockets to be done
R=sgjesse@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@43680 260f80e4-7a28-3924-810f-c04153c831b5
2015-02-11 11:34:47 +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
kustermann@google.com 700bea9f78 Parenthesize expression using bit-wise and on windows
R=sgjesse@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@43640 260f80e4-7a28-3924-810f-c04153c831b5
2015-02-10 12:17:54 +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 74c0f65c89 Implement windows support for having multiple Dart_Port's registered on one OS socket
R=sgjesse@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@43631 260f80e4-7a28-3924-810f-c04153c831b5
2015-02-10 10:08:49 +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 a7f50cd5d2 Move CircularLinkedList to eventhandler.h
Move constants and InterruptMessage to eventhandler.h

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@43524 260f80e4-7a28-3924-810f-c04153c831b5
2015-02-05 21:45:47 +00:00
kustermann@google.com cae03aaf1a Wait for eventhandler to shut down before exiting
R=sgjesse@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@43504 260f80e4-7a28-3924-810f-c04153c831b5
2015-02-05 13:16:07 +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
johnmccutchan@google.com 93e840e859 Fix compilation warnings in Windows event handler
BUG=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@42649 260f80e4-7a28-3924-810f-c04153c831b5
2015-01-06 22:51:00 +00:00
iposva@google.com 5a383e7add - Make sure that the threads for dart::bin are in the correct namespace.
R=asiva@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@39233 260f80e4-7a28-3924-810f-c04153c831b5
2014-08-14 00:06:04 +00:00
iposva@google.com 58cf8abfd3 - MutexLocker needed by eventhandler_win.cc.
Review URL: https://codereview.chromium.org//467953002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@39181 260f80e4-7a28-3924-810f-c04153c831b5
2014-08-13 00:08:50 +00:00
iposva@google.com 4884b3124c - More missing headers on Windows.
Review URL: https://codereview.chromium.org//463373002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@39180 260f80e4-7a28-3924-810f-c04153c831b5
2014-08-13 00:03:46 +00:00
iposva@google.com 14ecdbd66a - Separate the thread implementation used in bin/ and vm/
to allow us to make VM specific changes.

R=asiva@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@39172 260f80e4-7a28-3924-810f-c04153c831b5
2014-08-12 23:19:53 +00:00
ajohnsen@google.com d3e183b91a Be sure we don't delete a ClientSocket, until 'connect' is completed.
BUG=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@38671 260f80e4-7a28-3924-810f-c04153c831b5
2014-07-29 13:40:51 +00:00
ajohnsen@google.com d481c8b61c Start accepting incoming sockets earlier on Windows, to associate a at AcceptEx error to 'ServerSocket.bind'.
Note that I have not been able to reproduce the error, thus no test is added for this case.

BUG=http://code.google.com/p/dart/issues/detail?id=19815
R=whesse@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@38606 260f80e4-7a28-3924-810f-c04153c831b5
2014-07-28 11:36:35 +00:00
ajohnsen@google.com cee2d6e82e Correctly truncate in Windows eventhandler.
BUG=
R=sgjesse@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@37163 260f80e4-7a28-3924-810f-c04153c831b5
2014-06-10 07:12:52 +00:00
ajohnsen@google.com 9ddf98ffb8 Mark handle as invalid, when datagram socket is closed.
BUG=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@37030 260f80e4-7a28-3924-810f-c04153c831b5
2014-06-05 15:56:59 +00:00
ajohnsen@google.com 58e0c32205 Don't issue new directory reads, if we already got unhandled data.
BUG=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@37006 260f80e4-7a28-3924-810f-c04153c831b5
2014-06-04 18:50:40 +00:00
ajohnsen@google.com 90db41af31 Fix previous fix, by still making 'handle' the socket.
BUG=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@36999 260f80e4-7a28-3924-810f-c04153c831b5
2014-06-04 15:56:47 +00:00
ajohnsen@google.com f8d735521c Don't use same value for socket() and handle(), as they are different concepts.
BUG=
R=kasperl@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@36995 260f80e4-7a28-3924-810f-c04153c831b5
2014-06-04 14:16:50 +00:00
ajohnsen@google.com 69a7b746ef Fix double-closing of handles in Windows EventHandler.
BUG=
R=kasperl@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@36991 260f80e4-7a28-3924-810f-c04153c831b5
2014-06-04 11:53:53 +00:00
ajohnsen@google.com 146f95135e Use 'Directory.watch' on Windows in pkg/watcher, instead of pooling.
This is a close copy of MacOS, except for the special handling on mac, and the extra watcher on Windows for detecting if the watched folder is deleted.

BUG=https://code.google.com/p/dart/issues/detail?id=14428,https://code.google.com/p/dart/issues/detail?id=18108,http://code.google.com/p/dart/issues/detail?id=19189
R=kasperl@google.com, sgjesse@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@36988 260f80e4-7a28-3924-810f-c04153c831b5
2014-06-04 10:23:32 +00:00
ajohnsen@google.com 30f6999668 Don't try to send messages, when the port is not set.
BUG=https://code.google.com/p/dart/issues/detail?id=18402
R=sgjesse@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@35898 260f80e4-7a28-3924-810f-c04153c831b5
2014-05-08 10:28:31 +00:00
ajohnsen@google.com 3e1058fdfd Clean up windows eventhandler.
BUG=
R=sgjesse@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@35737 260f80e4-7a28-3924-810f-c04153c831b5
2014-05-05 11:08:03 +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 f5b0a17b19 Use ConnectEx on Windows, to do async connect of sockets.
BUG=https://code.google.com/p/dart/issues/detail?id=18154
R=sgjesse@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@35622 260f80e4-7a28-3924-810f-c04153c831b5
2014-05-01 10:48:43 +00:00
ajohnsen@google.com 3b29063492 Don't act on return-token commands on Windows.
BUG=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@33653 260f80e4-7a28-3924-810f-c04153c831b5
2014-03-13 15:23:08 +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
ajohnsen@google.com a5d145b1ca Remove non-fatal prints from windows eventhandler.
BUG=
R=sgjesse@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@32964 260f80e4-7a28-3924-810f-c04153c831b5
2014-02-24 14:31:39 +00:00