svn commit: lorikeet r771 - in trunk/heimdal/lib/roken: .
lha at samba.org
lha at samba.org
Mon Jul 16 17:47:00 GMT 2007
Author: lha
Date: 2007-07-16 17:46:59 +0000 (Mon, 16 Jul 2007)
New Revision: 771
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=lorikeet&rev=771
Log:
Merged with Heimdal svn revision 21593
Modified:
trunk/heimdal/lib/roken/ChangeLog
trunk/heimdal/lib/roken/socket_wrapper.c
Changeset:
Modified: trunk/heimdal/lib/roken/ChangeLog
===================================================================
--- trunk/heimdal/lib/roken/ChangeLog 2007-07-16 17:10:00 UTC (rev 770)
+++ trunk/heimdal/lib/roken/ChangeLog 2007-07-16 17:46:59 UTC (rev 771)
@@ -1,5 +1,7 @@
2007-07-16 Love Hörnquist Åstrand <lha at it.su.se>
+ * socket_wrapper.c: Implement swrap_dup too.
+
* socket_wrapper.c: Add dup(dummy stub) and dup2(real).
* socket_wrapper.h: Add dup(dummy stub) and dup2(real).
Modified: trunk/heimdal/lib/roken/socket_wrapper.c
===================================================================
--- trunk/heimdal/lib/roken/socket_wrapper.c 2007-07-16 17:10:00 UTC (rev 770)
+++ trunk/heimdal/lib/roken/socket_wrapper.c 2007-07-16 17:46:59 UTC (rev 771)
@@ -1837,15 +1837,53 @@
return ret;
}
+static int
+dup_internal(const struct socket_info *si_oldd, int fd)
+{
+ struct socket_info *si_newd;
+
+ si_newd = (struct socket_info *)calloc(1, sizeof(struct socket_info));
+
+ si_newd->fd = fd;
+
+ si_newd->family = si_oldd->family;
+ si_newd->type = si_oldd->type;
+ si_newd->protocol = si_oldd->protocol;
+ si_newd->bound = si_oldd->bound;
+ si_newd->bcast = si_oldd->bcast;
+ if (si_oldd->path)
+ si_newd->path = strdup(si_oldd->path);
+ if (si_oldd->tmp_path)
+ si_newd->tmp_path = strdup(si_oldd->tmp_path);
+ si_newd->myname =
+ sockaddr_dup(si_oldd->myname, si_oldd->myname_len);
+ si_newd->myname_len = si_oldd->myname_len;
+ si_newd->peername =
+ sockaddr_dup(si_oldd->peername, si_oldd->peername_len);
+ si_newd->peername_len = si_oldd->peername_len;
+
+ si_newd->io = si_oldd->io;
+
+ SWRAP_DLIST_ADD(sockets, si_newd);
+
+ return fd;
+}
+
+
_PUBLIC_ int swrap_dup(int oldd)
{
struct socket_info *si;
+ int fd;
si = find_socket_info(oldd);
if (si == NULL)
return real_dup(oldd);
- abort(); /* write code here */
+ fd = real_dup(si->fd);
+ if (fd < 0)
+ return fd;
+
+ return dup_internal(si, fd);
}
@@ -1870,30 +1908,6 @@
/* close new socket first */
if (si_newd)
swrap_close(newd);
-
- si_newd = (struct socket_info *)calloc(1, sizeof(struct socket_info));
- si_newd->fd = fd;
-
- si_newd->family = si_oldd->family;
- si_newd->type = si_oldd->type;
- si_newd->protocol = si_oldd->protocol;
- si_newd->bound = si_oldd->bound;
- si_newd->bcast = si_oldd->bcast;
- if (si_oldd->path)
- si_newd->path = strdup(si_oldd->path);
- if (si_oldd->tmp_path)
- si_newd->tmp_path = strdup(si_oldd->tmp_path);
- si_newd->myname =
- sockaddr_dup(si_oldd->myname, si_oldd->myname_len);
- si_newd->myname_len = si_oldd->myname_len;
- si_newd->peername =
- sockaddr_dup(si_oldd->peername, si_oldd->peername_len);
- si_newd->peername_len = si_oldd->peername_len;
-
- si_newd->io = si_oldd->io;
-
- SWRAP_DLIST_ADD(sockets, si_newd);
-
- return fd;
+ return dup_internal(si_oldd, fd);
}
More information about the samba-cvs
mailing list