aboutsummaryrefslogtreecommitdiff
path: root/src/libdraw
diff options
context:
space:
mode:
authorRuss Cox <rsc@swtch.com>2008-01-10 21:38:42 -0500
committerRuss Cox <rsc@swtch.com>2008-01-10 21:38:42 -0500
commit0a98a883d5bc30843f859a1b4f05af1a6906907a (patch)
tree3fdb08f6ea95793a8865c23263d9234135c00ac8 /src/libdraw
parent27589754e47a2d2e682ee29daa2d21dff99e509d (diff)
downloadplan9port-0a98a883d5bc30843f859a1b4f05af1a6906907a.tar.gz
plan9port-0a98a883d5bc30843f859a1b4f05af1a6906907a.tar.bz2
plan9port-0a98a883d5bc30843f859a1b4f05af1a6906907a.zip
libdraw: fix spinning event loop (David Bulkow)
Diffstat (limited to 'src/libdraw')
-rw-r--r--src/libdraw/event.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/libdraw/event.c b/src/libdraw/event.c
index b1147bd4..e41814f3 100644
--- a/src/libdraw/event.c
+++ b/src/libdraw/event.c
@@ -159,7 +159,7 @@ etimer(ulong key, int n)
if(n <= 0)
n = 1000;
eslave[Stimer].n = n;
- eslave[Stimer].nexttick = nsec()+n*1000LL;
+ eslave[Stimer].nexttick = nsec()+n*1000000LL;
return 1<<Stimer;
}
@@ -295,12 +295,12 @@ extract(int canblock)
}
}else if(i == Stimer){
t0 = nsec();
- if(t0-eslave[i].nexttick <= 0){
+ if(t0 >= eslave[i].nexttick){
tv.tv_sec = 0;
tv.tv_usec = 0;
}else{
- tv.tv_sec = (t0-eslave[i].nexttick)/1000000000;
- tv.tv_usec = (t0-eslave[i].nexttick)%1000000000 / 1000;
+ tv.tv_sec = (eslave[i].nexttick-t0)/1000000000;
+ tv.tv_usec = (eslave[i].nexttick-t0)%1000000000 / 1000;
}
timeout = &tv;
}else{
@@ -345,8 +345,8 @@ extract(int canblock)
}
}else if(i == Stimer){
t0 = nsec();
- while(t0-eslave[i].nexttick > 0){
- eslave[i].nexttick += eslave[i].n*1000LL;
+ while(t0 > eslave[i].nexttick){
+ eslave[i].nexttick += eslave[i].n*1000000LL;
eslave[i].head = (Ebuf*)1;
n++;
}