summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2017-02-19 02:27:42 +0100
committercinap_lenrek <cinap_lenrek@felloff.net>2017-02-19 02:27:42 +0100
commitabda59c7ecef03f9ab91568c8417f963fb7db894 (patch)
tree784a06521009e6485c0733c6911629643b154404 /sys
parent59ba35a327d9b5a2f08bc877cb18bf6c6f942b8c (diff)
ip/gping: fix corruption due to Machine.last pointer not being maintained in pingclean(), cleanup unused stuff
Diffstat (limited to 'sys')
-rw-r--r--sys/src/cmd/ip/gping.c23
1 files changed, 6 insertions, 17 deletions
diff --git a/sys/src/cmd/ip/gping.c b/sys/src/cmd/ip/gping.c
index 911dd5a39..705bc9888 100644
--- a/sys/src/cmd/ip/gping.c
+++ b/sys/src/cmd/ip/gping.c
@@ -47,7 +47,6 @@ struct Req
{
int seq; /* sequence number */
vlong time; /* time sent */
-// int rtt;
Req *next;
};
@@ -68,13 +67,7 @@ struct Machine
int unreachable;
ushort seq;
- Req *first;
- Req *last;
- Req *rcvd;
-
- char buf[1024];
- char *bufp;
- char *ebufp;
+ Req *list;
};
enum
@@ -436,7 +429,7 @@ pingclean(Machine *m, ushort seq, vlong now, int)
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 @@ pingsend(Machine *m)
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);