]> git.openfabrics.org - ~shefty/librdmacm.git/commitdiff
refresh (create temporary patch)
authorSean Hefty <sean.hefty@intel.com>
Mon, 6 Aug 2012 22:06:17 +0000 (15:06 -0700)
committerSean Hefty <sean.hefty@intel.com>
Mon, 6 Aug 2012 22:06:17 +0000 (15:06 -0700)
meta
patches/refresh-temp [new file with mode: 0644]

diff --git a/meta b/meta
index 118cb2bd7405bd9c70b80d1cb245dc874fcdc65a..e9dc01cc7f5e8c35b9d778b7cc8c7263b0a065e7 100644 (file)
--- a/meta
+++ b/meta
@@ -1,9 +1,10 @@
 Version: 1
-Previous: c5e5b79678874f58dd99ce97571f7e13ce70eb79
-Head: 02f124a4ba5b3530bbce5cfbe28a343cd1b54260
+Previous: 116a8edd3fb819a75aefb33abedca70ee92ed897
+Head: b84021e12362153bf1d5248926bb2f153870eb37
 Applied:
   real-close: 3409f8d6af187d25c63a5d1f8ee8bff5f14555e2
   dup2: 02f124a4ba5b3530bbce5cfbe28a343cd1b54260
+  refresh-temp: b84021e12362153bf1d5248926bb2f153870eb37
 Unapplied:
   dbg: 0c269855776d3001e37da8c8afe283c20e1d6cd6
   waitall-buggy: c49c6b56c55385774065f5aa2704078e6ae0ceb8
diff --git a/patches/refresh-temp b/patches/refresh-temp
new file mode 100644 (file)
index 0000000..923b69f
--- /dev/null
@@ -0,0 +1,78 @@
+Bottom: 1ba59f6f7d9886c4ce5b8aa5fa06f770d53b8bf2
+Top:    7b4509e39407700f2b83499e2db1b89ccde97650
+Author: Sean Hefty <sean.hefty@intel.com>
+Date:   2012-08-06 15:06:17 -0700
+
+Refresh of dup2
+
+---
+
+diff --git a/src/preload.c b/src/preload.c
+index b716e66..ff7d2d0 100644
+--- a/src/preload.c
++++ b/src/preload.c
+@@ -106,7 +106,7 @@ enum fd_type {
+ struct fd_info {
+       enum fd_type type;
+       int fd;
+-      struct fd_info *dupfdi;
++      int dupfd;
+       atomic_t refcnt;
+ };
+@@ -125,6 +125,7 @@ static int fd_open(void)
+               goto err1;
+       }
++      fdi->dupfd = -1;
+       atomic_init(&fdi->refcnt);
+       atomic_set(&fdi->refcnt, 1);
+       pthread_mutex_lock(&mut);
+@@ -813,9 +814,27 @@ int shutdown(int socket, int how)
+ int close(int socket)
+ {
+-      int fd;
++      struct fd_info *fdi;
++
+       init_preload();
+-      return (fd_close(socket, &fd) == fd_rsocket) ? rclose(fd) : real.close(fd);
++      fdi = idm_lookup(&idm, socket);
++      if (!fdi)
++              return real.close(socket);
++
++      if (fdi->dupfd != -1) {
++              ret = close(fdi->dupfd);
++              if (ret)
++                      return ret;
++      }
++
++      if (atomic_dec(&fdi->refcnt))
++              return 0;
++
++      idm_clear(&idm, socket);
++      real.close(socket);
++      ret = (fdi->type == fd_rsocket) ? rclose(fdi->fd) : real.close(fdi->fd);
++      free(fdi);
++      return ret;
+ }
+ int getpeername(int socket, struct sockaddr *addr, socklen_t *addrlen)
+@@ -924,11 +943,14 @@ int dup2(int oldfd, int newfd)
+       idm_set(&idm, newfd, newfdi);
+       pthread_mutex_unlock(&mut);
+-      if (oldfdi->dupfdi)
+-              oldfdi = oldfdi->dupfdi;
+       newfdi->fd = oldfdi->fd;
+       newfdi->type = oldfdi->type;
+-      newfdi->dupfdi = oldfdi;
++      if (oldfdi->dupfd != -1) {
++              newfdi->dupfd = oldfdi->dupfd;
++              oldfdi = idm_lookup(&idm, oldfdi->dupfd);
++      } else {
++              newfdi->dupfd = oldfd;
++      }
+       atomic_init(&newfdi->refcnt);
+       atomic_set(&newfdi->refcnt, 1);
+       atomic_inc(&oldfdi->refcnt);