|
|
7809d0 |
diff -r -u db-5.3.21_orig/src/mp/mp_stat.c db-5.3.21/src/mp/mp_stat.c
|
|
|
7809d0 |
--- db-5.3.21_orig/src/mp/mp_stat.c 2012-05-12 01:57:53.000000000 +0800
|
|
|
7809d0 |
+++ db-5.3.21/src/mp/mp_stat.c 2015-05-19 15:07:09.000000000 +0800
|
|
|
7809d0 |
@@ -87,6 +87,13 @@
|
|
|
7809d0 |
u_int32_t i;
|
|
|
7809d0 |
uintmax_t tmp_wait, tmp_nowait;
|
|
|
7809d0 |
|
|
|
7809d0 |
+ /*
|
|
|
7809d0 |
+ * The array holding the lengths related to the buffer allocated for *fspp.
|
|
|
7809d0 |
+ * The first element of the array holds the number of entries allocated.
|
|
|
7809d0 |
+ * The second element of the array holds the total number of bytes allocated.
|
|
|
7809d0 |
+ */
|
|
|
7809d0 |
+ u_int32_t fsp_len[2];
|
|
|
7809d0 |
+
|
|
|
7809d0 |
dbmp = env->mp_handle;
|
|
|
7809d0 |
mp = dbmp->reginfo[0].primary;
|
|
|
7809d0 |
|
|
|
7809d0 |
@@ -193,32 +200,53 @@
|
|
|
7809d0 |
if (fspp != NULL) {
|
|
|
7809d0 |
*fspp = NULL;
|
|
|
7809d0 |
|
|
|
7809d0 |
- /* Count the MPOOLFILE structures. */
|
|
|
7809d0 |
- i = 0;
|
|
|
7809d0 |
- len = 0;
|
|
|
7809d0 |
- if ((ret = __memp_walk_files(env,
|
|
|
7809d0 |
- mp, __memp_count_files, &len, &i, flags)) != 0)
|
|
|
7809d0 |
- return (ret);
|
|
|
7809d0 |
+ while (*fspp == NULL) {
|
|
|
7809d0 |
+ /* Count the MPOOLFILE structures. */
|
|
|
7809d0 |
+ i = 0;
|
|
|
7809d0 |
+ /*
|
|
|
7809d0 |
+ * Allow space for the first __memp_get_files() to align the
|
|
|
7809d0 |
+ * structure array to uintmax_t, DB_MPOOL_STAT's most
|
|
|
7809d0 |
+ * restrictive field. [#23150]
|
|
|
7809d0 |
+ */
|
|
|
7809d0 |
+ len = sizeof(uintmax_t);
|
|
|
7809d0 |
+ if ((ret = __memp_walk_files(env,
|
|
|
7809d0 |
+ mp, __memp_count_files, &len, &i, flags)) != 0)
|
|
|
7809d0 |
+ return (ret);
|
|
|
7809d0 |
+
|
|
|
7809d0 |
+ if (i == 0)
|
|
|
7809d0 |
+ return (0);
|
|
|
7809d0 |
+
|
|
|
7809d0 |
+ /*
|
|
|
7809d0 |
+ * Copy the number of DB_MPOOL_FSTAT entries and the number of
|
|
|
7809d0 |
+ * bytes allocated for them into fsp_len. Do not count the space
|
|
|
7809d0 |
+ * reserved for allignment.
|
|
|
7809d0 |
+ */
|
|
|
7809d0 |
+ fsp_len[0] = i;
|
|
|
7809d0 |
+ fsp_len[1] = len - sizeof(uintmax_t);
|
|
|
7809d0 |
|
|
|
7809d0 |
- if (i == 0)
|
|
|
7809d0 |
- return (0);
|
|
|
7809d0 |
- len += sizeof(DB_MPOOL_FSTAT *); /* Trailing NULL */
|
|
|
7809d0 |
+ len += sizeof(DB_MPOOL_FSTAT *); /* Trailing NULL */
|
|
|
7809d0 |
|
|
|
7809d0 |
- /* Allocate space */
|
|
|
7809d0 |
- if ((ret = __os_umalloc(env, len, fspp)) != 0)
|
|
|
7809d0 |
- return (ret);
|
|
|
7809d0 |
+ /* Allocate space */
|
|
|
7809d0 |
+ if ((ret = __os_umalloc(env, len, fspp)) != 0)
|
|
|
7809d0 |
+ return (ret);
|
|
|
7809d0 |
|
|
|
7809d0 |
- tfsp = *fspp;
|
|
|
7809d0 |
- *tfsp = NULL;
|
|
|
7809d0 |
-
|
|
|
7809d0 |
- /*
|
|
|
7809d0 |
- * Files may have been opened since we counted, don't walk
|
|
|
7809d0 |
- * off the end of the allocated space.
|
|
|
7809d0 |
- */
|
|
|
7809d0 |
- if ((ret = __memp_walk_files(env,
|
|
|
7809d0 |
- mp, __memp_get_files, &tfsp, &i, flags)) != 0)
|
|
|
7809d0 |
- return (ret);
|
|
|
7809d0 |
+ tfsp = *fspp;
|
|
|
7809d0 |
+ *tfsp = NULL;
|
|
|
7809d0 |
|
|
|
7809d0 |
+ /*
|
|
|
7809d0 |
+ * Files may have been opened since we counted, if we walk off
|
|
|
7809d0 |
+ * the end of the allocated space specified in fsp_len, retry.
|
|
|
7809d0 |
+ */
|
|
|
7809d0 |
+ if ((ret = __memp_walk_files(env,
|
|
|
7809d0 |
+ mp, __memp_get_files, &tfsp, fsp_len, flags)) != 0) {
|
|
|
7809d0 |
+ if (ret == DB_BUFFER_SMALL) {
|
|
|
7809d0 |
+ __os_ufree(env, *fspp);
|
|
|
7809d0 |
+ *fspp = NULL;
|
|
|
7809d0 |
+ tfsp = NULL;
|
|
|
7809d0 |
+ } else
|
|
|
7809d0 |
+ return (ret);
|
|
|
7809d0 |
+ }
|
|
|
7809d0 |
+ }
|
|
|
7809d0 |
*++tfsp = NULL;
|
|
|
7809d0 |
}
|
|
|
7809d0 |
|
|
|
7809d0 |
@@ -286,28 +314,35 @@
|
|
|
7809d0 |
* for the text file names.
|
|
|
7809d0 |
*/
|
|
|
7809d0 |
static int
|
|
|
7809d0 |
-__memp_get_files(env, mfp, argp, countp, flags)
|
|
|
7809d0 |
+__memp_get_files(env, mfp, argp, fsp_len, flags)
|
|
|
7809d0 |
ENV *env;
|
|
|
7809d0 |
MPOOLFILE *mfp;
|
|
|
7809d0 |
void *argp;
|
|
|
7809d0 |
- u_int32_t *countp;
|
|
|
7809d0 |
+ u_int32_t fsp_len[];
|
|
|
7809d0 |
u_int32_t flags;
|
|
|
7809d0 |
{
|
|
|
7809d0 |
DB_MPOOL *dbmp;
|
|
|
7809d0 |
DB_MPOOL_FSTAT **tfsp, *tstruct;
|
|
|
7809d0 |
char *name, *tname;
|
|
|
7809d0 |
- size_t nlen;
|
|
|
7809d0 |
+ size_t nlen, tlen;
|
|
|
7809d0 |
|
|
|
7809d0 |
- if (*countp == 0)
|
|
|
7809d0 |
- return (0);
|
|
|
7809d0 |
+ /* We walked through more files than argp was allocated for. */
|
|
|
7809d0 |
+ if (fsp_len[0] == 0)
|
|
|
7809d0 |
+ return DB_BUFFER_SMALL;
|
|
|
7809d0 |
|
|
|
7809d0 |
dbmp = env->mp_handle;
|
|
|
7809d0 |
tfsp = *(DB_MPOOL_FSTAT ***)argp;
|
|
|
7809d0 |
|
|
|
7809d0 |
if (*tfsp == NULL) {
|
|
|
7809d0 |
- /* Add 1 to count because we need to skip over the NULL. */
|
|
|
7809d0 |
- tstruct = (DB_MPOOL_FSTAT *)(tfsp + *countp + 1);
|
|
|
7809d0 |
- tname = (char *)(tstruct + *countp);
|
|
|
7809d0 |
+ /*
|
|
|
7809d0 |
+ * Add 1 to count because to skip over the NULL end marker.
|
|
|
7809d0 |
+ * Align it further for DB_MPOOL_STAT's most restrictive field
|
|
|
7809d0 |
+ * because uintmax_t might require stricter alignment than
|
|
|
7809d0 |
+ * pointers; e.g., IP32 LL64 SPARC. [#23150]
|
|
|
7809d0 |
+ */
|
|
|
7809d0 |
+ tstruct = (DB_MPOOL_FSTAT *)&tfsp[fsp_len[0] + 1];
|
|
|
7809d0 |
+ tstruct = ALIGNP_INC(tstruct, sizeof(uintmax_t));
|
|
|
7809d0 |
+ tname = (char *)&tstruct[fsp_len[0]];
|
|
|
7809d0 |
*tfsp = tstruct;
|
|
|
7809d0 |
} else {
|
|
|
7809d0 |
tstruct = *tfsp + 1;
|
|
|
7809d0 |
@@ -317,6 +352,15 @@
|
|
|
7809d0 |
|
|
|
7809d0 |
name = __memp_fns(dbmp, mfp);
|
|
|
7809d0 |
nlen = strlen(name) + 1;
|
|
|
7809d0 |
+
|
|
|
7809d0 |
+ /* The space required for file names is larger than argp was allocated for. */
|
|
|
7809d0 |
+ tlen = sizeof(DB_MPOOL_FSTAT *) + sizeof(DB_MPOOL_FSTAT) + nlen;
|
|
|
7809d0 |
+ if (fsp_len[1] < tlen)
|
|
|
7809d0 |
+ return DB_BUFFER_SMALL;
|
|
|
7809d0 |
+ else
|
|
|
7809d0 |
+ /* Count down the number of bytes left in argp. */
|
|
|
7809d0 |
+ fsp_len[1] -= tlen;
|
|
|
7809d0 |
+
|
|
|
7809d0 |
memcpy(tname, name, nlen);
|
|
|
7809d0 |
memcpy(tstruct, &mfp->stat, sizeof(mfp->stat));
|
|
|
7809d0 |
tstruct->file_name = tname;
|
|
|
7809d0 |
@@ -325,7 +369,9 @@
|
|
|
7809d0 |
tstruct->st_pagesize = mfp->pagesize;
|
|
|
7809d0 |
|
|
|
7809d0 |
*(DB_MPOOL_FSTAT ***)argp = tfsp;
|
|
|
7809d0 |
- (*countp)--;
|
|
|
7809d0 |
+
|
|
|
7809d0 |
+ /* Count down the number of entries left in argp. */
|
|
|
7809d0 |
+ fsp_len[0]--;
|
|
|
7809d0 |
|
|
|
7809d0 |
if (LF_ISSET(DB_STAT_CLEAR))
|
|
|
7809d0 |
memset(&mfp->stat, 0, sizeof(mfp->stat));
|
|
|
7809d0 |
diff -r -u db-5.3.21_orig/src/mp/mp_sync.c db-5.3.21/src/mp/mp_sync.c
|
|
|
7809d0 |
--- db-5.3.21_orig/src/mp/mp_sync.c 2012-05-12 01:57:53.000000000 +0800
|
|
|
7809d0 |
+++ db-5.3.21/src/mp/mp_sync.c 2015-05-19 15:08:05.000000000 +0800
|
|
|
7809d0 |
@@ -57,11 +57,13 @@
|
|
|
7809d0 |
if ((t_ret = func(env,
|
|
|
7809d0 |
mfp, arg, countp, flags)) != 0 && ret == 0)
|
|
|
7809d0 |
ret = t_ret;
|
|
|
7809d0 |
- if (ret != 0 && !LF_ISSET(DB_STAT_MEMP_NOERROR))
|
|
|
7809d0 |
+ if (ret != 0 &&
|
|
|
7809d0 |
+ (!LF_ISSET(DB_STAT_MEMP_NOERROR) || ret == DB_BUFFER_SMALL))
|
|
|
7809d0 |
break;
|
|
|
7809d0 |
}
|
|
|
7809d0 |
MUTEX_UNLOCK(env, hp->mtx_hash);
|
|
|
7809d0 |
- if (ret != 0 && !LF_ISSET(DB_STAT_MEMP_NOERROR))
|
|
|
7809d0 |
+ if (ret != 0 &&
|
|
|
7809d0 |
+ (!LF_ISSET(DB_STAT_MEMP_NOERROR) || ret == DB_BUFFER_SMALL))
|
|
|
7809d0 |
break;
|
|
|
7809d0 |
}
|
|
|
7809d0 |
return (ret);
|