common: {dgram,stream}-transport fixes.
authorKrisztian Litkey <krisztian.litkey@intel.com>
Mon, 4 Jun 2012 15:10:52 +0000 (18:10 +0300)
committerKrisztian Litkey <krisztian.litkey@intel.com>
Mon, 4 Jun 2012 15:10:52 +0000 (18:10 +0300)
src/common/dgram-transport.c
src/common/stream-transport.c
src/common/tests/transport-test.c

index 8477256..3dceaa2 100644 (file)
@@ -60,7 +60,7 @@ static int parse_address(const char *str, int *familyp, char *nodep,
 
     node = (char *)str;
 
-    if (!strncmp(node, UDP4, l=UDP4L+1)) {
+    if (!strncmp(node, UDP4":", l=UDP4L+1)) {
        family = AF_INET;
        type   = UDP4;
        node  += l;
@@ -441,8 +441,6 @@ static int dgrm_connect(mrp_transport_t *mu, mrp_sockaddr_t *addr,
        nb = 1;
        fcntl(u->sock, F_SETFL, O_NONBLOCK, nb);
 
-       u->connected = TRUE;
-
        return TRUE;
     }
     
@@ -458,7 +456,6 @@ static int dgrm_disconnect(mrp_transport_t *mu)
 
     if (u->connected) {
        connect(u->sock, &none, sizeof(none));
-       u->connected = FALSE;
        
        return TRUE;
     }
@@ -670,7 +667,7 @@ static int dgrm_senddatato(mrp_transport_t *mu, void *data, uint16_t tag,
 }
 
 
-MRP_REGISTER_TRANSPORT(udp4, "udp4", dgrm_t, dgrm_resolve,
+MRP_REGISTER_TRANSPORT(udp4, UDP4, dgrm_t, dgrm_resolve,
                       dgrm_open, dgrm_createfrom, dgrm_close,
                       dgrm_bind, dgrm_listen, NULL,
                       dgrm_connect, dgrm_disconnect,
@@ -678,7 +675,7 @@ MRP_REGISTER_TRANSPORT(udp4, "udp4", dgrm_t, dgrm_resolve,
                       dgrm_sendraw, dgrm_sendrawto,
                       dgrm_senddata, dgrm_senddatato);
 
-MRP_REGISTER_TRANSPORT(udp6, "udp6", dgrm_t, dgrm_resolve,
+MRP_REGISTER_TRANSPORT(udp6, UDP6, dgrm_t, dgrm_resolve,
                       dgrm_open, dgrm_createfrom, dgrm_close,
                       dgrm_bind, dgrm_listen, NULL,
                       dgrm_connect, dgrm_disconnect,
@@ -686,7 +683,7 @@ MRP_REGISTER_TRANSPORT(udp6, "udp6", dgrm_t, dgrm_resolve,
                       dgrm_sendraw, dgrm_sendrawto,
                       dgrm_senddata, dgrm_senddatato);
 
-MRP_REGISTER_TRANSPORT(unxdgrm, "unxd", dgrm_t, dgrm_resolve,
+MRP_REGISTER_TRANSPORT(unxdgrm, UNXD, dgrm_t, dgrm_resolve,
                       dgrm_open, dgrm_createfrom, dgrm_close,
                       dgrm_bind, dgrm_listen, NULL,
                       dgrm_connect, dgrm_disconnect,
index f66c0b6..a112939 100644 (file)
@@ -242,11 +242,8 @@ static int strm_createfrom(mrp_transport_t *mt, void *conn)
            events = MRP_IO_EVENT_IN | MRP_IO_EVENT_HUP;
            t->iow = mrp_add_io_watch(t->ml, t->sock, events, strm_recv_cb, t);
            
-           if (t->iow != NULL) {
-               t->connected = TRUE;
-
+           if (t->iow != NULL)
                return TRUE;
-           }
        }
     }
     
@@ -315,11 +312,8 @@ static int strm_accept(mrp_transport_t *mt, mrp_transport_t *mlt)
        events = MRP_IO_EVENT_IN | MRP_IO_EVENT_HUP;
        t->iow = mrp_add_io_watch(t->ml, t->sock, events, strm_recv_cb, t);
            
-       if (t->iow != NULL) {
-           t->connected = TRUE;
-           
+       if (t->iow != NULL)
            return TRUE;
-       }
        else {
            close(t->sock);
            t->sock = -1;
@@ -511,8 +505,6 @@ static int strm_connect(mrp_transport_t *mt, mrp_sockaddr_t *addr,
            setsockopt(t->sock, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on));
            nb = 1;
            fcntl(t->sock, F_SETFL, O_NONBLOCK, nb);
-
-           t->connected = TRUE;
            
            return TRUE;
        }
@@ -536,7 +528,6 @@ static int strm_disconnect(mrp_transport_t *mt)
        t->iow = NULL;
 
        shutdown(t->sock, SHUT_RDWR);
-       t->connected = FALSE;
 
        return TRUE;
     }
@@ -650,7 +641,7 @@ static int strm_senddata(mrp_transport_t *mt, void *data, uint16_t tag)
 }
 
 
-MRP_REGISTER_TRANSPORT(tcp4, "tcp4", strm_t, strm_resolve,
+MRP_REGISTER_TRANSPORT(tcp4, TCP4, strm_t, strm_resolve,
                       strm_open, strm_createfrom, strm_close,
                       strm_bind, strm_listen, strm_accept,
                       strm_connect, strm_disconnect,
@@ -658,7 +649,7 @@ MRP_REGISTER_TRANSPORT(tcp4, "tcp4", strm_t, strm_resolve,
                       strm_sendraw, NULL,
                       strm_senddata, NULL);
 
-MRP_REGISTER_TRANSPORT(tcp6, "tcp6", strm_t, strm_resolve,
+MRP_REGISTER_TRANSPORT(tcp6, TCP6, strm_t, strm_resolve,
                       strm_open, strm_createfrom, strm_close,
                       strm_bind, strm_listen, strm_accept,
                       strm_connect, strm_disconnect,
@@ -666,7 +657,7 @@ MRP_REGISTER_TRANSPORT(tcp6, "tcp6", strm_t, strm_resolve,
                       strm_sendraw, NULL,
                       strm_senddata, NULL);
 
-MRP_REGISTER_TRANSPORT(unxstrm, "unxs", strm_t, strm_resolve,
+MRP_REGISTER_TRANSPORT(unxstrm, UNXS, strm_t, strm_resolve,
                       strm_open, strm_createfrom, strm_close,
                       strm_bind, strm_listen, strm_accept,
                       strm_connect, strm_disconnect,
index 7aa41b6..c9c079b 100644 (file)
@@ -512,6 +512,7 @@ static void print_usage(const char *argv0, int exit_code, const char *fmt, ...)
            "  -s, --server                   run as test server (default)\n"
           "  -C, --connect                  connect transport\n"
           "      For connection-oriented transports, this is automatic.\n"
+          "  -a, --address                  address to use\n"
           "  -c, --custom                   use custom messages\n"
           "  -m, --message                  use generic messages (default)\n"
            "  -t, --log-target=TARGET        log target to use\n"