AmendHub

Download (as of this amendment):

jcs

/

subtext

/

amendments

/

631

board: When tossing, if message id cache can't be read, rebuild it


jcs made amendment 631 about 1 month ago
--- board.c Sat Dec 6 17:44:46 2025 +++ board.c Fri Sep 18 21:08:06 2026 @@ -1757,18 +1757,18 @@ board_toss_ftn_message(struct board *board, asize = o->size + sizeof(struct board_ftn_msgid_cache); msgid_cache = xmalloc(asize); if (msgid_cache == NULL) { - logger_printf("[board] toss: malloc(%ld) failed", - asize); - return -1; + logger_printf("[board] Toss to %s: malloc(%ld) failed, " + "building new cache", board->name, asize); + } else { + bile_read(board->bile, o->type, o->id, msgid_cache, o->size); + npost_ids = o->size / sizeof(struct board_ftn_msgid_cache); } - bile_read(board->bile, o->type, o->id, msgid_cache, o->size); - npost_ids = o->size / sizeof(struct board_ftn_msgid_cache); xfree(&o); - } else { + } + + if (msgid_cache == NULL) { npost_ids = bile_ids_by_type(board->bile, BOARD_FTN_POST_RTYPE, &post_ids); - if (npost_ids == 0) - goto add; msgid_cache = xcalloc(sizeof(struct board_ftn_msgid_cache), npost_ids + 1); if (msgid_cache == NULL) { @@ -1777,6 +1777,8 @@ board_toss_ftn_message(struct board *board, xfree(&post_ids); return -1; } + if (npost_ids == 0) + goto add; for (n = 0; n < npost_ids; n++) { /* only read as far as we have to */ bile_read(board->bile, BOARD_FTN_POST_RTYPE, post_ids[n],