1. 03 Apr, 2020 1 commit
    • Boqin Qin's avatar
      all: fix a bunch of inconsequential goroutine leaks (#20667) · be6078ad
      Boqin Qin authored
      The leaks were mostly in unit tests, and could all be resolved by
      adding suitably-sized channel buffers or by restructuring the test
      to not send on a channel after an error has occurred.
      
      There is an unavoidable goroutine leak in Console.Interactive: when
      we receive a signal, the line reader cannot be unblocked and will get
      stuck. This leak is now documented and I've tried to make it slightly 
      less bad by adding a one-element buffer to the output channels of
      the line-reading loop. Should the reader eventually awake from its
      blocked state (i.e. when stdin is closed), at least it won't get stuck
      trying to send to the interpreter loop which has quit long ago.
      Co-authored-by: 's avatarFelix Lange <fjl@twurst.com>
      be6078ad
  2. 18 Nov, 2019 1 commit
    • Felix Lange's avatar
      rpc, p2p/simulations: use github.com/gorilla/websocket (#20289) · 7c4a4eb5
      Felix Lange authored
      * rpc: improve codec abstraction
      
      rpc.ServerCodec is an opaque interface. There was only one way to get a
      codec using existing APIs: rpc.NewJSONCodec. This change exports
      newCodec (as NewFuncCodec) and NewJSONCodec (as NewCodec). It also makes
      all codec methods non-public to avoid showing internals in godoc.
      
      While here, remove codec options in tests because they are not
      supported anymore.
      
      * p2p/simulations: use github.com/gorilla/websocket
      
      This package was the last remaining user of golang.org/x/net/websocket.
      Migrating to the new library wasn't straightforward because it is no
      longer possible to treat WebSocket connections as a net.Conn.
      
      * vendor: delete golang.org/x/net/websocket
      
      * rpc: fix godoc comments and run gofmt
      7c4a4eb5
  3. 04 Feb, 2019 1 commit
    • Felix Lange's avatar
      rpc: implement full bi-directional communication (#18471) · 245f3146
      Felix Lange authored
      New APIs added:
      
          client.RegisterName(namespace, service) // makes service available to server
          client.Notify(ctx, method, args...)     // sends a notification
          ClientFromContext(ctx)                  // to get a client in handler method
      
      This is essentially a rewrite of the server-side code. JSON-RPC
      processing code is now the same on both server and client side. Many
      minor issues were fixed in the process and there is a new test suite for
      JSON-RPC spec compliance (and non-compliance in some cases).
      
      List of behavior changes:
      
      - Method handlers are now called with a per-request context instead of a
        per-connection context. The context is canceled right after the method
        returns.
      - Subscription error channels are always closed when the connection
        ends. There is no need to also wait on the Notifier's Closed channel
        to detect whether the subscription has ended.
      - Client now omits "params" instead of sending "params": null when there
        are no arguments to a call. The previous behavior was not compliant
        with the spec. The server still accepts "params": null.
      - Floating point numbers are allowed as "id". The spec doesn't allow
        them, but we handle request "id" as json.RawMessage and guarantee that
        the same number will be sent back.
      - Logging is improved significantly. There is now a message at DEBUG
        level for each RPC call served.
      245f3146
  4. 09 Oct, 2018 1 commit
    • Felix Lange's avatar
      rpc: fix subscription corner case and speed up tests (#17874) · 4e474c74
      Felix Lange authored
      Notifier tracks whether subscription are 'active'. A subscription
      becomes active when the subscription ID has been sent to the client. If
      the client sends notifications in the request handler before the
      subscription becomes active they are dropped. The tests tried to work
      around this problem by always waiting 5s before sending the first
      notification.
      
      Fix it by buffering notifications until the subscription becomes active.
      This speeds up all subscription tests.
      
      Also fix TestSubscriptionMultipleNamespaces to wait for three messages
      per subscription instead of six. The test now finishes just after all
      notifications have been received and doesn't hit the 30s timeout anymore.
      4e474c74
  5. 08 Nov, 2017 1 commit
  6. 08 Aug, 2017 1 commit
  7. 25 Apr, 2017 1 commit
  8. 22 Mar, 2017 1 commit
    • Felix Lange's avatar
      all: import "context" instead of "golang.org/x/net/context" · c213fd1f
      Felix Lange authored
      There is no need to depend on the old context package now that the
      minimum Go version is 1.7. The move to "context" eliminates our weird
      vendoring setup. Some vendored code still uses golang.org/x/net/context
      and it is now vendored in the normal way.
      
      This change triggered new vet checks around context.WithTimeout which
      didn't fire with golang.org/x/net/context.
      c213fd1f
  9. 09 Jan, 2017 1 commit
  10. 06 Jan, 2017 1 commit
  11. 17 Aug, 2016 1 commit
  12. 05 Aug, 2016 1 commit
    • Felix Lange's avatar
      rpc: ensure client doesn't block for slow subscribers · f5f042ff
      Felix Lange authored
      I initially made the client block if the 100-element buffer was
      exceeded. It turns out that this is inconvenient for simple uses of the
      client which subscribe and perform calls on the same goroutine, e.g.
      
          client, _ := rpc.Dial(...)
          ch := make(chan int) // note: no buffer
          sub, _ := client.EthSubscribe(ch, "something")
          for event := range ch {
              client.Call(...)
          }
      
      This innocent looking code will lock up if the server suddenly decides
      to send 2000 notifications. In this case, the client's main loop won't
      accept the call because it is trying to deliver a notification to ch.
      
      The issue is kind of hard to explain in the docs and few people will
      actually read them. Buffering is the simple option and works with close
      to no overhead for subscribers that always listen.
      f5f042ff
  13. 22 Jul, 2016 1 commit
  14. 15 Apr, 2016 2 commits
  15. 01 Apr, 2016 1 commit