Source-Changes-HG archive

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

[src/trunk]: src Remove code supporting SOCK_STREAM, as SOCK_DGRAM works fine



details:   https://anonhg.NetBSD.org/src/rev/580fc17559ac
branches:  trunk
changeset: 757987:580fc17559ac
user:      manu <manu%NetBSD.org@localhost>
date:      Mon Oct 11 05:37:58 2010 +0000

description:
Remove code supporting SOCK_STREAM, as SOCK_DGRAM works fine

diffstat:

 lib/libperfuse/ops.c          |    2 +-
 lib/libperfuse/perfuse.c      |   10 +-
 lib/libperfuse/perfuse_if.h   |    3 +-
 lib/libperfuse/perfuse_priv.h |    2 +-
 lib/libperfuse/subr.c         |    7 +-
 usr.sbin/perfused/msg.c       |  204 ++++++++++++++++-------------------------
 usr.sbin/perfused/perfused.c  |   28 +-----
 7 files changed, 88 insertions(+), 168 deletions(-)

diffs (truncated from 442 to 300 lines):

diff -r de316adefb28 -r 580fc17559ac lib/libperfuse/ops.c
--- a/lib/libperfuse/ops.c      Mon Oct 11 01:52:05 2010 +0000
+++ b/lib/libperfuse/ops.c      Mon Oct 11 05:37:58 2010 +0000
@@ -1,4 +1,4 @@
-/*  $NetBSD: ops.c,v 1.22 2010/10/11 01:52:05 manu Exp $ */
+/*  $NetBSD: ops.c,v 1.23 2010/10/11 05:37:58 manu Exp $ */
 
 /*-
  *  Copyright (c) 2010 Emmanuel Dreyfus. All rights reserved.
diff -r de316adefb28 -r 580fc17559ac lib/libperfuse/perfuse.c
--- a/lib/libperfuse/perfuse.c  Mon Oct 11 01:52:05 2010 +0000
+++ b/lib/libperfuse/perfuse.c  Mon Oct 11 05:37:58 2010 +0000
@@ -1,4 +1,4 @@
-/*  $NetBSD: perfuse.c,v 1.10 2010/10/03 05:46:47 manu Exp $ */
+/*  $NetBSD: perfuse.c,v 1.11 2010/10/11 05:37:58 manu Exp $ */
 
 /*-
  *  Copyright (c) 2010 Emmanuel Dreyfus. All rights reserved.
@@ -115,7 +115,7 @@
        if (strcmp(path, _PATH_FUSE) != 0)
                return open(path, flags, mode);
 
-       if ((sv[0] = socket(PF_LOCAL, PERFUSE_SOCKTYPE, 0)) == -1) {
+       if ((sv[0] = socket(PF_LOCAL, SOCK_DGRAM, 0)) == -1) {
 #ifdef PERFUSE_DEBUG
                DWARN("%s:%d socket failed: %s", __func__, __LINE__);
 #endif
@@ -149,7 +149,7 @@
         * we will talk using a socketpair 
         * instead of /dev/fuse.
         */
-       if (socketpair(PF_LOCAL, PERFUSE_SOCKTYPE, 0, sv) != 0) {
+       if (socketpair(PF_LOCAL, SOCK_DGRAM, 0, sv) != 0) {
                DWARN("%s:%d: socketpair failed", __func__, __LINE__);
                return -1;
        }
@@ -218,12 +218,10 @@
        int s;
        size_t len;
        struct perfuse_mount_out *pmo;
-#if (PERFUSE_SOCKTYPE == SOCK_DGRAM)
        struct sockaddr_storage ss;
        struct sockaddr_un *sun;
        struct sockaddr *sa;
        socklen_t sa_len;
-#endif
        size_t sock_len;
        char *frame;
        char *cp;
@@ -244,7 +242,6 @@
         * XXX This socket is not removed at exit time yet
         */
        sock_len = 0;
-#if (PERFUSE_SOCKTYPE == SOCK_DGRAM)
        sa = (struct sockaddr *)(void *)&ss;
        sun = (struct sockaddr_un *)(void *)&ss;
        sa_len = sizeof(ss);
@@ -263,7 +260,6 @@
 
                sock_len = strlen(sun->sun_path) + 1;
        }
-#endif /* PERFUSE_SOCKTYPE */
                
        len = sizeof(*pmo);
        len += source ? (uint32_t)strlen(source) + 1 : 0;
