Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/librumphijack * attempt to match libc non-compat names (...



details:   https://anonhg.NetBSD.org/src/rev/c5955f837b22
branches:  trunk
changeset: 761008:c5955f837b22
user:      pooka <pooka%NetBSD.org@localhost>
date:      Tue Jan 18 19:41:02 2011 +0000

description:
* attempt to match libc non-compat names (XXX: needs work)
* make shutdown() a dual-stack call
* flip the default to use host for PF_UNIX, since that's generally
  the desired case (because of X)

diffstat:

 lib/librumphijack/hijack.c |  43 ++++++++++++++++++++++++++++++++++---------
 1 files changed, 34 insertions(+), 9 deletions(-)

diffs (110 lines):

diff -r 2581a6463c3b -r c5955f837b22 lib/librumphijack/hijack.c
--- a/lib/librumphijack/hijack.c        Tue Jan 18 18:56:25 2011 +0000
+++ b/lib/librumphijack/hijack.c        Tue Jan 18 19:41:02 2011 +0000
@@ -1,4 +1,4 @@
-/*      $NetBSD: hijack.c,v 1.13 2011/01/18 16:00:04 pooka Exp $       */
+/*      $NetBSD: hijack.c,v 1.14 2011/01/18 19:41:02 pooka Exp $       */
 
 /*-
  * Copyright (c) 2011 Antti Kantee.  All Rights Reserved.
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: hijack.c,v 1.13 2011/01/18 16:00:04 pooka Exp $");
+__RCSID("$NetBSD: hijack.c,v 1.14 2011/01/18 19:41:02 pooka Exp $");
 
 #include <sys/param.h>
 #include <sys/types.h>
@@ -115,10 +115,30 @@
                               const struct timespec *, const sigset_t *);
 static pid_t   (*host_fork)(void);
 static int     (*host_dup2)(int, int);
+static int     (*host_shutdown)(int, int);
 
 static void *rumpcalls[RUMPCALL__NUM];
 
 /*
+ * Would be nice to get this automatically in sync with libc.
+ * Also, this does not work for compat-using binaries!
+ */
+
+#if !__NetBSD_Prereq__(5,99,7)
+#define SELECT select
+#define POLLTS pollts
+#define POLL poll
+#else
+#define SELECT __select50
+#define POLLTS __pollts50
+#define POLL __poll50
+
+int SELECT(int, fd_set *, fd_set *, fd_set *, struct timeval *);
+int POLLTS(struct pollfd *, nfds_t, const struct timespec *, const sigset_t *);
+int POLL(struct pollfd *, nfds_t, int);
+#endif
+
+/*
  * This is called from librumpclient in case of LD_PRELOAD.
  * It ensures correct RTLD_NEXT.
  */
@@ -130,7 +150,7 @@
 }
 
 /* low calorie sockets? */
-static bool hostlocalsockets = false;
+static bool hostlocalsockets = true;
 
 static void __attribute__((constructor))
 rcinit(void)
@@ -168,6 +188,7 @@
        host_pollts = dlsym(RTLD_NEXT, "pollts");
        host_fork = dlsym(RTLD_NEXT, "fork");
        host_dup2 = dlsym(RTLD_NEXT, "dup2");
+       host_shutdown = dlsym(RTLD_NEXT, "shutdown");
 
        for (i = 0; i < RUMPCALL__NUM; i++) {
                rumpcalls[i] = dlsym(hand, sysnames[i]);
@@ -462,9 +483,13 @@
        int (*rc_shutdown)(int, int);
 
        DPRINTF(("shutdown -> %d\n", s));
-       assertfd(s);
-       rc_shutdown = rumpcalls[RUMPCALL_SHUTDOWN];
-       return rc_shutdown(fd_host2rump(s), how);
+       if (fd_isrump(s)) {
+               rc_shutdown = rumpcalls[RUMPCALL_SHUTDOWN];
+               s = fd_host2rump(s);
+       } else {
+               rc_shutdown = host_shutdown;
+       }
+       return rc_shutdown(s, how);
 }
 
 /*
@@ -658,7 +683,7 @@
 }
 
 int
-select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
+SELECT(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
        struct timeval *timeout)
 {
        struct pollfd *pfds;
@@ -820,7 +845,7 @@
 }
 
 int
-pollts(struct pollfd *fds, nfds_t nfds, const struct timespec *ts,
+POLLTS(struct pollfd *fds, nfds_t nfds, const struct timespec *ts,
        const sigset_t *sigmask)
 {
        int (*op_pollts)(struct pollfd *, nfds_t, const struct timespec *,
@@ -957,7 +982,7 @@
 }
 
 int
-poll(struct pollfd *fds, nfds_t nfds, int timeout)
+POLL(struct pollfd *fds, nfds_t nfds, int timeout)
 {
        struct timespec ts;
        struct timespec *tsp = NULL;



Home | Main Index | Thread Index | Old Index