1. 18 Jun, 2019 7 commits
    • Kenton Varda's avatar
      Regenerate bootstraps for streaming. · a784f2f7
      Kenton Varda authored
      Note: Apparently, json.capnp had not been added to the bootstrap test, and the checked-in bootstrap had drifted from the source file.
      a784f2f7
    • Kenton Varda's avatar
      Introduce new 'stream' keyword. · bd6d75ba
      Kenton Varda authored
      This can be used on a method to indicate that it is used for "streaming", like:
      
          write @0 (bytes :Data) -> stream;
      
      A "streaming" method is one which is expected to be called many times to transmit an ordered stream of items. For best throughput, it is often necessary to make multiple overlapping calls, so as not to wait for a round trip for every item. However, to avoid excess buffering, it may be necessary to apply backpressure by having the client limit the total number of overlapping calls. This logic is difficult to get right at the application level, so making it a language feature gives us the opportunity to implement it in the RPC layer.
      
      We can, however, do it in a way that is backwards-compatible with implementations that don't support it. The above declaration is equivalent to:
      
          write @0 (bytes :Data) -> import "/capnp/stream.capnp".StreamResult;
      
      RPC implementations that don't explicitly support streaming can thus instead leave it up to the application to handle.
      bd6d75ba
    • Kenton Varda's avatar
      Add Maybe<Own<T>>::emplace() to avoid assign-then-assert-nonnull. · 2ae7ca9b
      Kenton Varda authored
      I have this pattern:
      
          Maybe<Own<T>> foo;
      
          // ...
      
          foo = heap<T>();
          KJ_ASSERT_NONNULL(foo)->doSomething();
      
      The assertion feels non-type-safe.
      
      Now you can do:
      
          auto& ref = foo.emplace(heap<T>());
          ref.doSomething();
      2ae7ca9b
    • Kenton Varda's avatar
      Allow `kj::Absolute<T>` to be initialized to `kj::maxValue`. · 0bf96571
      Kenton Varda authored
      `kj::Quantity<T>` already supported this. I copied from it.
      0bf96571
    • Kenton Varda's avatar
      Fix `newAdaptedPromise<Promise<T>, Adapter>()`. · c786c444
      Kenton Varda authored
      This was failing to chain the promises, and so returning `Promise<Promise<T>>`.
      
      The idea here is you can create a PromiseAdapter which eventually produces another promise to chain to. The adapter is finished and should be destroyed at that point, but the final promise should then redirect to the new promise.
      c786c444
    • Kenton Varda's avatar
      Fix estimation of Return message sizes. · c826a71a
      Kenton Varda authored
      Apparently, Return messages with empty capability tables have been allocated one word too small all along, causing many Return messages to be split into two segments and allocate twice the memory they need. I never bothered to check whether this was happening...
      c826a71a
    • Kenton Varda's avatar
      Fix another AsyncPipe bug. · 889d7583
      Kenton Varda authored
      889d7583
  2. 16 Jun, 2019 5 commits
    • Kenton Varda's avatar
      Add cheaper way to check size of RPC messages for flow control. · 76e35a7c
      Kenton Varda authored
      Way back in 538a767e I added `RpcSystem::setFlowLimit()`, a blunt mechanism by which an RPC node can arrange to stop reading new messages from the connection when too many incoming calls are in-flight. This was needed to deal with buggy Sandstorm apps that would stream multi-gigabyte files by doing a zillion writes without waiting, which would then all be queued in the HTTP gateway, causing it to run out of memory.
      
      In implementing that, I inadertently caused the RPC system to do a tree walk on every call message it received, in order to sum up the message size. This is silly, becaues it's much cheaper to sum up the segment sizes. In fact, in the case of a malicious peer, the tree walk is potentially insufficient, because it doesn't count holes in the segments. The tree walk also means that any invalid pointers in the message cause an exception to be thrown even if that pointer is never accessed by the app, which isn't the usual behavior.
      
      I seem to recall this issue coming up in discussion once in the past, but I couldn't find the thread.
      
      For the new streaming feature, we'll be paying attention to the size of outgoing messages. Again, here, it would be nice to compute this size by summing segments without doing a tree walk.
      
      So, this commit adds `sizeInWords()` methods that do this.
      76e35a7c
    • Kenton Varda's avatar
      Merge pull request #836 from pwrdwnsys/openbsd-aligned_alloc · 99d308ff
      Kenton Varda authored
      Add OpenBSD to posix_memalign ifdef
      99d308ff
    • pwrdwnsys's avatar
      update comment · 73c5b9f7
      pwrdwnsys authored
      73c5b9f7
    • Kenton Varda's avatar
      Merge pull request #834 from capnproto/attach-and-clone · c6d71669
      Kenton Varda authored
      Introduce kj::attachVal(), kj::attachRef(), and capnp::clone() utility functions
      c6d71669
    • Kenton Varda's avatar
      Merge pull request #835 from capnproto/rpc-server-drain · 1e75c181
      Kenton Varda authored
      Add TwoPartyServer::drain().
      1e75c181
  3. 15 Jun, 2019 4 commits
  4. 14 Jun, 2019 1 commit
  5. 10 Jun, 2019 3 commits
  6. 09 Jun, 2019 3 commits
  7. 30 May, 2019 2 commits
  8. 27 May, 2019 2 commits
  9. 24 May, 2019 2 commits
  10. 02 May, 2019 2 commits
  11. 26 Apr, 2019 1 commit
  12. 22 Apr, 2019 7 commits
  13. 21 Apr, 2019 1 commit