some renaming
This commit is contained in:
parent
c242c72f3d
commit
4010408b08
@ -33,7 +33,7 @@ type ipcCommon struct {
|
|||||||
errCh chan error
|
errCh chan error
|
||||||
nextId int64
|
nextId int64
|
||||||
pendingCalls map[int64]*pendingCall
|
pendingCalls map[int64]*pendingCall
|
||||||
processingCalls atomic.Int64
|
processingIncomingCalls atomic.Int64
|
||||||
stopRequested atomic.Bool
|
stopRequested atomic.Bool
|
||||||
mu sync.Mutex
|
mu sync.Mutex
|
||||||
writeMu sync.Mutex
|
writeMu sync.Mutex
|
||||||
@ -50,17 +50,17 @@ func (ipc *ipcCommon) readConn() {
|
|||||||
ipc.raiseErr(fmt.Errorf("unmarshal message: %w", err))
|
ipc.raiseErr(fmt.Errorf("unmarshal message: %w", err))
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
ipc.processMsg(msg)
|
ipc.handleIncomingMsg(msg)
|
||||||
}
|
}
|
||||||
if err := scn.Err(); err != nil {
|
if err := scn.Err(); err != nil {
|
||||||
ipc.raiseErr(err)
|
ipc.raiseErr(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ipc *ipcCommon) processMsg(msg Message) {
|
func (ipc *ipcCommon) handleIncomingMsg(msg Message) {
|
||||||
switch msg.Type {
|
switch msg.Type {
|
||||||
case MsgCall:
|
case MsgCall:
|
||||||
go ipc.handleCall(msg)
|
go ipc.handleIncomingCall(msg)
|
||||||
case MsgResponse:
|
case MsgResponse:
|
||||||
ipc.handleResponse(msg)
|
ipc.handleResponse(msg)
|
||||||
}
|
}
|
||||||
@ -83,13 +83,13 @@ func (ipc *ipcCommon) sendMsg(msg Message) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ipc *ipcCommon) handleCall(msg Message) {
|
func (ipc *ipcCommon) handleIncomingCall(msg Message) {
|
||||||
if ipc.stopRequested.Load() {
|
if ipc.stopRequested.Load() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
ipc.processingCalls.Add(1)
|
ipc.processingIncomingCalls.Add(1)
|
||||||
defer ipc.processingCalls.Add(-1)
|
defer ipc.processingIncomingCalls.Add(-1)
|
||||||
|
|
||||||
defer func() {
|
defer func() {
|
||||||
if err := recover(); err != nil {
|
if err := recover(); err != nil {
|
||||||
@ -126,12 +126,12 @@ func (ipc *ipcCommon) handleCall(msg Message) {
|
|||||||
results = append(results, resVal.Interface())
|
results = append(results, resVal.Interface())
|
||||||
}
|
}
|
||||||
|
|
||||||
var resErr error
|
var resultError error
|
||||||
if !errResultVals.IsNil() {
|
if !errResultVals.IsNil() {
|
||||||
resErr = errResultVals.Interface().(error)
|
resultError = errResultVals.Interface().(error)
|
||||||
}
|
}
|
||||||
|
|
||||||
ipc.sendResponse(msg.Id, results, resErr)
|
ipc.sendResponse(msg.Id, results, resultError)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ipc *ipcCommon) findMethod(methodName string) (reflect.Value, error) {
|
func (ipc *ipcCommon) findMethod(methodName string) (reflect.Value, error) {
|
||||||
|
|||||||
@ -111,7 +111,7 @@ func (p *ParentIPC) Stop() error {
|
|||||||
if hasPending {
|
if hasPending {
|
||||||
return fmt.Errorf("there are calls pending")
|
return fmt.Errorf("there are calls pending")
|
||||||
}
|
}
|
||||||
if p.processingCalls.Load() > 0 {
|
if p.processingIncomingCalls.Load() > 0 {
|
||||||
return fmt.Errorf("there are calls processing")
|
return fmt.Errorf("there are calls processing")
|
||||||
}
|
}
|
||||||
p.stopRequested.Store(true)
|
p.stopRequested.Store(true)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user