47 Commits
Author SHA1 Message Date
Kenton Varda 65edaa8a57 Promise capabilities take ownership of the capability to which they resolve.
Make sure that the node-level capability is replaced with one that will throw an exception from calls, rather than segfault on null pointer.
2016-06-20 14:28:00 -07:00
Kenton Varda 27ef02fac9 Support "flat" encoding, and "packed-flat" too. 2016-03-27 07:16:58 -07:00
Kenton Varda 39743ab28a Include Javascript stack when converting to KJ exception. 2016-03-27 07:16:58 -07:00
Drew Fisher dcf1b10278 Make the overhead computation look less like it has an integer underflow 2016-02-18 19:00:57 -08:00
Drew Fisher ccdb72c931 Compute a tighter upper bound on the buffer needed for packed encoding 2016-02-18 15:48:41 -08:00
Drew Fisher 09c79de07d Add tests for packed encoding/decoding. 2016-02-18 15:11:13 -08:00
Drew Fisher b013752ed5 Add support for serializing structures to packed Cap'n Proto encoding 2016-02-18 14:00:10 -08:00
Drew Fisher 6b899a4250 Add support for parsing structures in Cap'n Proto's packed encoding 2016-02-18 12:03:03 -08:00
Kenton Varda 10e269d298 Void values are normally represented as 'null', so ignoring 'null' fields is wrong. 2016-02-09 18:41:47 -08:00
Kenton Varda 55d9a51855 Treat closed capability as disconnected.
This seems correct, and works around a bug in Sandstorm where a capability shared between multiple components is sometimes closed by one of them. This isn't the best way to fix the bug, but the real fix will require some refactoring.
2015-11-10 09:57:24 -08:00
Kenton Varda 753c11b038 Fix typo in previous commit. 2015-10-05 22:52:48 -07:00
Kenton Varda 5266df2ac6 Add some logging code to attempt to track down the event-loop-deadlocking bug, which apprently isn't fixed.
This change might inadvertently fix the problem, if it related to doRun() receiving a non-zero status.
2015-10-05 22:06:16 -07:00
Kenton Varda db34d99401 Properly close UV handles.
It turns out that you need to call uv_close() on all handles, but the libuv documentation does a remarkably good job of hiding this fact by not discussing it in any intros nor showing it in any examples.

In particular, UvEventPort was repeatedly re-initializing a timer handle over an existing handle that had been stopped but not closed (I had assumed "stop" also cleaned up).

In practice, the effect of this problems seems to be that on very rare occasion, the KJ<->UV glue will stop operating, such that the KJ event loop no longer dispatches any events. The problem only seems to occur on heavily-loaded servers and even then is rare. Possibly memory was being leaked as well, but if so, not very much.

(Actually, as of now I am not certain that this change fixes that problem, but I am certain that the code was wrong before this change.)
2015-09-29 12:38:02 -07:00
Kenton Varda c5207b697b Merge pull request #23 from jparyani/set-anypointer-with-cap
Allow setting AnyPointer fields with a capability
2015-06-12 16:19:13 -07:00
Jason Paryani 38c2366d79 Handle local caps properly when converting from AnyPointer 2015-06-12 15:50:27 -07:00
Jason Paryani ad69dc7bd8 Allow setting AnyPointer fields with a capability
This is blocked on https://github.com/sandstorm-io/capnproto/pull/214
2015-06-10 16:06:56 -07:00
David Renshaw 3ef506cd94 Fix off-by-one bug for methods with non-inline param list. 2015-06-05 11:14:30 -04:00
Jason Paryani f74f71a580 Also rename type->kjType for converting from js exceptions 2015-06-04 15:49:07 -07:00
Jason Paryani 0e4602fd8c Rename error.type to kjType
This a workaround due to a v8 bug:
https://code.google.com/p/v8/issues/detail?id=2397
2015-06-04 13:36:47 -07:00
Kenton Varda 10a149f333 Merge pull request #19 from jparyani/add-any-pointer-capability
Handle Capabilities that are typed as AnyPointers
2015-05-29 16:09:26 -07:00
Jason Paryani 32380dd1a6 Handle Capabilities that are typed as AnyPointers 2015-05-29 15:22:42 -07:00
Kenton Varda 54ad340ecf Cleanup: Remove #ifdefs to handle pre-0.5.x. 2015-05-28 17:17:35 -07:00
Kenton Varda 1199aa284a Cleanup: Use new capnp::Type to eliminate hacks. 2015-05-28 17:14:51 -07:00
Kenton Varda 069df22577 Support constants. 2015-04-14 22:36:18 -07:00
Jason Paryani c1b498b8fd Change fieldFromJs to allow setting fields as null/undefined
Before this, string fields would accept null/undefined, and immediately
call toString() on them, resulting in "null"/"undefined". Other field
types would error out. Now we allow setting fields as null/undefined, so
doing something like:

