From af41549b639be8ef33d99789c8a6a6366658001c Mon Sep 17 00:00:00 2001 From: wuxf Date: Fri, 24 Feb 2023 17:22:12 +0800 Subject: [PATCH] =?UTF-8?q?RecvContext=E5=A2=9E=E5=8A=A0=E5=BE=AE=E7=A7=92?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=EF=BC=8CCurrent=E7=B2=BE=E7=A1=AE=E6=8E=A5?= =?UTF-8?q?=E6=94=B6=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- servant/libservant/Current.cpp | 4 ++-- util/include/util/tc_epoll_server.h | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/servant/libservant/Current.cpp b/servant/libservant/Current.cpp index eed6d50..2d6c8a2 100644 --- a/servant/libservant/Current.cpp +++ b/servant/libservant/Current.cpp @@ -128,8 +128,8 @@ int Current::getMessageType() const struct timeval Current::getRecvTime() const { timeval tm; - tm.tv_sec = _data->recvTimeStamp() / 1000; - tm.tv_usec = (_data->recvTimeStamp() % 1000) * 1000; + tm.tv_sec = _data->recvTimeStampUs() / 1000000; + tm.tv_usec = _data->recvTimeStampUs() % 1000000; return tm; } diff --git a/util/include/util/tc_epoll_server.h b/util/include/util/tc_epoll_server.h index 04b452f..66cc904 100755 --- a/util/include/util/tc_epoll_server.h +++ b/util/include/util/tc_epoll_server.h @@ -187,7 +187,7 @@ public: , _adapter(adapter) , _isClosed(isClosed) , _closeType(closeType) - , _recvTimeStamp(TNOWMS) + , _recvTimeStamp(TNOWUS) {} inline int threadIndex() const { return _threadIndex; } inline uint32_t uid() const { return _uid; } @@ -196,7 +196,8 @@ public: inline uint16_t port() const { parseIpPort(); return _port; } inline vector & buffer() { return _rbuffer; } inline const vector & buffer() const { return _rbuffer; } - inline int64_t recvTimeStamp() const { return _recvTimeStamp; } + inline int64_t recvTimeStamp() const { return _recvTimeStamp/1000; } + inline int64_t recvTimeStampUs() const { return _recvTimeStamp; } inline bool isOverload() const { return _isOverload; } inline void setOverload() { _isOverload = true; } inline bool isClosed() const { return _isClosed; } @@ -232,7 +233,7 @@ public: bool _isOverload = false; /**是否已过载 */ bool _isClosed = false; /**是否已关闭*/ int _closeType; /*如果是关闭消息包,则标识关闭类型,0:表示客户端主动关闭;1:服务端主动关闭;2:连接超时服务端主动关闭*/ - int64_t _recvTimeStamp; /**接收到数据的时间*/ + int64_t _recvTimeStamp; /**接收到数据的时间,微秒*/ }; /**