Loading...
--- Libc/Libc-763.13/db/mpool/FreeBSD/mpool.c
+++ Libc/Libc-1583.60.2/db/mpool/FreeBSD/mpool.c
@@ -45,6 +45,8 @@
#include <unistd.h>
#include "un-namespace.h"
+#include "libc_private.h" // for LIBC_ABORT
+
#include <db.h>
#define __MPOOLINTERFACE_PRIVATE
@@ -110,16 +112,14 @@
* Get a new page of memory.
*/
void *
-mpool_new(mp, pgnoaddr)
- MPOOL *mp;
- pgno_t *pgnoaddr;
+mpool_new(MPOOL *mp, pgno_t *pgnoaddr)
{
struct _hqh *head;
BKT *bp;
if (mp->npages == MAX_PAGE_NUMBER) {
(void)fprintf(stderr, "mpool_new: page allocation overflow.\n");
- abort();
+ LIBC_ABORT("page allocation overflow");
}
#ifdef STATISTICS
++mp->pagenew;
@@ -170,7 +170,7 @@
if (bp->flags & MPOOL_PINNED) {
(void)fprintf(stderr,
"mpool_get: page %d already pinned\n", bp->pgno);
- abort();
+ LIBC_ABORT("page %d already pinned", bp->pgno);
}
#endif
/*
@@ -241,7 +241,7 @@
if (!(bp->flags & MPOOL_PINNED)) {
(void)fprintf(stderr,
"mpool_put: page %d not pinned\n", bp->pgno);
- abort();
+ LIBC_ABORT("page %d not pinned", bp->pgno);
}
#endif
bp->flags &= ~MPOOL_PINNED;
@@ -280,10 +280,17 @@
BKT *bp;
/* Walk the lru chain, flushing any dirty pages to disk. */
- TAILQ_FOREACH(bp, &mp->lqh, q)
- if (bp->flags & MPOOL_DIRTY &&
- mpool_write(mp, bp) == RET_ERROR)
- return (RET_ERROR);
+ TAILQ_FOREACH(bp, &mp->lqh, q) {
+ if (bp->flags & MPOOL_DIRTY) {
+ if (mpool_write(mp, bp) == RET_ERROR) {
+ return (RET_ERROR);
+ } else {
+ /* 4874757: Re-run through the user's pgin filter. */
+ if (mp->pgin != NULL)
+ (mp->pgin)(mp->pgcookie, bp->pgno, bp->page);
+ }
+ }
+ }
/* Sync the file descriptor. */
return (_fsync(mp->fd) ? RET_ERROR : RET_SUCCESS);