gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r28099 - msh/src


From: gnunet
Subject: [GNUnet-SVN] r28099 - msh/src
Date: Tue, 16 Jul 2013 23:33:22 +0200

Author: harsha
Date: 2013-07-16 23:33:21 +0200 (Tue, 16 Jul 2013)
New Revision: 28099

Modified:
   msh/src/addressmap.c
   msh/src/addressmap.h
   msh/src/mshd.c
   msh/src/test_addressmap.c
Log:
- use IP and port number as instance address instead of using sockaddr 
structures;
- fix address iterator is mshd.c


Modified: msh/src/addressmap.c
===================================================================
--- msh/src/addressmap.c        2013-07-16 19:08:17 UTC (rev 28098)
+++ msh/src/addressmap.c        2013-07-16 21:33:21 UTC (rev 28099)
@@ -26,14 +26,14 @@
   struct InstanceAddr *prev;
 
   /**
-   * The length of the instance address
+   * the port
    */
-  socklen_t addrlen;
+  uint16_t port;
 
   /**
-   * The instance address to be followed here
+   * the ip address
    */
-  struct sockaddr saddr[0];
+  in_addr_t ip;
 };
 
 
@@ -68,35 +68,41 @@
  * Get the 32bit IP addresses from an instance address
  */
 #define instance_address_ip(iaddr) \
-  ((uint32_t) ((struct sockaddr_in *)iaddr->saddr)->sin_addr.s_addr)
+  ((uint32_t) iaddr->ip)
 
 
 /**
  * Create an instance address structure from its port number and ip address
  *
- * @param port the number in network byte format
- * @param ip 32-bit IP address in network byte format
+ * @param port the port number
+ * @param ip 32-bit IP address
  * @return instace address structure
  */
 struct InstanceAddr *
 instance_address_create_sockaddr_in (uint16_t port, in_addr_t ip)
 {
   struct InstanceAddr *iaddr;
-  struct sockaddr_in *sinaddr;
-  socklen_t addrlen;
 
-  addrlen = sizeof (struct sockaddr_in);
-  iaddr = MSH_malloc (sizeof (struct InstanceAddr) + addrlen);
-  iaddr->addrlen = addrlen;
-  sinaddr = (struct sockaddr_in *) iaddr->saddr;
-  sinaddr->sin_family = AF_INET;
-  sinaddr->sin_port = port;
-  sinaddr->sin_addr.s_addr = ip;
+  iaddr = MSH_malloc (sizeof (struct InstanceAddr));
+  iaddr->port = port;
+  iaddr->ip = ip;
   return iaddr;
 }
 
 
 /**
+ * Releases the resources occupied by the instance address object
+ *
+ * @param iaddr the instance address object
+ */
+void
+instance_address_destroy (struct InstanceAddr *iaddr)
+{
+  free (iaddr);
+}
+
+
+/**
  * Create an instance address information object
  *
  * @param rank the MPI rank of the instance
@@ -118,8 +124,11 @@
  *
  * @param iainfo the instance information object
  * @param iaddr the address to add
+ * @return MSH_OK if the instance address is added; MSH_NO if the given address
+ *           is already present (in this case the address object will not be
+ *           added)
  */
