Commit Graph

32 Commits

Author SHA1 Message Date
kustermann@google.com 29585740d6 Set close-on-exec flag on pipe() and kqueue() file descriptors on MacOS
Review URL: https://codereview.chromium.org//11571056

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@16316 260f80e4-7a28-3924-810f-c04153c831b5
2012-12-19 12:43:38 +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
ager@google.com 5c9f9ef74f Avoid needless int64_t to intptr_t conversion in eventhandler.
R=sgjesse@google.com
BUG=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@12693 260f80e4-7a28-3924-810f-c04153c831b5
2012-09-21 11:40:40 +00:00
cshapiro@google.com 26b843c7ee Fix build break on Win32 and MacOS related to printf format string checks.
Implement remaining inttypes.h format specifiers on Win32

Resolve some conversion specifier discrepancies on MacOS.

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@11913 260f80e4-7a28-3924-810f-c04153c831b5
2012-09-06 01:14:09 +00:00
asiva@google.com 9d123e5366 Move hashmap.h and hashmap.cc from the 'bin' directory to 'platform' directory so that it can be used from VM code too.
Review URL: https://chromiumcodereview.appspot.com//10853009

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@10261 260f80e4-7a28-3924-810f-c04153c831b5
2012-08-03 22:11:30 +00:00
ager@google.com f791a12b38 Terminate event handler thread on isolate shutdown.
R=sgjesse@google.com
BUG=
TEST=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@9251 260f80e4-7a28-3924-810f-c04153c831b5
2012-06-29 14:40:17 +00:00
ager@google.com 989daa8d1d Fix invalid pointer arithmetic in Linux and MacOS event handler
implementations.

R=sgjesse@google.com
BUG=dartbug.com/2759
TEST=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@7066 260f80e4-7a28-3924-810f-c04153c831b5
2012-04-27 11:07:01 +00:00
ager@google.com 37147fc116 Remove unused thread pool from standalone VM binary.
We are using the thread pool in the VM via native ports.

R=sgjesse@google.com
BUG=
TEST=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@5954 260f80e4-7a28-3924-810f-c04153c831b5
2012-03-28 21:57:58 +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
ager@google.com a98318a348 Add additional error printing to kqueue failures on Mac.
This is an attempt to get more information on dartbug.com/1876

R=ricow@google.com
BUG=1876

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@5686 260f80e4-7a28-3924-810f-c04153c831b5
2012-03-20 15:24:14 +00:00
sgjesse@google.com 18743ce4fb Fix kqueue handling of no timeout
Using a tiemout value of 0 when there was no timeout caused busy
looping int the eventhandler thread as that actually ment
immediate timeout. No timeout is specified using NULL.

BUG=dart:1641

R=iposva@google.com

TEST=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@4176 260f80e4-7a28-3924-810f-c04153c831b5
2012-02-13 09:16:57 +00:00
ager@google.com 3e590345ca Fix event handler assert stupidity. :-)
R=sgjesse@google.com
BUG=
TEST=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@4035 260f80e4-7a28-3924-810f-c04153c831b5
2012-02-08 14:28:24 +00:00
ager@google.com 0a0f1d9504 Move the event handler on macos from poll to kqueue. Simpler and faster.
R=sgjesse@google.com
BUG=
TEST=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@4028 260f80e4-7a28-3924-810f-c04153c831b5
2012-02-08 12:18:29 +00:00
sgjesse@google.com be4fb55ac9 Fix Windows and Mac OS builds
TBR=asiva@google.com

BUG=
TEST=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@3948 260f80e4-7a28-3924-810f-c04153c831b5
2012-02-06 15:52:39 +00:00
sgjesse@google.com 4e9686dc4b Implemented encoding af a Dart_CMessage structure into a Dart message. Currently supported types are:
Boolean
  Smi
  Double
  String
  Array

The encoding uses the upper bits of the Dart_CObject type field for "marking" already written objects with their object id for generating backward references. After serialization these mark are removed.

Added the API Dart_PostCMessage for encoding and posting a Dart_CMessage structure.

