diff --git a/.topdeps b/.topdeps index b80d16757a0901dfb0b2f44b73c66f7ceb45fb6f..85babb7a9612ce6a76157454d9012711c16032db 100644 --- a/.topdeps +++ b/.topdeps @@ -1 +1 @@ -remove-reclamation +add-text_store diff --git a/.topmsg b/.topmsg index c54171a4cabc9420e8c31fdc6cd60e65ca876ff0..182bd8e7665ef92b4d51bc701b0a69644a3574ad 100644 --- a/.topmsg +++ b/.topmsg @@ -1,3 +1,3 @@ From: Per Cederqvist <ceder@lysator.liu.se> -Subject: Create empty files text-store.h and text-store.c, and include them in the link. * src/server/text-store.h: New file, currently empty. * src/server/text-store.c: New file. Include text-store.h, but do not yet do anything. * src/server/Makefile.am (DISKOBJS): Added text-store.c and text-store.h. (DBCK): Added text-store.c. +Subject: patch introduce-generation_position.patch diff --git a/src/include/kom-types.h b/src/include/kom-types.h index 8a769a15c75557ee1beeced412b87c241b5f4052..d4c07fb70ad6dc4ca6360e4234cf7757cdc56b90 100644 --- a/src/include/kom-types.h +++ b/src/include/kom-types.h @@ -210,12 +210,32 @@ typedef struct { */ typedef unsigned long Garb_nice; +typedef long Generation; + +struct generation_position { + /* The generation number where the text mass is stored. */ + Generation generation; + + /* Start of the text. For generation 0, this is the start of the + actual text. For all other generations, this points is a + struct that contains some metadata and the text mass. See + foutput_text_mass() for the format. */ + long file_pos; + + /* Size of text and metadata. For generation 0, there is no + metadata, so file_size will be equal to no_of_chars in the + corresponding Text_stat. For all other generations, this will + include some overhead (see foutput_text_mass()). */ + long file_size; +}; /* Struct for text status */ typedef struct { Time creation_time; - long generation; - long file_pos; /* Start of the text in the text file. */ + + /* Where the text can be found. */ + struct generation_position text_store; + Pers_no author; unsigned short no_of_lines; String_size no_of_chars; diff --git a/src/server/dbck-cache.c b/src/server/dbck-cache.c index d3ef7dec23bfcc791c24614a7c3cc20fd0ce5c2c..3de2d242af9cc94a6f1f1916a5c870c0f52eb528 100644 --- a/src/server/dbck-cache.c +++ b/src/server/dbck-cache.c @@ -329,11 +329,11 @@ cached_get_text( Text_no text ) if ( text_arr[ text ] == NULL ) return EMPTY_STRING; - else if (text_arr[text]->generation == 0) + else if (text_arr[text]->text_store.generation == 0) { the_string.string = tmp_alloc( text_arr[text]->no_of_chars ); the_string.len = text_arr[text]->no_of_chars; - fseek(text_file, text_arr[ text ]->file_pos, SEEK_SET); + fseek(text_file, text_arr[ text ]->text_store.file_pos, SEEK_SET); if ( fread(the_string.string, sizeof(char), the_string.len, text_file) != (size_t)the_string.len ) { @@ -424,8 +424,9 @@ cached_flush_text(Text_no text_no, fseek(new_text_file, 0, SEEK_END); #warning Generation > 0 not yet handled - text_arr[ text_no ]->generation = 0; - text_arr[ text_no ]->file_pos = ftell(new_text_file); + text_arr[ text_no ]->text_store.generation = 0; + text_arr[ text_no ]->text_store.file_pos = ftell(new_text_file); + text_arr[ text_no ]->text_store.file_size = 0; if ( fwrite(message.string, sizeof(char), message.len, new_text_file) != (size_t)message.len ) diff --git a/src/server/memory.c b/src/server/memory.c index 29c70d61b12443a71a5a43a86ecd74f6c98484cf..e000bf80c596a5461692b86cc379d61b43c88922 100644 --- a/src/server/memory.c +++ b/src/server/memory.c @@ -608,8 +608,9 @@ copy_text_stat(const Text_stat *t) c = alloc_text_stat(); c->creation_time = t->creation_time; - c->generation = t->generation; - c->file_pos = t->file_pos; + c->text_store.generation = t->text_store.generation; + c->text_store.file_pos = t->text_store.file_pos; + c->text_store.file_size = t->text_store.file_size; c->author = t->author; c->no_of_lines = t->no_of_lines; c->no_of_chars = t->no_of_chars; @@ -627,8 +628,9 @@ void init_text_stat (Text_stat *t) { t->creation_time = NO_TIME; - t->generation = 0; - t->file_pos = 0; + t->text_store.generation = 0; + t->text_store.file_pos = 0; + t->text_store.file_size = 0; t->author = 0; t->no_of_lines = 0; t->no_of_chars = 0; diff --git a/src/server/ram-output.c b/src/server/ram-output.c index 0c085fbb11e08c147774a5433f0ce84c6aefc52c..9cb192ea5e55897a2dbf33f240135b045be818ce 100644 --- a/src/server/ram-output.c +++ b/src/server/ram-output.c @@ -325,7 +325,7 @@ foutput_text_stat_0(struct dbfile *fp, foutput_time(fp, t_stat->creation_time); foutput_ulong((unsigned long) t_stat->author, fp); - foutput_ulong((unsigned long) t_stat->file_pos, fp); + foutput_ulong((unsigned long) t_stat->text_store.file_pos, fp); foutput_ulong((unsigned long) t_stat->no_of_lines, fp); foutput_ulong((unsigned long) t_stat->no_of_chars, fp); foutput_ulong((unsigned long) t_stat->no_of_marks, fp); @@ -351,7 +351,7 @@ foutput_text_stat_2(struct dbfile *fp, foutput_time(fp, t_stat->creation_time); foutput_ulong((unsigned long) t_stat->author, fp); - foutput_ulong((unsigned long) t_stat->file_pos, fp); + foutput_ulong((unsigned long) t_stat->text_store.file_pos, fp); foutput_ulong((unsigned long) t_stat->no_of_lines, fp); foutput_ulong((unsigned long) t_stat->no_of_chars, fp); foutput_ulong((unsigned long) t_stat->no_of_marks, fp); @@ -380,8 +380,9 @@ foutput_text_stat_3(struct dbfile *fp, foutput_time(fp, t_stat->creation_time); foutput_ulong((unsigned long) t_stat->author, fp); - foutput_ulong((unsigned long) t_stat->generation, fp); - foutput_ulong((unsigned long) t_stat->file_pos, fp); + foutput_ulong((unsigned long) t_stat->text_store.generation, fp); + foutput_ulong((unsigned long) t_stat->text_store.file_pos, fp); + foutput_ulong((unsigned long) t_stat->text_store.file_size, fp); foutput_ulong((unsigned long) t_stat->no_of_lines, fp); foutput_ulong((unsigned long) t_stat->no_of_chars, fp); foutput_ulong((unsigned long) t_stat->no_of_marks, fp); diff --git a/src/server/ram-parse.c b/src/server/ram-parse.c index 8961f1e6056e56c453d48624c08efb26b72c3045..8b3887cd6c4e274ef0ea9b6bf364ac189b259fab 100644 --- a/src/server/ram-parse.c +++ b/src/server/ram-parse.c @@ -1049,8 +1049,9 @@ fparse_text_stat_3(struct dbfile *fp, result->creation_time = fparse_time(fp); result->author = fparse_long(fp); - result->generation = fparse_long(fp); - result->file_pos = fparse_long(fp); + result->text_store.generation = fparse_long(fp); + result->text_store.file_pos = fparse_long(fp); + result->text_store.file_size = fparse_long(fp); result->no_of_lines = fparse_long(fp); result->no_of_chars = fparse_long(fp); result->no_of_marks = fparse_long(fp); @@ -1166,8 +1167,9 @@ fparse_text_stat_2(struct dbfile *fp, result->creation_time = fparse_time(fp); result->author = fparse_long(fp); - result->generation = 0; - result->file_pos = fparse_long(fp); + result->text_store.generation = 0; + result->text_store.file_pos = fparse_long(fp); + result->text_store.file_size = 0; result->no_of_lines = fparse_long(fp); result->no_of_chars = fparse_long(fp); result->no_of_marks = fparse_long(fp); @@ -1283,8 +1285,9 @@ fparse_text_stat_0(struct dbfile *fp, result->creation_time = fparse_time(fp); result->author = fparse_long(fp); - result->generation = 0; - result->file_pos = fparse_long(fp); + result->text_store.generation = 0; + result->text_store.file_pos = fparse_long(fp); + result->text_store.file_size = 0; result->no_of_lines = fparse_long(fp); result->no_of_chars = fparse_long(fp); result->no_of_marks = fparse_long(fp); diff --git a/src/server/simple-cache.c b/src/server/simple-cache.c index 4ed7247ca0aedc6a527e0b32fbab0209538d5fce..7c51c205ab7b6bd2a0cdeaee5819bd3ff8dfe2e2 100644 --- a/src/server/simple-cache.c +++ b/src/server/simple-cache.c @@ -1052,15 +1052,15 @@ cached_get_text( Text_no text ) if ( (t_stat = cached_get_text_stat (text)) == NULL ) return EMPTY_STRING; - else if (t_stat->generation == 0) + else if (t_stat->text_store.generation == 0) { LOGACC(lt_text_mass, text); the_string.string = tmp_alloc( t_stat->no_of_chars ); the_string.len = t_stat->no_of_chars; - if (fseek(text_file, t_stat->file_pos, SEEK_SET) != 0) + if (fseek(text_file, t_stat->text_store.file_pos, SEEK_SET) != 0) { kom_log("Failed to seek to %ld in text mass file: %s.\n", - t_stat->file_pos, strerror(errno)); + t_stat->text_store.file_pos, strerror(errno)); return EMPTY_STRING; } @@ -1227,8 +1227,8 @@ cached_create_text(const String message) ((Text_stat *)node->ptr)->no_of_marks = 0; ((Text_stat *)node->ptr)->no_of_lines = 0; ((Text_stat *)node->ptr)->no_of_chars = 0; - ((Text_stat *)node->ptr)->generation = 0; - ((Text_stat *)node->ptr)->file_pos = file_pos; + ((Text_stat *)node->ptr)->text_store.generation = 0; + ((Text_stat *)node->ptr)->text_store.file_pos = file_pos; text_set_mru( tno );