-void
+int
 instance_address_info_add_address (struct InstanceAddrInfo *iainfo,
                                    struct InstanceAddr *iaddr)
 {
@@ -129,10 +138,7 @@
   while (NULL != addr)
   {
     if (instance_address_ip (iaddr) == instance_address_ip (addr))
-    {
-      MSH_break (0);
-      return;
-    }
+      return MSH_NO;
     if (instance_address_ip (iaddr) < instance_address_ip (addr))
       break;
     addr = addr->next;
@@ -141,9 +147,10 @@
   if (NULL == addr)
   {
     DLL_insert_tail (iainfo->addr_head, iainfo->addr_tail, iaddr);
-    return;
+    return MSH_OK;
   }
-  DLL_insert_before (iainfo->addr_head, iainfo->addr_tail, addr, iaddr);  
+  DLL_insert_before (iainfo->addr_head, iainfo->addr_tail, addr, iaddr);
+  return MSH_OK;
 }
 
 
@@ -168,7 +175,7 @@
   iaddr = iainfo->addr_head;
   while (NULL != iaddr)
   {
-    if (MSH_OK != cb (cls, iaddr->saddr, iaddr->addrlen))
+    if (MSH_OK != cb (cls, iaddr->port, iaddr->ip))
       return MSH_SYSERR;
     iaddr = iaddr->next;
   }
@@ -184,7 +191,7 @@
  * @return the rank of the instance
  */
 unsigned int
-instance_address_get_rank (const struct InstanceAddrInfo *iainfo)
+instance_address_info_get_rank (const struct InstanceAddrInfo *iainfo)
 {
   return iainfo->rank;
 }
@@ -250,51 +257,33 @@
  * Add an address to the address map
  *
  * @param m the address map
- * @param new the new instance address info object to add into the address map
+ * @param rank the MPI rank of the instance whose address is being added
+ * @param port the port number through which the instance is reachable
+ * @param ip the IP address through which the instance is reachable
+ * @return MSH_OK if the instance address is added; MSH_NO if the given address
+ *           is already present (in this case the address object will not be
+ *           added)
  */
-void
-addressmap_add (AddressMap *m, struct InstanceAddrInfo *new)
+int
+addressmap_add (AddressMap *m, unsigned int rank, uint16_t port, in_addr_t ip)
 {
-  struct InstanceAddrInfo *old;
-  struct InstanceAddr *old_ia;
-  struct InstanceAddr *new_ia;
-  struct InstanceAddr *iacpy;
-  unsigned int rank;
+  struct InstanceAddrInfo *iainfo;
+  struct InstanceAddr *iaddr;
 
-  rank = new->rank;
   MSH_assert (rank < m->size);
-  old = m->map[rank];
-  if (NULL == old)
+  iainfo = m->map[rank];
+  if (NULL == iainfo)
   {
-    m->map[rank] = new;
-    return;
+    m->map[rank] = instance_address_info_create (rank);
+    iainfo = m->map[rank];
   }
-  old_ia = old->addr_head;
-  new_ia = new->addr_head;
-  while (NULL != new_ia)
-  {    
-    while (NULL != old_ia)
-    {
-      if (instance_address_ip (new_ia) == instance_address_ip (old_ia))
-        goto next;
-      if (instance_address_ip (new_ia) < instance_address_ip (old_ia))
-        break;
-      old_ia = old_ia->next;
-    }    
-    iacpy = MSH_malloc (sizeof (struct InstanceAddr) + new_ia->addrlen);
-    (void) memcpy (iacpy->saddr, new_ia->saddr, new_ia->addrlen);
-    iacpy->addrlen = new_ia->addrlen;
-    old->naddrs++;
-    if (NULL == old_ia)
-    {
-      DLL_insert_tail (old->addr_head, old->addr_tail, iacpy);
-      goto next;
-    }
-    DLL_insert_before (old->addr_head, old->addr_tail, old_ia, iacpy);
-
-  next:
-    new_ia = new_ia->next;
+  iaddr = instance_address_create_sockaddr_in (port, ip);
+  if (MSH_NO == instance_address_info_add_address (iainfo, iaddr))
+  {
+    instance_address_destroy (iaddr);
+    return MSH_NO;
   }
+  return MSH_OK;
 }
 
 
@@ -417,6 +406,14 @@
 void
 addressmap_destroy (AddressMap *m)
 {
+  unsigned int cnt;
+    
+  for (cnt = 0; cnt < m->size; cnt++)
+  {
+    if (NULL == m->map[cnt])
+      continue;
+    instance_address_info_destroy (m->map[cnt]);
+  }
   free (m);
 }
 

Modified: msh/src/addressmap.h
===================================================================
--- msh/src/addressmap.h        2013-07-16 19:08:17 UTC (rev 28098)
+++ msh/src/addressmap.h        2013-07-16 21:33:21 UTC (rev 28099)
@@ -25,8 +25,8 @@
 /**
  * Create an instance address structure from its port number and ip address
  *
- * @param port the number in network byte format
- * @param ip 32-bit IP address in network byte format
+ * @param port the port number
+ * @param ip 32-bit IP address
  * @return instace address structure
  */
 struct InstanceAddr *
@@ -44,12 +44,24 @@
 
 
 /**
+ * Releases the resources occupied by the instance address object
+ *
+ * @param iaddr the instance address object
+ */
+void
+instance_address_destroy (struct InstanceAddr *iaddr);
+
+
+/**
  * Add an address to the address information object
  *
  * @param iainfo the instance information object
  * @param iaddr the address to add
+ * @return MSH_OK if the instance address is added; MSH_NO if the given address
+ *           is already present (in this case the address object will not be
+ *           added)
  */
-void
+int
 instance_address_info_add_address (struct InstanceAddrInfo *iainfo,
                                    struct InstanceAddr *iaddr);
 
@@ -61,7 +73,7 @@
  * @return the rank of the instance
  */
 unsigned int
-instance_address_get_rank (const struct InstanceAddrInfo *iainfo);
+instance_address_info_get_rank (const struct InstanceAddrInfo *iainfo);
 
 
 /**
@@ -79,13 +91,13 @@
  * address info object
  *
  * @param cls the closure passed to instance_address_info_iterate_addresses()
- * @param addr the address of the instance
- * @param addrlen the address length
+ * @param port the port where the instance is listening
+ * @param ip the ip of the instance
  * @return MSH_OK to continue iteration; MSH_SYSERR to terminate
  */
 typedef int (*instance_address_info_address_iterate_cb) (void *cls,
-                                                         struct sockaddr *addr,
-                                                         socklen_t addrlen);
+                                                         uint16_t port,
+                                                         in_addr_t ip);
 
 
 /**
@@ -134,10 +146,15 @@
  * Add an address to the address map
  *
  * @param m the address map
- * @param new the new instance address info object to add into the address map
+ * @param rank the MPI rank of the instance whose address is being added
+ * @param port the port number through which the instance is reachable
+ * @param ip the IP address through which the instance is reachable
+ * @return MSH_OK if the instance address is added; MSH_NO if the given address
+ *           is already present (in this case the address object will not be
+ *           added)
  */
-void
-addressmap_add (AddressMap *m, struct InstanceAddrInfo *new);
+int
+addressmap_add (AddressMap *m, unsigned int rank, uint16_t port, in_addr_t ip);
 
 
 /**
@@ -157,11 +174,11 @@
  * address map
  *
  * @param cls the closure passed to addressmap_iterate_instance_address_infos()
- * @param iaddr the instance address info object
+ * @param iainfo the instance address info object
  * @return MSH_OK to continue iteration; MSH_SYSERR to terminate
  */
 typedef int (*instance_address_info_iterator_cb) (void *cls,
-                                                  struct InstanceAddrInfo 
*iaddr);
+                                                  struct InstanceAddrInfo 
*iainfo);
 
 
 /**

Modified: msh/src/mshd.c
===================================================================
--- msh/src/mshd.c      2013-07-16 19:08:17 UTC (rev 28098)
+++ msh/src/mshd.c      2013-07-16 21:33:21 UTC (rev 28099)
@@ -37,14 +37,14 @@
   struct Task *close_task;
 
   /**
-   * the instance's address being verified in association with this context
+   * the port number
    */
