...
1 package server
2
3 import (
4 "sync"
5
6 "golang.conradwood.net/go-easyops/cmdline"
7 )
8
9 var (
10 active_rpc_lock sync.Mutex
11 active_rpcs = 0
12 )
13
14 func startRPC() {
15 active_rpc_lock.Lock()
16 active_rpcs++
17 active_rpc_lock.Unlock()
18 cmdline.DebugfRPC("------------------ RPC ENTERED (%d) --------------------\n", active_rpcs)
19 }
20 func stopRPC() {
21 active_rpc_lock.Lock()
22 if active_rpcs == 0 {
23 panic("[go-easyops] active_rpcs must never be negative")
24 }
25 active_rpcs--
26 active_rpc_lock.Unlock()
27 cmdline.DebugfRPC("------------------ RPC COMPLETE (%d) --------------------\n", active_rpcs)
28 }
29 func ActiveRPCs() int {
30 return active_rpcs
31 }
32
View as plain text