diff options
| author | arf20 <aruizfernandez05@gmail.com> | 2025-12-08 00:31:59 +0100 |
|---|---|---|
| committer | arf20 <aruizfernandez05@gmail.com> | 2025-12-08 00:31:59 +0100 |
| commit | c2977c08c4778d0dff74ca92441bc33789687947 (patch) | |
| tree | d40430de2b8fa9a92c230fe98ddafcd8bd6eee59 /main.c | |
| parent | 0159795be5aa8423e8d223d057912e2d152efb4f (diff) | |
| download | arfnet2-search-c2977c08c4778d0dff74ca92441bc33789687947.tar.gz arfnet2-search-c2977c08c4778d0dff74ca92441bc33789687947.zip | |
periodic reindexing
Diffstat (limited to 'main.c')
| -rw-r--r-- | main.c | 31 |
1 files changed, 17 insertions, 14 deletions
@@ -347,27 +347,30 @@ int main() { return 1; } - /* begin indexing */ if (index_init() < 0) return 1; - time_t time_now = time(NULL); - struct tm *tm_now = gmtime(&time_now); - static char timestr[256]; - strftime(timestr, 256, "%Y-%m-%d %H:%M:%S", tm_now); + /* index loop */ + do { + time_t time_now = time(NULL); + struct tm *tm_now = gmtime(&time_now); + static char timestr[256]; + strftime(timestr, 256, "%Y-%m-%d %H:%M:%S", tm_now); - printf("[%s] [index] indexeding started...\n", timestr); + printf("[%s] [index] indexeding started...\n", timestr); - g_index = index_new(INIT_MAP_CAPACITY, root, 1); + if (g_index) + index_destroy(g_index); - time_now = time(NULL); - tm_now = gmtime(&time_now); - strftime(timestr, 256, "%Y-%m-%d %H:%M:%S", tm_now); + g_index = index_new(INIT_MAP_CAPACITY, root, magic_enable); - printf("[%s] [index] indexed finished\n", timestr); + time_now = time(NULL); + tm_now = gmtime(&time_now); + strftime(timestr, 256, "%Y-%m-%d %H:%M:%S", tm_now); - while (1) { - sleep(1000); - } + printf("[%s] [index] indexed finished\n", timestr); + + sleep(period); + } while (1); } |
