src/liboping.c: Do not reset recv_ttl in ping_receive_one().
authorSebastian Harl <sh@tokkee.org>
Fri, 17 Jul 2009 07:39:35 +0000 (09:39 +0200)
committerSebastian Harl <sh@tokkee.org>
Fri, 17 Jul 2009 07:39:35 +0000 (09:39 +0200)
Instead, reset the value of all host object in ping_receive_all().

ping_receive_one() does not necessarily get a pointer to the host object for
which we receive a reply, since ICMP messages may be received on _any_ raw
socket.

src/liboping.c

index 51071ad..2ccbf4d 100644 (file)
@@ -478,7 +478,6 @@ static int ping_receive_one (int fd, pinghost_t *ph, struct timeval *now)
 
        /* Iterate over all auxiliary data in msghdr */
        recv_ttl = -1;
-       ph->recv_ttl = -1;
        for (cmsg = CMSG_FIRSTHDR (&msghdr); /* {{{ */
                        cmsg != NULL;
                        cmsg = CMSG_NXTHDR (&msghdr, cmsg))
@@ -592,7 +591,10 @@ static int ping_receive_all (pingobj_t *obj)
        ret = 0;
 
        for (ptr = ph; ptr != NULL; ptr = ptr->next)
-               ptr->latency = -1.0;
+       {
+               ptr->latency  = -1.0;
+               ptr->recv_ttl = -1;
+       }
 
        if (gettimeofday (&nowtime, NULL) == -1)
        {