MCPcopy Create free account
hub / github.com/CPChain/chain / Stop

Method Stop

api/rpc/server.go:231–241  ·  view source on GitHub ↗

Stop will stop reading new requests, wait for stopPendingRequestTimeout to allow pending requests to finish, close all codecs which will cancel pending requests/subscriptions.

()

Source from the content-addressed store, hash-verified

229// Stop will stop reading new requests, wait for stopPendingRequestTimeout to allow pending requests to finish,
230// close all codecs which will cancel pending requests/subscriptions.
231func (s *Server) Stop() {
232 if atomic.CompareAndSwapInt32(&s.run, 1, 0) {
233 log.Debug("RPC Server shutdown initiatied")
234 s.codecsMu.Lock()
235 defer s.codecsMu.Unlock()
236 s.codecs.Each(func(c interface{}) bool {
237 c.(ServerCodec).Close()
238 return true
239 })
240 }
241}
242
243// createSubscription will call the subscription callback and returns the subscription id or error.
244func (s *Server) createSubscription(ctx context.Context, c ServerCodec, req *serverRequest) (ID, error) {

Callers 1

StartMethod · 0.95

Calls 4

DebugMethod · 0.80
LockMethod · 0.80
UnlockMethod · 0.80
CloseMethod · 0.65

Tested by

no test coverage detected