-  struct sockaddr *saddr;
+  uint16_t port;
 
   /**
-   * The length of the above address
+   * the ip address
    */
-  socklen_t addrlen;
+  in_addr_t ip;
 
   /**
    * The socket file descriptor associated with the connection used to verify
@@ -125,6 +125,11 @@
 static struct ReadContext *rtail;
 
 /**
+ * Mapping for instance addresses
+ */
+static struct AddressMap *addrmap;
+
+/**
  * The number of total mshd processes 
  */
 static int nproc;
@@ -176,6 +181,20 @@
 }
 
 
+static char *
+ip2str (const in_addr_t ip)
+{
+  static char hostip[NI_MAXHOST];
+  
+  MSH_break (0 < snprintf (hostip, NI_MAXHOST, "%u.%u.%u.%u",
+                           ip >> 24, 
+                           (ip >> 16) % 256,
+                           (ip >> 8) % 256,
+                           ip % 256));
+  return hostip;
+}
+
+
 /**
  * Callback function invoked for each interface found.
  *
@@ -317,14 +336,17 @@
      in parallel in each round) */
   trounds = ((nproc - 1) + (rwidth - 1)) / rwidth;
   if (round < trounds)
+  {
     rtask = scheduler_add (&run_round, NULL, TV_IMMEDIATE);
-  else
-    LOG_DEBUG ("Verification phase complete; commencing reduction phase\n");
+    return;
+  }
+  LOG_DEBUG ("Verification phase complete; commencing reduction phase\n");
+  //ntree_reduction ();
 }
 
 
 /**
- * Callback trigger to finalise a round
+ * Callback triggered to finalise a round
  *
  * @param sock -1 do not use this
  * @param flags EV_* flags
@@ -370,15 +392,15 @@
 
 
 /**
- * Callback triggered when the data on the sock is written.  This function
- * closes the socket.
+ * Callback triggered when the data on the sock is written and the socket is
+ * available for writing again.  We close the associated socket in this 
callback.
  *
  * @param sock the socket file descriptor
  * @param flags EV_* flags
  * @param cls context for verifying addresses
  */
 static void
