From 14278bd98326f0afdd86fe4ec24e747b0e0b712a Mon Sep 17 00:00:00 2001
From: cheliequan <liequanche@126.com>
Date: 星期日, 04 十二月 2022 21:15:05 +0800
Subject: [PATCH] 增减共享内存链表管理

---
 src/memfd.c |   24 ++++++++++++++++--------
 1 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/src/memfd.c b/src/memfd.c
index 0cc3fb9..04ced4d 100644
--- a/src/memfd.c
+++ b/src/memfd.c
@@ -11,6 +11,7 @@
 #include <stdlib.h>
 #include <time.h>
 #include <stdarg.h>
+#include "memfd.h"
 
 #define errExit(msg)    do { perror(msg); exit(EXIT_FAILURE); \
 } while (0)
@@ -127,14 +128,19 @@
 
 int basic_shm_open(int fd, pid_t pid, int flags)
 {
-    if(0 >= flags)
-    {
-        basic_shm_path_open(fd, getpid());
+    int memfd = -1;
+    switch(flags){
+      case local_open_flag:
+        memfd = basic_shm_path_open(fd, getpid());
+        break;
+      case remote_open_flag:
+        memfd = basic_shm_path_open(fd, pid);
+        break;        
+      default:
+        mydebug("not support\n");
+        break;
     }
-    else
-    {
-        basic_shm_path_open(fd, pid);
-    }
+    return memfd;
 }
 
 int basic_shm_mmap(int fd, unsigned char** ppaddr)
@@ -180,10 +186,12 @@
 
 int basic_shm_close(int fd)
 {
+  int ret = -1;
   if (fd >= 0) 
   {
-    close(fd);
+    ret = close(fd);
   }
+  return ret;
 }
 
 static void mfd_assert_size(int fd, size_t size)

--
Gitblit v1.8.0