From 5f246a2c098b663fa44d87bc5c9ac5c8f74bbcc1 Mon Sep 17 00:00:00 2001
From: wangzhengquan <wangzhengquan85@126.com>
Date: 星期五, 26 二月 2021 14:04:39 +0800
Subject: [PATCH] update

---
 src/psem.h                   |   42 +++++++++++++++++++++---------------------
 test_net_socket/shm_util.cpp |    3 +--
 src/socket/shm_socket.cpp    |    2 +-
 3 files changed, 23 insertions(+), 24 deletions(-)

diff --git a/src/psem.h b/src/psem.h
index fb64dba..41b76e6 100644
--- a/src/psem.h
+++ b/src/psem.h
@@ -7,31 +7,31 @@
 
 inline int psem_timedwait(sem_t *sem, const struct timespec *ts) {
 	struct timespec abs_timeout = TimeUtil::calc_abs_time(ts);
-  return sem_timedwait(sem, &abs_timeout);
-  // int rv ;
-  // while ( (rv = sem_timedwait(sem, &abs_timeout)) == -1) {
-  //     if(errno == EINTR)
-  //         continue;
-  //     else {
-  //        // LoggerFactory::getLogger()->error(errno, "LockFreeQueue push_timeout");
-  //        return -1;
-  //     }
-  // }
-  // return 0;
+  // return sem_timedwait(sem, &abs_timeout);
+  int rv ;
+  while ( (rv = sem_timedwait(sem, &abs_timeout)) == -1) {
+      if(errno == EINTR)
+          continue;
+      else {
+         // LoggerFactory::getLogger()->error(errno, "LockFreeQueue push_timeout");
+         return -1;
+      }
+  }
+  return 0;
 }
 
 
 inline int psem_wait(sem_t *sem) {
-  return sem_wait(sem);
-  // int rv;
-  // while ( (rv = sem_wait(sem)) == -1) {
-  //     if(errno == EINTR)
-  //         continue;
-  //     else {
-  //        return -1;
-  //     }
-  // }
-  // return 0;
+  // return sem_wait(sem);
+  int rv;
+  while ( (rv = sem_wait(sem)) == -1) {
+      if(errno == EINTR)
+          continue;
+      else {
+         return -1;
+      }
+  }
+  return 0;
 }
 
 inline int psem_trywait(sem_t *sem) {
diff --git a/src/socket/shm_socket.cpp b/src/socket/shm_socket.cpp
index 2b3e626..562682e 100644
--- a/src/socket/shm_socket.cpp
+++ b/src/socket/shm_socket.cpp
@@ -292,7 +292,7 @@
 {
   int rv;
 
-  logger->debug("%d destroy threadlocal socket\n", pthread_self()); 
+  logger->debug("%lu destroy threadlocal socket\n", pthread_self()); 
 
   if(tmp_socket == NULL)
     return;
diff --git a/test_net_socket/shm_util.cpp b/test_net_socket/shm_util.cpp
index 549e29f..4eb03f8 100644
--- a/test_net_socket/shm_util.cpp
+++ b/test_net_socket/shm_util.cpp
@@ -44,7 +44,7 @@
   pthread_detach(pthread_self());
   
   char action[512];
-  while ( true) {
+  while ( true ) {
     printf("Input action: Close?\n");
     if(scanf("%s",action) < 1) {
       printf("Invalide action\n");
@@ -881,7 +881,6 @@
     opt =  parse_args(argc, argv);
     if(opt.bind == 0) {
       usage(argv[0]);
-      exit(1);
     } else {
       start_recvfrom(opt.bind, opt.force);
     }

--
Gitblit v1.8.0