-socket_close_cb (evutil_socket_t sock, short flags, void *cls)
+socket_write_cb (evutil_socket_t sock, short flags, void *cls)
 {
   struct VerifyAddressesCtx *ctx = cls;
   int lb;
@@ -398,15 +420,18 @@
     return;
   }
   /* FIXME: add the addresses associated with the contex to the mapping */
+  
   lb = rank - round * rwidth - rwidth + nproc;
   MSH_assert (0 <= lb);
   lb %= nproc;
-  source = instance_address_get_rank (ctx->iainfo);
+  source = instance_address_info_get_rank (ctx->iainfo);
   if (lb <= source)
     off = source - lb;
   else
     off = nproc - lb + source;
   bitmap_set (bitmap, off, 1);
+  addressmap_add (addrmap, instance_address_info_get_rank (ctx->iainfo),
+                  ctx->port, ctx->ip);
   return;
 }
 
@@ -431,8 +456,8 @@
     /* FIXME: Check if we already got a mapping for the instance */
     goto err_ret;
   }
-  LOG_DEBUG ("%d: Opened a connection to %s\n", rank, 
-             saddr2str (ctx->saddr, ctx->addrlen));
+  LOG_DEBUG ("%d: Opened a connection to %s:%u\n", rank, 
+             ip2str (ctx->ip), ctx->port);
   ctx->sock = sockfd;
   id = htonl ((uint32_t) rank);
   if (sizeof (uint32_t) != write (sockfd, &id, sizeof (uint32_t)))
@@ -442,7 +467,7 @@
     goto err_ret;
   }
   ctx->close_task = 
-      scheduler_add_socket (sockfd, EV_WRITE, &socket_close_cb, ctx, NULL);
+      scheduler_add_socket (sockfd, EV_WRITE, &socket_write_cb, ctx, NULL);
   return;
 
  err_ret:
@@ -450,19 +475,27 @@
   free (ctx);
 }
 
+static unsigned int bmx;
 
 static int
