修訂 | 39 (tree) |
---|---|
時間 | 2021-12-07 06:22:41 |
作者 | mateuszviste |
save/load db also takes care of the nextcheck timestamp
@@ -112,7 +112,7 @@ | ||
112 | 112 | int i; |
113 | 113 | char *ptrs[4]; |
114 | 114 | char lbuf[256]; |
115 | - struct gopherlist *res = NULL; | |
115 | + struct gopherlist *res = NULL, *newnode; | |
116 | 116 | fd = fopen(fname, "rb"); |
117 | 117 | if (fd == NULL) return(NULL); |
118 | 118 | for (;;) { |
@@ -121,13 +121,16 @@ | ||
121 | 121 | /* TSV line structure |
122 | 122 | * 0 hostname |
123 | 123 | * 1 port |
124 | - * 2 failedsince (time_t) */ | |
124 | + * 2 failedsince (time_t) | |
125 | + * 3 nextcheck (time_t) */ | |
125 | 126 | |
126 | - if (glist_addnewhostport(&res, ptrs[0], (unsigned short)atoi(ptrs[1]), atol(ptrs[2])) == NULL) { | |
127 | + newnode = glist_addnewhostport(&res, ptrs[0], (unsigned short)atoi(ptrs[1]), atol(ptrs[2])); | |
128 | + if (newnode == NULL) { | |
127 | 129 | /* on error, free list and quit */ |
128 | 130 | glist_free(res); |
129 | 131 | return(NULL); |
130 | 132 | } |
133 | + newnode->nextcheck = atoi(ptrs[3]); | |
131 | 134 | } |
132 | 135 | fclose(fd); |
133 | 136 | return(res); |
@@ -145,7 +148,7 @@ | ||
145 | 148 | if (node->failedsince == 0) countactive++; |
146 | 149 | if (node->failedsince == 1) countpending++; |
147 | 150 | if (node->failedsince > 1) countdown++; |
148 | - fprintf(f, "%s,%u,%ld\n", node->fqdn, node->port, node->failedsince); | |
151 | + fprintf(f, "%s,%u,%ld,%ld\n", node->fqdn, node->port, node->failedsince, node->nextcheck); | |
149 | 152 | } |
150 | 153 | fclose(f); |
151 | 154 | f = fopen(fcount, "wb"); |
@@ -515,7 +518,7 @@ | ||
515 | 518 | continue; |
516 | 519 | } |
517 | 520 | |
518 | - /* try adding hosts to global glist (and count 'em) */ | |
521 | + /* try adding hosts to global glist */ | |
519 | 522 | for (gnode = mlist; gnode != NULL; gnode = gnode->next) { |
520 | 523 | glist_addnewhostport(&glist, gnode->fqdn, gnode->port, 1); |
521 | 524 | } |