Removed the API Dart_PostIntArray and used Dart_PostCMessage instead.

R=asive@google.com,turnidge@google.com

BUG=
TEST=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@3947 260f80e4-7a28-3924-810f-c04153c831b5
2012-02-06 15:42:15 +00:00
sgjesse@google.com 42b70dcddb Change the thread interface in runtime/platform and use it starting all threads
The platform thread interface (dart::thread) is now refactored to an
all static interface as suggested by iposva@ and asiva@. Use this
interface for running all threads in the VM.

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

BUG=
TEST=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@3830 260f80e4-7a28-3924-810f-c04153c831b5
2012-02-02 08:59:26 +00:00
ager@google.com 0f9fdc51d3 Add extra debug information when failing to deliver an interrupt message.
R=sgjesse@google.com
BUG=
TEST=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@3539 260f80e4-7a28-3924-810f-c04153c831b5
2012-01-24 09:52:53 +00:00
sgjesse@google.com 76a9abf164 Fix Mac OS build
TBR=ager@google.com

BUG=
TEST=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@3484 260f80e4-7a28-3924-810f-c04153c831b5
2012-01-23 09:53:28 +00:00
sgjesse@google.com c1d041500f Use hash map for event handler file descriptor map
Instead of using an array indexed using the file descriptor for
looking up data associated with a socket (SocketData objects) this is
now stored in a hash map using the file descriptor as key.

Added hash map implementation like the one used in the V8 project.

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

BUG=
TEST=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@3483 260f80e4-7a28-3924-810f-c04153c831b5
2012-01-23 09:10:51 +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
sgjesse@google.com 8871567117 Don't treat stdin from a terminal differently from piped input
Both piped input (when using the "<" to pipe in a file) and terminal
input from stdin can set POLLIN with 0 bytes available without POLLHUP
when end of file is reached.

R=ager@google.com

BUG=dart:782
TEST=none

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@2311 260f80e4-7a28-3924-810f-c04153c831b5
2011-12-09 14:11:47 +00:00
ager@google.com 422ab9a7cf Make the write end of the interrupt pipe in the eventhandler blocking on mac and linux.
The messages written are small control messages that we do want to succeed now.

R=sgjesse@google.com
BUG=
TEST=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@2246 260f80e4-7a28-3924-810f-c04153c831b5
2011-12-08 13:44:06 +00:00
ager@google.com 3653ebdd17 Only report poll failures when it is something we cannot recover from.
R=sgjesse@google.com
BUG=
TEST=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@1922 260f80e4-7a28-3924-810f-c04153c831b5
2011-11-30 13:32:26 +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 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 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
sgjesse@google.com 032de2585d Some Linux and Mac OS event handler refactoring
This moved some of the handling of the data on a socket to a socket data object.

This is a step in preparation for another change where more state will be stored on socket data object.

This is also a step in moving from an array of socket data objects indexed by the file descriptor to a hash map of socket data objects.

R=ager@google.com

BUG=
TEST=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@1001 260f80e4-7a28-3924-810f-c04153c831b5
2011-11-01 11:54:14 +00:00
sgjesse@google.com 6568436be7 Explicitly handle listen sockets and connection sockets differently in Linux and Mac OS eventhandler
Previously the assumption was that an POLLIN event with no data available was from a listen socket with pending accepts. However a POLLIN event from a connection socket can have no data available if the data has been read before the event is processed.

R=ager@google.com

BUG=
TEST=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@878 260f80e4-7a28-3924-810f-c04153c831b5
2011-10-28 09:30:42 +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
sgjesse@google.com 74e4e46c2f Fix wrong pointer arithmetic when extending the file descripter list in the eventhandler
This caused random crashes due to memory corruption when the file descripter list in the eventhandler needed to be extended.

R=ager@google.com

BUG=none
TEST=tests/dart/src/SocketManyConnectionsTest.dart

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@331 260f80e4-7a28-3924-810f-c04153c831b5
2011-10-11 15:05:32 +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