-address_iterator_cb (void *cls, struct sockaddr *saddr, socklen_t addrlen)
+address_iterator_cb (void *cls, uint16_t port, in_addr_t ip)
 {
   struct VerifyAddressesCtx *ctx;
   struct InstanceAddrInfo *iainfo = cls;
+  struct sockaddr_in in_addr;;
 
+  LOG_DEBUG ("%d: \t %d Opening connection to: %s\n", rank, bmx++, ip2str 
((uint32_t) ip) );
+  in_addr.sin_family = AF_INET;
+  in_addr.sin_port = htons (port);
+  in_addr.sin_addr.s_addr = htonl ((uint32_t) ip);
   ctx = MSH_malloc (sizeof (struct VerifyAddressesCtx));
-  ctx->soh = scheduler_open_socket (saddr, addrlen, &socket_open_cb, ctx);
+  ctx->soh = scheduler_open_socket ((struct sockaddr *) &in_addr,
+                                    sizeof (struct sockaddr_in),
+                                    &socket_open_cb, ctx);
+  ctx->port = port;
+  ctx->ip = ip;
+  ctx->sock = -1;
   ctx->iainfo = iainfo;
-  ctx->saddr = saddr;
-  ctx->addrlen = addrlen;
-  ctx->sock = -1;
   if (NULL == ctx->soh)
   {
     MSH_break (0);
@@ -470,6 +503,7 @@
     return MSH_SYSERR;
   }
   DLL_insert_tail (vactx_head, vactx_tail, ctx);
+  return MSH_OK;
 }
 
 
@@ -488,6 +522,7 @@
   
   struct InstanceAddr *iaddr;
   
+  bmx = 0;
   if (MSH_OK != instance_address_info_iterate_addresses (iainfo,
                                                          &address_iterator_cb,
                                                          iainfo))
@@ -523,9 +558,10 @@
   iainfo = instance_address_info_create (source);
   for (cnt = 0; cnt < nips; cnt++)
   {
-    iaddr = instance_address_create_sockaddr_in (msg->port,
-                                                (in_addr_t) msg->ipaddrs[cnt]);
-    instance_address_info_add_address (iainfo, iaddr);
+    LOG_DEBUG ("%d: Parsed address: %s\n", rank, ip2str ((in_addr_t) ntohl 
(msg->ipaddrs[cnt])));
+    iaddr = instance_address_create_sockaddr_in (ntohs (msg->port),
+                                                 (in_addr_t) ntohl 
(msg->ipaddrs[cnt]));
+    MSH_break (MSH_OK == instance_address_info_add_address (iainfo, iaddr));
   }
   return iainfo;
 }
@@ -585,13 +621,13 @@
       MSH_break (0);
       goto err_ret;
     }
+    LOG_DEBUG ("%d: Received message of size %d from %d\n", rank, rsize, 
source);
     if (NULL == (iainfos[cnt] = parse_verify_address_msg (msg, source)))
     {
       free (msg);
       goto err_ret;
     }
     free (msg);
-    LOG_DEBUG ("%d: Received message of size %d from %d\n", rank, rsize, 
source);
   }
   return iainfos;
   
@@ -895,6 +931,7 @@
     goto fail;
   }
   bitmap = bitmap_create (rwidth);
+  addrmap = addressmap_create (nproc);
   if (MSH_OK != scheduler_run (&run, NULL))
   {
     MSH_break (0);
@@ -909,6 +946,11 @@
     bitmap_destroy (bitmap);
     bitmap = NULL;
   }
+  if (NULL != addrmap)
+  {
+    addressmap_destroy (addrmap);
+    addrmap = NULL;
+  }
   MSH_break (MPI_SUCCESS == MPI_Finalize());
   MSH_free_non_null (s_addrs);
   //libevent_global_shutdown ();

Modified: msh/src/test_addressmap.c
===================================================================
--- msh/src/test_addressmap.c   2013-07-16 19:08:17 UTC (rev 28098)
+++ msh/src/test_addressmap.c   2013-07-16 21:33:21 UTC (rev 28099)
@@ -18,12 +18,12 @@
  * address info object
  *
  * @param cls the closure passed to instance_address_info_iterate_addresses()
- * @param addr the address of the instance
- * @param addrlen the address length
+ * @param port the port where the instance is listening
+ * @param ip the ip of the instance
  * @return MSH_OK to continue iteration; MSH_SYSERR to terminate
  */
 static int 
