starpc 0.33.3 → 0.33.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/srpc/client-rpc.go +0 -1
- package/srpc/common-rpc.go +9 -14
package/package.json
CHANGED
package/srpc/client-rpc.go
CHANGED
package/srpc/common-rpc.go
CHANGED
|
@@ -69,14 +69,13 @@ func (c *commonRPC) Wait(ctx context.Context) error {
|
|
|
69
69
|
//
|
|
70
70
|
// returns io.EOF if the stream ended without a packet.
|
|
71
71
|
func (c *commonRPC) ReadOne() ([]byte, error) {
|
|
72
|
-
var
|
|
72
|
+
var hasMsg bool
|
|
73
|
+
var msg []byte
|
|
73
74
|
var err error
|
|
74
75
|
var ctxDone bool
|
|
75
76
|
for {
|
|
76
77
|
var waitCh <-chan struct{}
|
|
77
78
|
c.bcast.HoldLock(func(broadcast func(), getWaitCh func() <-chan struct{}) {
|
|
78
|
-
waitCh = getWaitCh()
|
|
79
|
-
|
|
80
79
|
if ctxDone && !c.dataClosed {
|
|
81
80
|
// context must have been canceled locally
|
|
82
81
|
c.closeLocked(broadcast)
|
|
@@ -85,26 +84,22 @@ func (c *commonRPC) ReadOne() ([]byte, error) {
|
|
|
85
84
|
}
|
|
86
85
|
|
|
87
86
|
if len(c.dataQueue) != 0 {
|
|
88
|
-
|
|
89
|
-
|
|
87
|
+
msg = c.dataQueue[0]
|
|
88
|
+
hasMsg = true
|
|
90
89
|
c.dataQueue[0] = nil
|
|
91
90
|
c.dataQueue = c.dataQueue[1:]
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
if c.dataClosed || c.remoteErr != nil {
|
|
91
|
+
} else if c.dataClosed || c.remoteErr != nil {
|
|
95
92
|
err = c.remoteErr
|
|
96
93
|
if err == nil {
|
|
97
94
|
err = io.EOF
|
|
98
95
|
}
|
|
99
96
|
}
|
|
100
|
-
})
|
|
101
97
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
}
|
|
98
|
+
waitCh = getWaitCh()
|
|
99
|
+
})
|
|
105
100
|
|
|
106
|
-
if
|
|
107
|
-
return
|
|
101
|
+
if hasMsg || err != nil {
|
|
102
|
+
return msg, err
|
|
108
103
|
}
|
|
109
104
|
|
|
110
105
|
select {
|