diff -r de316adefb28 -r 580fc17559ac lib/libperfuse/perfuse_if.h
--- a/lib/libperfuse/perfuse_if.h       Mon Oct 11 01:52:05 2010 +0000
+++ b/lib/libperfuse/perfuse_if.h       Mon Oct 11 05:37:58 2010 +0000
@@ -1,4 +1,4 @@
-/*  $NetBSD: perfuse_if.h,v 1.9 2010/09/23 16:02:34 manu Exp $ */
+/*  $NetBSD: perfuse_if.h,v 1.10 2010/10/11 05:37:58 manu Exp $ */
 
 /*-
  *  Copyright (c) 2010 Emmanuel Dreyfus. All rights reserved.
@@ -36,7 +36,6 @@
 #define PERFUSE_MOUNT_MAGIC "noFuseRq"
 #define PERFUSE_UNKNOWN_INO 0xffffffff
 
-#define PERFUSE_SOCKTYPE SOCK_DGRAM
 /* 
  * Diagnostic flags. This global is used only for DPRINTF/DERR/DWARN
  */
diff -r de316adefb28 -r 580fc17559ac lib/libperfuse/perfuse_priv.h
--- a/lib/libperfuse/perfuse_priv.h     Mon Oct 11 01:52:05 2010 +0000
+++ b/lib/libperfuse/perfuse_priv.h     Mon Oct 11 05:37:58 2010 +0000
@@ -1,4 +1,4 @@
-/*  $NetBSD: perfuse_priv.h,v 1.15 2010/10/11 01:08:26 manu Exp $ */
+/*  $NetBSD: perfuse_priv.h,v 1.16 2010/10/11 05:37:58 manu Exp $ */
 
 /*-
  *  Copyright (c) 2010 Emmanuel Dreyfus. All rights reserved.
diff -r de316adefb28 -r 580fc17559ac lib/libperfuse/subr.c
--- a/lib/libperfuse/subr.c     Mon Oct 11 01:52:05 2010 +0000
+++ b/lib/libperfuse/subr.c     Mon Oct 11 05:37:58 2010 +0000
@@ -1,4 +1,4 @@
-/*  $NetBSD: subr.c,v 1.9 2010/10/11 01:08:26 manu Exp $ */
+/*  $NetBSD: subr.c,v 1.10 2010/10/11 05:37:58 manu Exp $ */
 
 /*-
  *  Copyright (c) 2010 Emmanuel Dreyfus. All rights reserved.
@@ -44,12 +44,9 @@
        const char *name;
        struct puffs_node *parent;
 {
-       struct perfuse_state *ps;
        struct puffs_node *pn;
        struct perfuse_node_data *pnd;
 
-       ps = puffs_getspecific(pu);
-
        if ((pnd = malloc(sizeof(*pnd))) == NULL)
                DERR(EX_OSERR, "malloc failed");
 
@@ -84,10 +81,8 @@
        struct puffs_usermount *pu;
        struct puffs_node *pn;
 {
-       struct perfuse_state *ps;
        struct perfuse_node_data *pnd;
 
-       ps = puffs_getspecific(pu);
        pnd = PERFUSE_NODE_DATA(pn);
 
        if (pnd->pnd_parent != NULL) {
diff -r de316adefb28 -r 580fc17559ac usr.sbin/perfused/msg.c
--- a/usr.sbin/perfused/msg.c   Mon Oct 11 01:52:05 2010 +0000
+++ b/usr.sbin/perfused/msg.c   Mon Oct 11 05:37:58 2010 +0000
@@ -1,4 +1,4 @@
-/*  $NetBSD: msg.c,v 1.8 2010/10/11 01:12:25 manu Exp $ */
+/*  $NetBSD: msg.c,v 1.9 2010/10/11 05:37:58 manu Exp $ */
 
 /*-
  *  Copyright (c) 2010 Emmanuel Dreyfus. All rights reserved.
@@ -59,7 +59,7 @@
 
        (void)unlink(_PATH_FUSE);
 
-       if ((s = socket(AF_LOCAL, PERFUSE_SOCKTYPE, 0)) == -1)
+       if ((s = socket(AF_LOCAL, SOCK_DGRAM, 0)) == -1)
                err(EX_OSERR, "socket failed");
 
        sa = (const struct sockaddr *)(void *)&sun;
@@ -90,13 +90,8 @@
        if (bind(s, sa, (socklen_t )sun.sun_len) == -1)
                err(EX_OSERR, "cannot open \"%s\" socket", _PATH_FUSE);
 
-#if (PERFUSE_SOCKTYPE == SOCK_DGRAM)
        if (connect(s, sa, (socklen_t )sun.sun_len) == -1)
                err(EX_OSERR, "cannot open \"%s\" socket", _PATH_FUSE);
-#else
-       if (listen(s, 1) == -1) 
-               err(EX_OSERR, "listen failed");
-#endif
 
        return s;
 }
@@ -475,116 +470,85 @@
        int *done;
 {
        struct fuse_out_header foh;
-       size_t offset;
-       size_t remain;
+       size_t len;
        ssize_t readen;
        void *data;
-       int peek = 0;
-
-#if (PERFUSE_SOCKTYPE == SOCK_DGRAM)
-       peek = MSG_PEEK;
-#endif
-       offset = puffs_framebuf_telloff(pufbuf);
 
        /*
         * Read the header 
-        * MSG_PEEK is used so that this code works for SOCK_DGRAM
-        * socket. The loop is only needed to work with SOCK_STREAM. 
         */
