History

check a few times before trusting the sense

Sigrid Solveig Haflínudóttir committed 5 years ago

Commit eed67ad1 parent c5b6d2a1 file · +7 −1Browse files

Unified · Split

jacksense.c+7−1
@@ -14,7 +14,7 @@ main(int argc, char **argv) · 13 unmodified lines
1414 {
1515 int hp, sp, cmd, ctl, vol, lastvol, newvol;
1616 int hpsafevol, spsafevol;
17− u32int x, y[4], has, had;
17+ u32int x, y[4], has, had, c;
1818 Biobuf *b;
1919 char *s, *a[16], tmp[32];
2020
@@ -61,10 +61,16 @@ main(int argc, char **argv) · 40 unmodified lines
6161 had = -1;
6262 lastvol = (spsafevol < hpsafevol ? spsafevol : hpsafevol)*2/3;
6363 for(;;){
64+ c = 0;
65+again:
6466 if(write(cmd, &x, 4) != 4 || read(cmd, y, sizeof(y)) < 4)
6567 sysfatal("failed");
6668 has = y[0] & (1<<31);
6769 if(has != had){
70+ if(c++ < 2){
71+ sleep(75);
72+ goto again;
73+ }
6874 newvol = lastvol;
6975 if(pread(vol, tmp, sizeof(tmp)-1, 0) > 0 && strncmp(tmp, "master ", 7) == 0)
7076 lastvol = atoi(tmp+7);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t