Clean up how read deals with new telegram arrivals
Fooling around with the file size is silly. It works only because read has flag C_MOD set, so they can only arrive while we're sitting at the delete confirmation prompt, not during reading. Simply try to read more telegrams instead.
This commit is contained in:
parent
43f562145e
commit
b6f666cff9
1 changed files with 10 additions and 11 deletions
|
@ -60,9 +60,7 @@ rea(void)
|
||||||
struct telstr tgm;
|
struct telstr tgm;
|
||||||
FILE *telfp;
|
FILE *telfp;
|
||||||
int teles;
|
int teles;
|
||||||
int size;
|
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
int filelen;
|
|
||||||
char *kind;
|
char *kind;
|
||||||
int n, res;
|
int n, res;
|
||||||
int num = player->cnum;
|
int num = player->cnum;
|
||||||
|
@ -101,9 +99,11 @@ rea(void)
|
||||||
return RET_FAIL;
|
return RET_FAIL;
|
||||||
}
|
}
|
||||||
teles = 0;
|
teles = 0;
|
||||||
size = fsize(fileno(telfp));
|
for (;;) {
|
||||||
|
res = tel_read_header(telfp, mbox, &tgm);
|
||||||
more:
|
more:
|
||||||
while ((res = tel_read_header(telfp, mbox, &tgm)) > 0) {
|
if (res <= 0)
|
||||||
|
break;
|
||||||
if (*kind == 'a') {
|
if (*kind == 'a') {
|
||||||
if ((!player->god && (getrejects(tgm.tel_from, np) & REJ_ANNO))
|
if ((!player->god && (getrejects(tgm.tel_from, np) & REJ_ANNO))
|
||||||
|| tgm.tel_date < then) {
|
|| tgm.tel_date < then) {
|
||||||
|
@ -161,13 +161,12 @@ rea(void)
|
||||||
np->nat_annotim = now;
|
np->nat_annotim = now;
|
||||||
putnat(np);
|
putnat(np);
|
||||||
} else {
|
} else {
|
||||||
if ((filelen = fsize(fileno(telfp))) > size) {
|
|
||||||
pr("Wait a sec! A new %s has arrived...\n", kind);
|
|
||||||
/* force stdio to re-read tel file */
|
/* force stdio to re-read tel file */
|
||||||
(void)fflush(telfp);
|
fflush(telfp);
|
||||||
(void)fseek(telfp, (long)size, SEEK_SET);
|
fseek(telfp, 0, SEEK_CUR);
|
||||||
size = filelen;
|
res = tel_read_header(telfp, mbox, &tgm);
|
||||||
now = time(NULL);
|
if (res != 0) {
|
||||||
|
pr("Wait a sec! A new %s has arrived...\n", kind);
|
||||||
goto more;
|
goto more;
|
||||||
}
|
}
|
||||||
/* Here, we just re-open the file for "w" only,
|
/* Here, we just re-open the file for "w" only,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue