Commit e93401aa authored by cvs2hg's avatar cvs2hg

fixup commit for tag 'DBM_1_61_RTM'

parent acaf5e78

Too many changes to show.

To preserve performance only 1000 of 1000+ files are displayed.

......@@ -240,9 +240,9 @@
#include "xp_mcom.h"
#define O_ACCMODE 3 /* Mask for file access modes */
#define EFTYPE 2000
XP_BEGIN_PROTOS
PR_BEGIN_EXTERN_C
int mkstemp(const char *path);
XP_END_PROTOS
PR_END_EXTERN_C
#endif /* MACINTOSH */
#if !defined(_WINDOWS) && !defined(macintosh) && !defined(XP_OS2)
......
......@@ -364,6 +364,7 @@ __big_return(
BUFHEAD *save_p;
uint16 *bp, len, off, save_addr;
char *tp;
int save_flags;
bp = (uint16 *)bufp->page;
while (bp[ndx + 1] == PARTIAL_KEY) {
......@@ -428,7 +429,12 @@ __big_return(
return (0);
}
/* pin our saved buf so that we don't lose if
* we run out of buffers */
save_flags = save_p->flags;
save_p->flags |= BUF_PIN;
val->size = collect_data(hashp, bufp, (int)len, set_current);
save_p->flags = save_flags;
if (val->size == (size_t)-1)
return (-1);
if (save_p->addr != save_addr) {
......@@ -440,9 +446,14 @@ __big_return(
val->data = (uint8 *)hashp->tmp_buf;
return (0);
}
/*
* Count how big the total datasize is by recursing through the pages. Then
* allocate a buffer and copy the data as you recurse up.
* Count how big the total datasize is by looping through the pages. Then
* allocate a buffer and copy the data in the second loop. NOTE: Our caller
* may already have a bp which it is holding onto. The caller is
* responsible for copying that bp into our temp buffer. 'len' is how much
* space to reserve for that buffer.
*/
static int
collect_data(
......@@ -451,56 +462,77 @@ collect_data(
int len, int set)
{
register uint16 *bp;
register char *p;
BUFHEAD *xbp;
uint16 save_addr;
BUFHEAD *save_bufp;
int save_flags;
int mylen, totlen;
p = bufp->page;
bp = (uint16 *)p;
mylen = hashp->BSIZE - bp[1];
/* if mylen ever goes negative it means that the
* page is screwed up.
/*
* save the input buf head because we need to walk the list twice.
* pin it to make sure it doesn't leave the buffer pool.
* This has the effect of growing the buffer pool if necessary.
*/
if(mylen < 0)
save_bufp = bufp;
save_flags = save_bufp->flags;
save_bufp->flags |= BUF_PIN;
/* read the length of the buffer */
for (totlen = len; bufp ; bufp = __get_buf(hashp, bp[bp[0]-1], bufp, 0)) {
bp = (uint16 *)bufp->page;
mylen = hashp->BSIZE - bp[1];
if (mylen < 0) {
save_bufp->flags = save_flags;
return (-1);
}
totlen += mylen;
if (bp[2] == FULL_KEY_DATA) {
break;
}
}
if (!bufp) {
save_bufp->flags = save_flags;
return (-1);
}
save_addr = bufp->addr;
/* allocate a temp buf */
if (hashp->tmp_buf)
free(hashp->tmp_buf);
if ((hashp->tmp_buf = (char *)malloc((size_t)totlen)) == NULL) {
save_bufp->flags = save_flags;
return (-1);
}
if (bp[2] == FULL_KEY_DATA) { /* End of Data */
totlen = len + mylen;
if (hashp->tmp_buf)
free(hashp->tmp_buf);
if ((hashp->tmp_buf = (char *)malloc((size_t)totlen)) == NULL)
return (-1);
if (set) {
hashp->cndx = 1;
if (bp[0] == 2) { /* No more buckets in chain */
hashp->cpage = NULL;
/* copy the buffers back into temp buf */
for (bufp = save_bufp; bufp ;
bufp = __get_buf(hashp, bp[bp[0]-1], bufp, 0)) {
bp = (uint16 *)bufp->page;
mylen = hashp->BSIZE - bp[1];
memmove(&hashp->tmp_buf[len], (bufp->page) + bp[1], (size_t)mylen);
len += mylen;
if (bp[2] == FULL_KEY_DATA) {
break;
}
}
/* 'clear' the pin flags */
save_bufp->flags = save_flags;
/* update the database cursor */
if (set) {
hashp->cndx = 1;
if (bp[0] == 2) { /* No more buckets in chain */
hashp->cpage = NULL;
hashp->cbucket++;
} else {
hashp->cpage = __get_buf(hashp, bp[bp[0] - 1], bufp, 0);
if (!hashp->cpage)
return (-1);
else if (!((uint16 *)hashp->cpage->page)[0]) {
hashp->cbucket++;
} else {
hashp->cpage =
__get_buf(hashp, bp[bp[0] - 1], bufp, 0);
if (!hashp->cpage)
return (-1);
else if (!((uint16 *)hashp->cpage->page)[0]) {
hashp->cbucket++;
hashp->cpage = NULL;
}
hashp->cpage = NULL;
}
}
} else {
xbp = __get_buf(hashp, bp[bp[0] - 1], bufp, 0);
if (!xbp || ((totlen =
collect_data(hashp, xbp, len + mylen, set)) < 1))
return (-1);
}
if (bufp->addr != save_addr) {
errno = EINVAL; /* Out of buffers. */
return (-1);
}
memmove(&hashp->tmp_buf[len], (bufp->page) + bp[1], (size_t)mylen);
return (totlen);
}
......
......@@ -566,9 +566,11 @@ hdestroy(HTAB *hashp)
#endif
free(hashp->filename);
}
if (hashp->tmp_buf)
free(hashp->tmp_buf);
if (hashp->tmp_key)
free(hashp->tmp_key);
free(hashp);
if (save_errno) {
errno = save_errno;
return (DBM_ERROR);
......@@ -900,7 +902,7 @@ hash_access(
n = *bp++;
ndx = 1;
off = hashp->BSIZE;
} else if (bp[1] < REAL_KEY) {
} else if (bp[1] < REAL_KEY) {
if ((ndx =
__find_bigpair(hashp, rbufp, ndx, kp, (int)size)) > 0)
goto found;
......
......@@ -284,6 +284,12 @@ newbuf(HTAB *hashp, uint32 addr, BUFHEAD *prev_bp)
xbp->ovfl = 0;
xbp = next_xbp;
/* leave pinned pages alone, we are still using
* them. */
if (xbp->flags & BUF_PIN) {
continue;
}
/* Check that ovfl pointer is up date. */
if (IS_BUCKET(xbp->flags) ||
(oaddr != xbp->addr))
......
#! gmake
#
# The contents of this file are subject to the Mozilla Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is the Netscape security libraries.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1994-2000 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
#
# Alternatively, the contents of this file may be used under the
# terms of the GNU General Public License Version 2 or later (the
# "GPL"), in which case the provisions of the GPL are applicable
# instead of those above. If you wish to allow use of your
# version of this file only under the terms of the GPL and not to
# allow others to use your version of this file under the MPL,
# indicate your decision by deleting the provisions above and
# replace them with the notice and other provisions required by
# the GPL. If you do not delete the provisions above, a recipient
# may use your version of this file under either the MPL or the
# GPL.
#
#######################################################################
# (1) Include initial platform-independent assignments (MANDATORY). #
#######################################################################
include manifest.mn
#######################################################################
# (2) Include "global" configuration information. (OPTIONAL) #
#######################################################################