-       while (offset < sizeof(foh)) {
-               remain = sizeof(foh) - offset;
-               PUFFS_FRAMEBUF_GETWINDOW(pufbuf, offset, &data, &remain);
+       len = sizeof(foh);
+       PUFFS_FRAMEBUF_GETWINDOW(pufbuf, 0, &data, &len);
 
-               switch (readen = recv(fd, data, remain, MSG_NOSIGNAL|peek)) {
-               case 0:
-                       DWARNX("%s: recv retunred 0", __func__);
-                       return ECONNRESET;
-                       /* NOTREACHED */
-                       break;
-               case -1:
-                       if (errno == EAGAIN)
-                               return 0;
-                       DWARN("%s: recv retunred -1", __func__);
-                       return errno;
-                       /* NOTREACHED */
-                       break;
-               default:
-#if defined(PERFUSE_DEBUG) && (PERFUSE_SOCKTYPE == SOCK_DGRAM)
-                       if (readen != remain)
-                               DERRX(EX_SOFTWARE, "%s: short recv %zd/%zd",
-                                     __func__, readen, remain);
-#endif
-                       break;
-               }
-
-               offset += readen;
-               if (puffs_framebuf_seekset(pufbuf, offset) == -1)
-                       DERR(EX_OSERR, "puffs_framebuf_seekset failed");
+       switch (readen = recv(fd, data, len, MSG_NOSIGNAL|MSG_PEEK)) {
+       case 0:
+               DWARNX("%s: recv retunred 0", __func__);
+               return ECONNRESET;
+               /* NOTREACHED */
+               break;
+       case -1:
+               if (errno == EAGAIN)
+                       return 0;
+               DWARN("%s: recv retunred -1", __func__);
+               return errno;
+               /* NOTREACHED */
+               break;
+       default:
+               break;
        }
 
-#if (PERFUSE_SOCKTYPE == SOCK_DGRAM)
-       /*
-        * We had a peek at the header, now really read it.
-        */
-       offset = 0;
+#ifdef PERFUSE_DEBUG
+       if (readen != len)
+               DERRX(EX_SOFTWARE, "%s: short recv %zd/%zd",
+                     __func__, readen, len);
 #endif
-       
+
        /*
         * We have a header, get remaing length to read
         */
        if (puffs_framebuf_getdata_atoff(pufbuf, 0, &foh, sizeof(foh)) != 0)
                DERR(EX_SOFTWARE, "puffs_framebuf_getdata_atoff failed");
-;
+
+       len = foh.len;
+
 #ifdef PERFUSE_DEBUG
-               if (foh.len > FUSE_BUFSIZE)
-                       DERRX(EX_SOFTWARE, "%s: foh.len = %d (this is huge!)", 
-                             __func__, foh.len);
+       if (len > FUSE_BUFSIZE)
+               DERRX(EX_SOFTWARE, "%s: foh.len = %d", __func__, len);
 #endif
 
        /*
-        * If we have only readen the header so far, 
-        * this is time to reserve space.
+        * This is time to reserve space.
         */
-       remain = foh.len - offset;
-       if (offset == sizeof(foh))
-               if (puffs_framebuf_reserve_space(pufbuf, remain) == -1)
-                       DERR(EX_OSERR, "puffs_framebuf_reserve_space failed");
-
+       if (puffs_framebuf_reserve_space(pufbuf, len) == -1)
+               DERR(EX_OSERR, "puffs_framebuf_reserve_space failed");
 
        /*
         * And read the remaining data
         */ 
-       while (remain != 0) {
-               PUFFS_FRAMEBUF_GETWINDOW(pufbuf, offset, &data, &remain);
+       PUFFS_FRAMEBUF_GETWINDOW(pufbuf, 0, &data, &len);
 
-               switch (readen = recv(fd, data, remain, MSG_NOSIGNAL)) {
-               case 0:
-                       DWARNX("%s: recv retunred 0", __func__);
-                       return ECONNRESET;
-                       /* NOTREACHED */
-                       break;
-               case -1:
-                       if (errno == EAGAIN)
-                               return 0;
-                       DWARN("%s: recv retunred -1", __func__);
-                       return errno;
-                       /* NOTREACHED */
-                       break;
-               default:
-#if defined(PERFUSE_DEBUG) && (PERFUSE_SOCKTYPE == SOCK_DGRAM)
-                       if (readen != remain)
-                               DERRX(EX_SOFTWARE, "%s: short recv %zd/%zd",
-                                     __func__, readen, remain);
+       switch (readen = recv(fd, data, len, MSG_NOSIGNAL)) {
+       case 0:
+               DWARNX("%s: recv retunred 0", __func__);
+               return ECONNRESET;
+               /* NOTREACHED */
+               break;
+       case -1:
+               if (errno == EAGAIN)



Home | Main Index | Thread Index | Old Index