myCap.myMethod(1, "2", null, "4", myObj["notAKey"])

is possible.
2015-03-30 17:20:02 -07:00
Kenton Varda f35875ee9f Merge pull request #13 from dwrensha/export-bootstrap
Allow clients to export a bootstrap capability.
2015-03-01 19:17:22 -08:00
David Renshaw a28896abb7 explicit move to avoid copy 2015-03-01 21:59:17 -05:00
David Renshaw 785778e81b Allow clients to export a bootstrap capability. 2015-02-26 13:36:05 -05:00
David Renshaw c2cb839cac fix typos 2015-02-25 14:24:29 -05:00
Jason Paryani b748000f52 Fix toJsParams not properly respecting types of fields
This would cause problems with large (u)int64_t fields
2015-02-24 14:12:45 -08:00
Jason Paryani 9f935d64f5 Rename _id to typeId 2015-02-19 16:30:48 -08:00
Jason Paryani 82d1fe0550 Add _id field for imported modules 2015-02-19 13:47:31 -08:00
Jason Paryani 17f7e2b273 Handle incoming AnyPointers by transforming them to a byte message 2015-02-19 11:27:37 -08:00
Kenton Varda 933b8cb67d Add missing files from previous commit. 2015-01-22 15:04:23 -08:00
Kenton Varda ac8c1a61c2 Update to support building with Ekam.
See: https://github.com/sandstorm-io/ekam

This will allow easier integration into the Sandstorm build, without re-publishing the package every time Sandstorm needs a minor change.
2015-01-22 13:25:01 -08:00
Kenton Varda dc538dd4ce Update for Cap'n Proto EventPort API change for cross-thread wakeup. 2014-12-08 22:41:08 -08:00
Kenton Varda fad577c18a Update for kj::Exception change in Cap'n Proto master. 2014-11-29 00:33:06 -08:00
Kenton Varda dca1c08575 Fix for recent Cap'n Proto changes. 2014-11-03 20:52:03 -08:00
Kenton Varda d5e510c65d Fix build for recent Cap'n Proto interface change and mostly-support generics. 2014-10-27 11:58:10 -07:00
Kenton Varda 7acd978d7e Allow Javascript servers to detect when all clients have closed a capability. 2014-09-19 19:15:59 -07:00
Kenton Varda 963018cccf Plug various leaks of capability references.
In all cases, the capabilities would eventually be garbage collected, but if a user explicitly called .close() in hopes of dropping a reference proactively, it could be ignored because a leaked reference still existed.
2014-09-10 22:50:23 -07:00
Jason Paryani 29f3d62c94 Update es6-promise to version 1.0.x and lock it there.
Also fix `cast` being replaced by `resolve`
2014-06-26 00:26:53 -07:00
Kenton Varda 9b3e84b111 Change copyright to Sandstorm Development Group, Inc. (Kenton's company) and license to MIT, to match recent changes to Cap'n Proto itself. 2014-06-25 20:24:18 -07:00
Kenton Varda e20a38d3f9 Allow Capabilities to be created from Promises, like in C++. Also fix a data corruption bug that could happen if a GC occurred at the wrong time. 2014-06-25 20:19:48 -07:00
Jason Paryani fea6ad3789 Add include <sys/uio.h> to fix build on OSX 2014-04-03 08:00:41 -07:00
Kenton Varda 1b2859ce7e Hook require() even though the docs say not to. 2014-04-02 23:17:33 -07:00
Kenton Varda 42b1fb77d0 Initial commit. 2014-04-02 22:14:44 -07:00