@ -21,7 +21,6 @@ import (
"reflect"
"reflect"
"runtime"
"runtime"
"sync/atomic"
"sync/atomic"
"time"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/logger/glog"
"github.com/ethereum/go-ethereum/logger/glog"
@ -30,8 +29,6 @@ import (
)
)
const (
const (
stopPendingRequestTimeout = 3 * time . Second // give pending requests stopPendingRequestTimeout the time to finish when the server is stopped
notificationBufferSize = 10000 // max buffered notifications before codec is closed
notificationBufferSize = 10000 // max buffered notifications before codec is closed
MetadataApi = "rpc"
MetadataApi = "rpc"
@ -240,13 +237,11 @@ func (s *Server) ServeSingleRequest(codec ServerCodec, options CodecOption) {
func ( s * Server ) Stop ( ) {
func ( s * Server ) Stop ( ) {
if atomic . CompareAndSwapInt32 ( & s . run , 1 , 0 ) {
if atomic . CompareAndSwapInt32 ( & s . run , 1 , 0 ) {
glog . V ( logger . Debug ) . Infoln ( "RPC Server shutdown initiatied" )
glog . V ( logger . Debug ) . Infoln ( "RPC Server shutdown initiatied" )
time . AfterFunc ( stopPendingRequestTimeout , func ( ) {
s . codecsMu . Lock ( )
s . codecsMu . Lock ( )
defer s . codecsMu . Unlock ( )
defer s . codecsMu . Unlock ( )
s . codecs . Each ( func ( c interface { } ) bool {
s . codecs . Each ( func ( c interface { } ) bool {
c . ( ServerCodec ) . Close ( )
c . ( ServerCodec ) . Close ( )
return true
return true
} )
} )
} )
}
}
}
}