-iterator_cb (void *cls, struct sockaddr *addr, socklen_t addrlen)
+iterator_cb (void *cls, uint16_t port, in_addr_t ip)
 {
   cnt++;
   return MSH_OK;
@@ -61,21 +61,13 @@
 test_deserialization ()
 {
   AddressMap *m;
-  struct InstanceAddrInfo *iainfo;
-  struct InstanceAddr *addr;
   struct MSH_MSG_InstanceAdresses **iaddr_msgs;
-  
-  iainfo = instance_address_info_create (1);
-  addr = instance_address_create_sockaddr_in (0, 12);
-  instance_address_info_add_address (iainfo, addr);
-  addr = instance_address_create_sockaddr_in (0, 2);
-  instance_address_info_add_address (iainfo, addr);
-  addr = instance_address_create_sockaddr_in (0, 7);
-  instance_address_info_add_address (iainfo, addr);
-  addr = instance_address_create_sockaddr_in (0, 14);
-  instance_address_info_add_address (iainfo, addr);
+
   m = addressmap_create (2);
-  addressmap_add (m, iainfo);
+  MSH_assert (MSH_OK == addressmap_add (m, 1, 0, 12));
+  MSH_assert (MSH_OK == addressmap_add (m, 1, 0, 2));
+  MSH_assert (MSH_OK == addressmap_add (m, 1, 0, 7));
+  MSH_assert (MSH_OK == addressmap_add (m, 1, 0, 14));
   cnt = 0;
   MSH_assert (MSH_OK == 
               addressmap_iterate_instance_addresses (m, 1, &iterator_cb, 
NULL));
@@ -84,36 +76,22 @@
   /* prepare a second addressmap */
   {
     AddressMap *m2;
-    struct InstanceAddrInfo *iainfo;
-    struct InstanceAddr *addr;
     struct MSH_MSG_AddressMap *map_msg;
 
     m2 = addressmap_create (2);
-    iainfo = instance_address_info_create (1);
-    addr = instance_address_create_sockaddr_in (0, 2);
-    instance_address_info_add_address (iainfo, addr);
-    addr = instance_address_create_sockaddr_in (0, 7);
-    instance_address_info_add_address (iainfo, addr);
-    addr = instance_address_create_sockaddr_in (0, 14);
-    instance_address_info_add_address (iainfo, addr);
-    addressmap_add (m2, iainfo);
-
-    iainfo = instance_address_info_create (0);
-    addr = instance_address_create_sockaddr_in (0, 3);
-    instance_address_info_add_address (iainfo, addr);
-    addressmap_add (m2, iainfo);
-
+    MSH_assert (MSH_OK == addressmap_add (m2, 1, 0, 2));
+    MSH_assert (MSH_OK == addressmap_add (m2, 1, 0, 7));
+    MSH_assert (MSH_OK == addressmap_add (m2, 1, 0, 14));
+    MSH_assert (MSH_OK == addressmap_add (m2, 0, 0, 3));
     cnt = 0;
     MSH_assert (MSH_OK == 
                 addressmap_iterate_instance_addresses (m2, 1, &iterator_cb, 
NULL));
     MSH_assert (3 == cnt);
-    MSH_assert (MSH_OK == addressmap_pack (m2, &map_msg, &iaddr_msgs));
     cnt = 0;
     MSH_assert (MSH_OK == 
                 addressmap_iterate_instance_addresses (m2, 0, &iterator_cb, 
NULL));
     MSH_assert (1 == cnt);
-    addressmap_iterate_instance_address_infos 
-        (m2, &instance_address_info_free_iterator, NULL);
+    MSH_assert (MSH_OK == addressmap_pack (m2, &map_msg, &iaddr_msgs));
     addressmap_destroy (m2);
     free (map_msg);
   }
@@ -123,8 +101,6 @@
   MSH_assert (MSH_OK == 
               addressmap_iterate_instance_addresses (m, 1, &iterator_cb, 
NULL));
   MSH_assert (3 == cnt);
-  addressmap_iterate_instance_address_infos
-      (m, &instance_address_info_free_iterator, NULL);
   addressmap_destroy (m);
   free (iaddr_msgs[1]);
   free (iaddr_msgs[0]);
@@ -137,61 +113,42 @@
 {
   AddressMap *m;
   struct InstanceAddr *addr1, *addr2, *addr3;
-  struct InstanceAddrInfo *iainfo, *iainfo2;
+  struct InstanceAddrInfo *iainfo;
   
-  addr1 = instance_address_create_sockaddr_in (0, 12);
-  iainfo = instance_address_info_create (0);
-  instance_address_info_add_address (iainfo, addr1);
-  addr2 = instance_address_create_sockaddr_in (0, 9);
-  instance_address_info_add_address (iainfo, addr2);
-  addr3 = instance_address_create_sockaddr_in (0, 13);
-  instance_address_info_add_address (iainfo, addr3);
   m = addressmap_create (2);
-  addressmap_add (m, iainfo);
-  MSH_assert (MSH_OK == 
-              instance_address_info_iterate_addresses (iainfo,
-                                                       &iterator_cb, NULL));
-  MSH_assert (3 == cnt);
+  MSH_assert (MSH_OK == addressmap_add (m, 0, 0, 12));
+  MSH_assert (MSH_OK == addressmap_add (m, 0, 0, 9));
+  MSH_assert (MSH_OK == addressmap_add (m, 0, 0, 13));
   cnt = 0;
   MSH_assert (MSH_OK == 
               addressmap_iterate_instance_addresses (m, 0, &iterator_cb, 
NULL));
   MSH_assert (3 == cnt);
-  iainfo2 = instance_address_info_create (0);
-  addr1 = instance_address_create_sockaddr_in (0, 12);
-  instance_address_info_add_address (iainfo2, addr1);
-  addr2 = instance_address_create_sockaddr_in (0, 19);
-  instance_address_info_add_address (iainfo2, addr2);
+
+  MSH_assert (MSH_OK != addressmap_add (m, 0, 0, 12)); /* 12 was added before 
*/
+  MSH_assert (MSH_OK == addressmap_add (m, 0, 0, 19));
   cnt = 0;
   MSH_assert (MSH_OK == 
-              instance_address_info_iterate_addresses (iainfo2,
-                                                       &iterator_cb, NULL));
-  MSH_assert (2 == cnt);
-  addressmap_add (m, iainfo2);
-  cnt = 0;
-  MSH_assert (MSH_OK == 
               addressmap_iterate_instance_addresses (m, 0, &iterator_cb, 
NULL));
   MSH_assert (4 == cnt);
-  instance_address_info_destroy (iainfo2);
 
   /* test address map intersections */
-  iainfo2 = instance_address_info_create (0);
+  iainfo = instance_address_info_create (0);
   addr1 = instance_address_create_sockaddr_in (0, 12);
-  instance_address_info_add_address (iainfo2, addr1);
+  instance_address_info_add_address (iainfo, addr1);
   addr2 = instance_address_create_sockaddr_in (0, 19);
-  instance_address_info_add_address (iainfo2, addr2);  
+  instance_address_info_add_address (iainfo, addr2);  
   addr3 = instance_address_create_sockaddr_in (0, 3);
-  instance_address_info_add_address (iainfo2, addr3);
-  addressmap_intersect (m, iainfo2);
+  instance_address_info_add_address (iainfo, addr3);
+  addressmap_intersect (m, iainfo);
   cnt = 0;
   MSH_assert (MSH_OK == 
               addressmap_iterate_instance_addresses (m, 0, &iterator_cb, 
NULL));
   MSH_assert (2 == cnt);
-  instance_address_info_destroy (iainfo2);
+  instance_address_info_destroy (iainfo);
   
   /* test message serialization of the addressmap */
   test_serialization (m);
   addressmap_destroy (m);  
-  instance_address_info_destroy (iainfo);
 
   /* test message deserialization of the addressmap */
   test_deserialization ();




reply via email to

[Prev in Thread] Current Thread [Next in Thread]