summaryrefslogtreecommitdiffstats
path: root/usr.sbin/ypserv/yp_dblookup.c
diff options
context:
space:
mode:
authorwpaul <wpaul@FreeBSD.org>1996-06-05 02:01:31 +0000
committerwpaul <wpaul@FreeBSD.org>1996-06-05 02:01:31 +0000
commitcf31622e837736537d53be8762523f3fecb07ae6 (patch)
tree8366e6ebd8e180952579e3ace571fee8de12afba /usr.sbin/ypserv/yp_dblookup.c
parentf12d02958af4923cccf62583718f39baa06fa941 (diff)
downloadFreeBSD-src-cf31622e837736537d53be8762523f3fecb07ae6.zip
FreeBSD-src-cf31622e837736537d53be8762523f3fecb07ae6.tar.gz
Makefile.yp:
- Add a 'pushpw' target that only yppushes the various passwd maps and sends a YPPROC_CLEAR to the local ypserv. This will be used by rpc.yppasswdd once I merge in the in-place update changes. yp_access.c: - Make the yp_access() function print RPC program and procedure numbers that it doesn't know about in literal form. This will allow it to work with other prgrams that it doesn't know about, like rpc.ypxfrd I'm going to import shortly. yp_dblookup.c: - Take out the __inline keywords. They weren't really helping me anyway. - Somehow I broke yp_next() when DB_CACHE wasn't #defined. Fix it. - Also fix potential case where yp_next() might loop forever; make sure it checks the return values of all the (dbp->seq)()/R_NEXT calls that it does as well as comparing keys.
Diffstat (limited to 'usr.sbin/ypserv/yp_dblookup.c')
-rw-r--r--usr.sbin/ypserv/yp_dblookup.c38
1 files changed, 23 insertions, 15 deletions
diff --git a/usr.sbin/ypserv/yp_dblookup.c b/usr.sbin/ypserv/yp_dblookup.c
index 76370f4..ea288a4 100644
--- a/usr.sbin/ypserv/yp_dblookup.c
+++ b/usr.sbin/ypserv/yp_dblookup.c
@@ -29,7 +29,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: yp_dblookup.c,v 1.9 1996/05/01 02:33:52 wpaul Exp $
+ * $Id: yp_dblookup.c,v 1.13 1996/06/04 04:08:21 wpaul Exp $
*
*/
#include <stdio.h>
@@ -47,7 +47,7 @@
#include "yp_extern.h"
#ifndef lint
-static const char rcsid[] = "$Id: yp_dblookup.c,v 1.9 1996/05/01 02:33:52 wpaul Exp $";
+static const char rcsid[] = "$Id: yp_dblookup.c,v 1.13 1996/06/04 04:08:21 wpaul Exp $";
#endif
int ypdb_debug = 0;
@@ -57,7 +57,7 @@ int yp_errno = YP_TRUE;
HASHINFO openinfo = {
4096, /* bsize */
32, /* ffactor */
- 512, /* nelem */
+ 256, /* nelem */
2048 * 512, /* cachesize */
NULL, /* hash */
0, /* lorder */
@@ -93,7 +93,7 @@ void yp_init_dbs()
* Zorch a single entry in the dbent table and release
* all its resources.
*/
-static __inline void yp_flush(i)
+static void yp_flush(i)
register int i;
{
(void)(dbs[i]->dbp->close)(dbs[i]->dbp);
@@ -128,7 +128,7 @@ void yp_flush_all()
* a new entry when all our slots are already filled, we have to kick
* out the entry in the last slot to make room.
*/
-static __inline void yp_add_db(dbp, name, size)
+static void yp_add_db(dbp, name, size)
DB *dbp;
char *name;
int size;
@@ -190,7 +190,7 @@ static __inline void yp_add_db(dbp, name, size)
* array so that it will be easier to find if another request for
* the same database comes in later.
*/
-static __inline DB *yp_find_db(name, key, size)
+static DB *yp_find_db(name, key, size)
char *name;
char *key;
int size;
@@ -202,12 +202,11 @@ static __inline DB *yp_find_db(name, key, size)
if (dbs[i]->name != NULL && !strcmp(dbs[i]->name, name)) {
if (size) {
if (size != dbs[i]->size ||
- strncmp(dbs[i]->key, key, size))
+ strncmp(dbs[i]->key, key, size))
continue;
} else {
- if (dbs[i]->size) {
+ if (dbs[i]->size)
continue;
- }
}
if (i > 0) {
tmp = dbs[i];
@@ -218,6 +217,7 @@ static __inline DB *yp_find_db(name, key, size)
return(dbs[0]->dbp);
}
}
+
return(NULL);
}
@@ -235,6 +235,9 @@ DB *yp_open_db_cache(domain, map, key, size)
{
DB *dbp = NULL;
char buf[MAXPATHLEN + 2];
+/*
+ snprintf(buf, sizeof(buf), "%s/%s", domain, map);
+*/
strcpy(buf, domain);
strcat(buf, "/");
@@ -451,17 +454,22 @@ int yp_next_record(dbp,key,data,all,allow)
key->size, key->data);
if (!all) {
-#ifndef DB_CACHE
- if (key->size != lkey.size ||
- strncmp(key->data, lkey.data, key->size)) {
-#else
- if (!dbs[0]->size) {
+#ifdef DB_CACHE
+ if (!dbs[0]->key) {
#endif
(dbp->seq)(dbp,&lkey,&ldata,R_FIRST);
while(strncmp((char *)key->data,lkey.data,
(int)key->size) || key->size != lkey.size)
- (dbp->seq)(dbp,&lkey,&ldata,R_NEXT);
+ if ((dbp->seq)(dbp,&lkey,&ldata,R_NEXT)) {
+#ifdef DB_CACHE
+ dbs[0]->size = 0;
+#endif
+ return(YP_NOKEY);
+ }
+
+#ifdef DB_CACHE
}
+#endif
}
if ((dbp->seq)(dbp,key,data,R_NEXT)) {
OpenPOWER on IntegriCloud