ref: abda59c7ecef03f9ab91568c8417f963fb7db894
parent: 59ba35a327d9b5a2f08bc877cb18bf6c6f942b8c
author: cinap_lenrek <[email protected]>
date: Sat Feb 18 21:27:42 EST 2017
ip/gping: fix corruption due to Machine.last pointer not being maintained in pingclean(), cleanup unused stuff
--- a/sys/src/cmd/ip/gping.c
+++ b/sys/src/cmd/ip/gping.c
@@ -47,7 +47,6 @@
{
int seq; /* sequence number */
vlong time; /* time sent */
-// int rtt;
Req *next;
};
@@ -68,13 +67,7 @@
int unreachable;
ushort seq;
- Req *first;
- Req *last;
- Req *rcvd;
-
- char buf[1024];
- char *bufp;
- char *ebufp;
+ Req *list;
};
enum
@@ -436,7 +429,7 @@
vlong x, y;
y = 10LL*1000000000LL;
- for(l = &m->first; *l; ){
+ for(l = &m->list; *l; ){
r = *l;
x = now - r->time;
if(x > y || r->seq == seq){
@@ -474,15 +467,11 @@
ip->seq[0] = m->seq;
ip->seq[1] = m->seq>>8;
r->seq = m->seq;
- r->next = nil;
- lock(m);
- pingclean(m, -1, nsec(), 0);
- if(m->first == nil)
- m->first = r;
- else
- m->last->next = r;
- m->last = r;
r->time = nsec();
+ lock(m);
+ pingclean(m, -1, r->time, 0);
+ r->next = m->list;
+ m->list = r;
unlock(m);
if(write(m->pingfd, buf, MSGLEN) < MSGLEN){
errstr(err, sizeof err);