1. 05 Dec, 2019 3 commits
    • Kenton Varda's avatar
      Use Win32 fibers on Cygwin. · 53d21772
      Kenton Varda authored
      While swapcontext() exists on Cygwin, it seems that throwing an exception in a stack other than the main stack leads to a hang. But the Win32 fiber API seems to work fine.
      53d21772
    • Kenton Varda's avatar
      Implement fibers on Windows. · 609679fb
      Kenton Varda authored
      It was so easy that it compiled on the first try and almost totally worked... only thing I missed was calling switchToMain() explicitly at the end of the fiber main func.
      609679fb
    • Kenton Varda's avatar
      Implement fibers on Unix. · e8a14a7a
      Kenton Varda authored
      Fibers allow code to be written in a synchronous / blocking style while running inside the KJ event loop, by executing the code on an alternate call stack and switching back to the main stack whenever it waits.
      
      We introduce a new function, `kj::startFiber(stackSize, func)`. `func` is executed on the fiber stack. It is passed as its parameter a `WaitScope&`, which can then be passed into the `.wait()` method of any promise in order to wait on the promise in a blocking style. `startFiber()` returns a promise for the eventual value returned by `func()` (much as `evalLater()` and friends do).
      
      This commit implements fibers on Unix via ucontext_t. Windows will come next (and will probably be easier...).
      e8a14a7a
  2. 04 Dec, 2019 1 commit
    • Kenton Varda's avatar
      Refactor: Promise should have fewer friends. · c28fb99c
      Kenton Varda authored
      Instead of making `Promise` friend everything that needs to construct a `Promise<T>` from an `Own<PromiseNode>` or vice versa, let's just friend `PromiseNode` itself -- which is already a "private" class by virtue of being in the `_` namespace -- and let it provide some static methods to do the conversions.
      c28fb99c
  3. 27 Nov, 2019 2 commits
  4. 15 Nov, 2019 1 commit
  5. 14 Nov, 2019 1 commit
    • Kenton Varda's avatar
      Fix RPC loopback bootstrap(). · 77a57f8c
      Kenton Varda authored
      When VatNetwork::connect() returns nullptr, it means that the caller is trying to connect to itself.
      
      rpc-test.c++ failed to test this in two ways:
      - The test VatNetwork's connect() never returned null.
      - There was no test case for loopback connect.
      
      As a result, the code to handle loopback in rpc.c++ had bitrotted. It failed to handle the new bootstrap mechanism introduced in v0.5, and instead only implemented the restorer mechanism from 0.4.
      77a57f8c
  6. 11 Nov, 2019 4 commits
  7. 08 Nov, 2019 1 commit
  8. 07 Nov, 2019 1 commit
  9. 01 Nov, 2019 1 commit
  10. 31 Oct, 2019 1 commit
    • Joe Lee's avatar
      Make HttpClient adapter preserve exception behavior · ea4dc7f0
      Joe Lee authored
      Ideally, the HttpClient/HttpServer adapters should maintain the invariant that
      the behavior of a given client is the same as the behavior of
      newHttpClient(newHttpService(client)).  Prior to this change, the HttpClient
      wrapper lazily called request(), so a client whose request() eagerly threw an
      exception could produce a different exception when called directly versus when
      wrapped -- the laziness allowed additional code to run.  This was particularly
      evident when making a request with a body, since code using a wrapped client
      would be able to set up a subsequent BlockedWrite, eventually resulting in a
      "read end of pipe was aborted" exception instead of the actual exception.
      
      This change makes HttpClientAdapter::request() execute the wrapped request()
      eagerly.
      
      (Note that it partially undoes 90d48343... Hopefully, it preserves the desired
      behavior added there.)
      ea4dc7f0
  11. 28 Oct, 2019 4 commits
  12. 23 Oct, 2019 1 commit
  13. 22 Oct, 2019 4 commits
  14. 15 Oct, 2019 2 commits
  15. 14 Oct, 2019 4 commits
  16. 04 Oct, 2019 2 commits
  17. 03 Oct, 2019 2 commits
  18. 02 Oct, 2019 4 commits
    • Kenton Varda's avatar
      Fix handling of queued RT signals. · c84d57a3
      Kenton Varda authored
      For regular (non-RT) POSIX signals, the process can only have at most one instance of each signal queued for delivery at a time. If another copy of the signal arrives before the first is delivered, the new signal is ignored. The idea was that signals are only meant to wake the process up to check some input; the signal itself is not the input.
      
      POSIX RT signals are different. Multiple copies of the same signal can be queued, and each is delivered separately. Each signal may contain some additional information that needs to be processed. The signals themselves are input.
      
      UnixEventPort's `onSignal()` method returns a Promise that resolves the next time the signal is delivered. When the Promise is resolved, the signal is also supposed to be blocked until `onSignal()` can be called again, so that the app cannot miss signals delivered in between.
      
      However, the epoll/signalfd implementation had a bug where it would pull _all_ queued signals off the `signalfd` at once, only delivering the first instance of each signal number and dropping subsequent instances on the floor. That's fine for regular signals, but not RT signals.
      
      This change fixes the bug and adds a test. Incidentally, the poll()-based implementation has been correct all along.
      c84d57a3
    • Kenton Varda's avatar
      Fix bug when multiple cmsgs are present. · 44c6b461
      Kenton Varda authored
      I don't really know how to test this since the other cmsg types are bizarre and non-portable, but they do exist.
      44c6b461
    • Kenton Varda's avatar
      Test that headers are allowed to contain '.'s. · 11f612a9
      Kenton Varda authored
      This and many other characters are surprisingly allowed by the relevant RFCs. But it turns out we implemented the RFCs correctly, so yay.
      11f612a9
    • Kenton Varda's avatar
      Avoid an unnecessary malloc. · ffbc7043
      Kenton Varda authored
      ffbc7043
  19. 30 Sep, 2019 1 commit