SCCS-vsn: lib/libc/db/btree/bt_open.c 5.4
SCCS-vsn: lib/libc/db/btree/bt_put.c 5.2
SCCS-vsn: lib/libc/db/btree/bt_seq.c 5.2
*/
#if defined(LIBC_SCCS) && !defined(lint)
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)bt_open.c 5.3 (Berkeley) %G%";
+static char sccsid[] = "@(#)bt_open.c 5.4 (Berkeley) %G%";
#endif /* LIBC_SCCS and not lint */
/*
#endif /* LIBC_SCCS and not lint */
/*
+ /* access method files are always close-on-exec */
+ if (fcntl(t->bt_s.bt_d.d_fd, F_SETFL, 1) == -1) {
+ (void) close(t->bt_s.bt_d.d_fd);
+ (void) free ((char *) t);
+ return ((BTREE) NULL);
+ }
+
/* get number of pages, page size if necessary */
(void) fstat(t->bt_s.bt_d.d_fd, &buf);
if (t->bt_psize == 0)
/* get number of pages, page size if necessary */
(void) fstat(t->bt_s.bt_d.d_fd, &buf);
if (t->bt_psize == 0)
/* lookup */
item = _bt_search(t, key);
/* lookup */
item = _bt_search(t, key);
- if (item == (BTITEM *) NULL)
- return (RET_ERROR);
/* clear parent pointer stack */
while (_bt_pop(t) != P_NONE)
continue;
/* clear parent pointer stack */
while (_bt_pop(t) != P_NONE)
continue;
+ if (item == (BTITEM *) NULL)
+ return (RET_ERROR);
+
h = (BTHEADER *) t->bt_curpage;
data->size = 0;
data->data = (char *) NULL;
h = (BTHEADER *) t->bt_curpage;
data->size = 0;
data->data = (char *) NULL;
if (VALIDITEM(t, item) && _bt_cmp(t, key->data, item->bti_index) == 0) {
if ((t->bt_flags & BTF_NODUPS) && flag == R_NOOVERWRITE) {
if (VALIDITEM(t, item) && _bt_cmp(t, key->data, item->bti_index) == 0) {
if ((t->bt_flags & BTF_NODUPS) && flag == R_NOOVERWRITE) {
- if (_bt_delone(t, item->bti_index) == RET_ERROR)
+ if (_bt_delone(t, item->bti_index) == RET_ERROR) {
+ while (_bt_pop(t) != P_NONE)
+ continue;
item = _bt_first(t, key);
h = t->bt_curpage;
item = _bt_first(t, key);
h = t->bt_curpage;
+ /* don't need the descent stack for deletes */
+ while (_bt_pop(t) != P_NONE)
+ continue;
+
/* delete all matching keys */
for (;;) {
while (VALIDITEM(t, item)
/* delete all matching keys */
for (;;) {
while (VALIDITEM(t, item)
- /* clean up the parent stack */
- while (_bt_pop(t) != P_NONE)
- continue;
-
/* flush changes to disk */
if (ISDISK(t)) {
if (h->h_flags & F_DIRTY) {
/* flush changes to disk */
if (ISDISK(t)) {
if (h->h_flags & F_DIRTY) {
*/
#if defined(LIBC_SCCS) && !defined(lint)
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)bt_put.c 5.1 (Berkeley) %G%";
+static char sccsid[] = "@(#)bt_put.c 5.2 (Berkeley) %G%";
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
if (_bt_split(t) == RET_ERROR)
return (RET_ERROR);
if (_bt_split(t) == RET_ERROR)
return (RET_ERROR);
+ /* okay, try again (empty the stack first, though) */
+ while (_bt_pop((BTREE) t) != P_NONE)
+ continue;
+
return (bt_put((BTREE) t, key, data, flag));
}
return (bt_put((BTREE) t, key, data, flag));
}
*/
#if defined(LIBC_SCCS) && !defined(lint)
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)bt_seq.c 5.1 (Berkeley) %G%";
+static char sccsid[] = "@(#)bt_seq.c 5.2 (Berkeley) %G%";
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
/* okay, scan is initialized */
t->bt_flags |= BTF_SEQINIT;
/* okay, scan is initialized */
t->bt_flags |= BTF_SEQINIT;
+ /* don't need the descent stack anymore */
+ while (_bt_pop(t) != P_NONE)
+ continue;
+
if (c->c_index == NEXTINDEX(t->bt_curpage))
return (RET_SPECIAL);
if (c->c_index == NEXTINDEX(t->bt_curpage))
return (RET_SPECIAL);