Skip to content

Commit

Permalink
feat: uds 超时优化
Browse files Browse the repository at this point in the history
  • Loading branch information
goodjava committed Nov 11, 2024
1 parent 7cefcf6 commit 6d19be8
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import io.netty.channel.unix.DomainSocketAddress;
import io.netty.handler.codec.LengthFieldBasedFrameDecoder;
import io.netty.handler.codec.LengthFieldPrepender;
import io.netty.util.Timeout;
import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
Expand Down Expand Up @@ -166,7 +167,7 @@ public UdsCommand call(UdsCommand req) {
log.debug("start send,id:{}", id);
Send.send(channel, req);

wheelTimer.newTimeout(() -> {
Timeout timeout = wheelTimer.newTimeout(() -> {
log.warn("check async udsClient time out auto close:{},{}", req.getId(), req.getTimeout());
HashMap<String, Object> map = reqMap.remove(req.getId());
if (null != map) {
Expand All @@ -177,7 +178,10 @@ public UdsCommand call(UdsCommand req) {
);
}
}
}, req.getTimeout() + 350);
}, req.getTimeout() + 200);

// 添加完成时取消定时任务的回调
future.whenComplete((k, v) -> timeout.cancel());

//异步还是同步
if (req.isAsync()) {
Expand Down

0 comments on commit 6d19be8

Please sign in to comment.