From 0d6000e8e75e45d83dfc5718bd249a11fcce45a3 Mon Sep 17 00:00:00 2001
From: wangzhengquan <wangzhengquan85@126.com>
Date: 星期五, 15 一月 2021 16:10:15 +0800
Subject: [PATCH] update

---
 src/queue/lock_free_queue.h |   17 ++++++++++-------
 1 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/src/queue/lock_free_queue.h b/src/queue/lock_free_queue.h
index 3914b85..bb0bfb5 100644
--- a/src/queue/lock_free_queue.h
+++ b/src/queue/lock_free_queue.h
@@ -262,12 +262,12 @@
 int LockFreeQueue<ELEM_T, Allocator, Q_TYPE>::push_timeout(const ELEM_T &a_data, const struct timespec * ts)
 {
      
-
+    int rv;
     struct timespec timeout = PXSemUtil::calc_sem_timeout(ts);
   // LoggerFactory::getLogger()->debug("==================LockFreeQueue push_timeout before tv_sec=%d, tv_nsec=%ld", 
   //   timeout.tv_sec, timeout.tv_nsec);
 
-    while (sem_timedwait(&slots, &timeout) == -1) {
+    while ( sem_timedwait(&slots, &timeout) == -1) {
     //     LoggerFactory::getLogger()->debug("==================LockFreeQueue push_timeout before tv_sec=%d, tv_nsec=%ld, ETIMEDOUT=%d, errno=%d\n", 
     // timeout.tv_sec, timeout.tv_nsec, ETIMEDOUT, errno);
 
@@ -300,7 +300,7 @@
 int LockFreeQueue<ELEM_T, Allocator, Q_TYPE>::pop(ELEM_T &a_data)
 {
 
-// LoggerFactory::getLogger()->debug("==================LockFreeQueue pop before\n");
+ // LoggerFactory::getLogger()->debug("==================LockFreeQueue pop before\n");
     if (sem_wait(&items) == -1) {
         LoggerFactory::getLogger()->error(errno, "LockFreeQueue pop");
         return errno;
@@ -343,18 +343,21 @@
     template <typename T, typename AT> class Q_TYPE>
 int LockFreeQueue<ELEM_T, Allocator, Q_TYPE>::pop_timeout(ELEM_T &a_data, struct timespec * ts)
 {
-// LoggerFactory::getLogger()->debug("==================LockFreeQueue pop_timeout before\n");
 
+    // LoggerFactory::getLogger()->debug("==================LockFreeQueue pop_timeout before\n");   
     struct timespec timeout = PXSemUtil::calc_sem_timeout(ts);
 
     while (sem_timedwait(&items, &timeout) == -1) {
-        if (errno == ETIMEDOUT)
+        // LoggerFactory::getLogger()->error(errno, "1 LockFreeQueue pop_timeout %d %d", errno, ETIMEDOUT);
+        if (errno == ETIMEDOUT) {
+             // LoggerFactory::getLogger()->error(errno, "2 LockFreeQueue pop_timeout %d %d", errno, EBUS_TIMEOUT);
             return EBUS_TIMEOUT;
+        }
         else if(errno == EINTR)
             continue;
         else {
-          LoggerFactory::getLogger()->error(errno, "LockFreeQueue pop_timeout");
-          return -1;
+          LoggerFactory::getLogger()->error(errno, "3  LockFreeQueue pop_timeout %d", errno);
+          return errno;
         }
     }
 

--
Gitblit v1.8.0