@@ -129,9 +129,7 @@ func (s *ServantProxy) TarsInvoke(ctx context.Context, cType byte,
129
129
130
130
msg := buildMessage (ctx , cType , sFuncName , buf , status , reqContext , resp , s )
131
131
timeout := time .Duration (s .syncTimeout ) * time .Millisecond
132
- err := s .invokeFilters (ctx , msg , timeout )
133
-
134
- if err != nil {
132
+ if err := s .invokeFilters (ctx , msg , timeout ); err != nil {
135
133
return err
136
134
}
137
135
* resp = * msg .Resp
@@ -238,8 +236,8 @@ func (s *ServantProxy) doInvoke(ctx context.Context, msg *Message, timeout time.
238
236
}
239
237
240
238
atomic .AddInt32 (& s .queueLen , 1 )
241
- readCh : = make (chan * requestf.ResponsePacket )
242
- adp .resp .Store (msg .Req .IRequestId , readCh )
239
+ msg . RespCh = make (chan * requestf.ResponsePacket )
240
+ adp .resp .Store (msg .Req .IRequestId , msg . RespCh )
243
241
var releaseFunc = func () {
244
242
CheckPanic ()
245
243
atomic .AddInt32 (& s .queueLen , - 1 )
@@ -265,7 +263,7 @@ func (s *ServantProxy) doInvoke(ctx context.Context, msg *Message, timeout time.
265
263
if msg .Async {
266
264
go func () {
267
265
defer releaseFunc ()
268
- err := s .waitInvoke (msg , adp , timeout , needCheck )
266
+ err := s .waitResp (msg , timeout , needCheck )
269
267
s .manager .postInvoke ()
270
268
msg .End ()
271
269
s .reportStat (msg , err )
@@ -280,21 +278,18 @@ func (s *ServantProxy) doInvoke(ctx context.Context, msg *Message, timeout time.
280
278
return nil
281
279
}
282
280
283
- return s .waitInvoke (msg , adp , timeout , needCheck )
281
+ return s .waitResp (msg , timeout , needCheck )
284
282
}
285
283
286
- func (s * ServantProxy ) waitInvoke (msg * Message , adp * AdapterProxy , timeout time.Duration , needCheck bool ) error {
287
- ch , _ := adp .resp .Load (msg .Req .IRequestId )
288
- readCh := ch .(chan * requestf.ResponsePacket )
289
-
284
+ func (s * ServantProxy ) waitResp (msg * Message , timeout time.Duration , needCheck bool ) error {
285
+ adp := msg .Adp
290
286
select {
291
287
case <- rtimer .After (timeout ):
292
288
msg .Status = basef .TARSINVOKETIMEOUT
293
289
adp .failAdd ()
294
- msg .End ()
295
290
return fmt .Errorf ("request timeout, begin time:%d, cost:%d, obj:%s, func:%s, addr:(%s:%d), reqid:%d" ,
296
291
msg .BeginTime , msg .Cost (), msg .Req .SServantName , msg .Req .SFuncName , adp .point .Host , adp .point .Port , msg .Req .IRequestId )
297
- case msg .Resp = <- readCh :
292
+ case msg .Resp = <- msg . RespCh :
298
293
if needCheck {
299
294
go func () {
300
295
adp .reset ()
0 commit comments