cache_api.cc revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 1996-2003 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/* The C interface to directory cache class functions */
#include "mt.h"
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <stdio.h>
#include "../gen/nis_local.h"
#include "local_cache.h"
#include "client_cache.h"
#include "mgr_cache.h"
static int checked_env = 0; /* protected by cur_cache_lock */
extern char *__nis_server; /* if set, use only this server for binding */
extern "C" {
extern void __nis_get_environment(); /* in libc/port/gen/nss_common.c */
#define MGR_CHECK_INTERVAL 300
/*
* Initializes the client cache. Allocates the global data strucuture
* NisSharedCache which is used by the other cache routines.
* We return a copy of the cache variable so that it will remain
* constant for each thread. We can change the cache variable
* from the shared cache to the local cache, but we must not
* delete the cache because another thread might still be using it
* (except in this routine if we create a cache with an error).
*/
{
if (!checked_env) {
__nis_get_environment(); /* in libc/port/gen/nss_common.c */
checked_env = 1;
}
}
/* Verify cachemgr still running; checkUp() is no-op for local cache */
} else {
}
}
/*
* If an explicit server for binding has been set, then
* we can't use the shared cache because its server
* rankings will conflict with ours.
*/
if (!__nis_server) {
} else if (status != NIS_SUCCESS) {
delete cur_cache;
}
}
} else if (status != NIS_SUCCESS) {
delete cur_cache;
}
} else if (status != NIS_SUCCESS) {
delete cur_cache;
}
}
}
return (status);
}
/*
* The Federated Naming code needs to be able to talk to NIS+ servers
* in foreign domains. It does this by calling __nis_CacheAddEntry
* with a "fabricated" directory object. The binding code needs to
* check to for these added directories. The simplest way to handle
* it would be to switch over to using the local cache but then we
* wouldn't be able to take advantage of the shared directory cache
* for lookups in the local domain. So, instead, we create an
* auxiliary local cache and check there for bindings first.
*
* Note that if the application is already using a local cache,
* then we will be creating another local cache. That doesn't
* break anything (it just uses more memory), but it makes the
* code simpler to not check for this special case, which shouldn't
* happen under normal circumstances.
*/
static
int
{
int nsrv;
/* check to see if we have an auxiliary cache */
return (NIS_NOTFOUND);
}
/* check to see if directory is in the cache */
if (err == NIS_CACHEEXPIRED && t != 0) {
/* Exists, but has expired; refresh it */
aux_cache->refreshBinding(t);
nis_free_binding(t);
/*
* If we're still getting NIS_CACHEEXPIRED, we'll
* continue using the expired object until the next
* refresh attempt.
*/
if (err == NIS_CACHEEXPIRED)
err = NIS_SUCCESS;
}
if (err != NIS_SUCCESS)
return (NIS_NOTFOUND);
if (flags & MASTER_ONLY) {
} else {
}
nis_free_binding(t);
return (err);
}
void
{
while (1) {
return;
break;
}
}
/*
* The C interface to NisCache::Bind().
* Returns a directory structure for a given dir_name.
*/
{
while (1) {
return (status);
break;
}
if (err == NIS_SUCCESS) {
sizeof (directory_obj));
} else {
}
return (err);
}
/*
* The C interface to NisSharedCache::removeEntry()
* Removes an entry from the cache.
*/
{
while (1) {
return (status);
/* Expired is good enough, since we intend to refresh it */
if (err == NIS_CACHEEXPIRED)
err = NIS_SUCCESS;
break;
}
if (err == NIS_SUCCESS) {
/*
* For the local cache, we really do want to remove the
* binding, but for the shared (mapped) cache, we just
* refresh instead. The resetBinding() function will
* do this for us.
*/
}
return (NIS_SUCCESS);
}
/*
* The C interface to NisSharedCache::search()
* searches the cache for a given directory_name
*/
{
sizeof (directory_obj));
return (NIS_SUCCESS);
}
while (1) {
return (err);
/* Exists, but has expired; refresh it */
/*
* If we're still getting NIS_CACHEEXPIRED, we'll
* continue using the expired object until the next
* refresh attempt.
*/
if (err == NIS_CACHEEXPIRED)
err = NIS_SUCCESS;
}
break;
}
if (err == NIS_SUCCESS) {
sizeof (directory_obj));
} else {
}
return (err);
}
/*
* The C interface to NisSharedCache::read_coldstart().
* It tells the caching system to reinitialize from the coldstart file.
* sends a message to cachemgr if the cachefile is valid to do this or
* if local_cache is valid reads in the coldstart on its own.
*/
void
{
while (1) {
return;
(void) cache->readColdStart();
break;
}
}
/*
* The C interface to NisSharedCache::print()
* dumps the entrire cache on stdout.
*/
void
{
while (1) {
return;
break;
}
}
{
if (!aux_cache) {
return (0);
} else if (status != NIS_SUCCESS) {
delete aux_cache;
return (0);
}
}
/* make a copy of the dir. obj. because createBinding() frees it */
if (!tmp) {
return (NIS_NOMEMORY);
}
return (NIS_NOMEMORY);
}
return (0);
return (1);
}
void
__nis_CacheRefreshEntry(char *)
{
/* this function is obsolete, but remains for compatibility */
}
{
return (NIS_SUCCESS);
while (1) {
return (status);
if (flags & MASTER_ONLY)
else
break;
}
return (status);
}
{
return (NIS_SUCCESS);
while (1) {
return (status);
break;
}
return (status);
}
{
while (1) {
return (status);
break;
}
return (status);
}
int
{
int status;
return (1);
while (1) {
return (0);
break;
}
return (status);
}
int
{
int status;
while (1) {
return (0);
break;
}
return (status);
}
int
{
int status;
while (1) {
return (0);
break;
}
return (status);
}
{
return (cur_cache->loadPreferredServers());
}
{
if (!checked_env) {
__nis_get_environment(); /* in libc/port/gen/nss_common.c */
checked_env = 1;
}
} else if (status != NIS_SUCCESS) {
delete cur_cache;
}
return (status);
}
{
if (!checked_env) {
__nis_get_environment(); /* in libc/port/gen/nss_common.c */
checked_env = 1;
}
} else if (status != NIS_SUCCESS) {
delete mgr_cache;
}
if (mgr_cache)
return (status);
}
{
return (__nis_CacheMgrInit_discard(0));
}
void
{
if (mgr_cache)
delete mgr_cache;
}
void
{
(void) mgr_cache->readColdStart();
}
__nis_CacheMgrBindReplica(char *dname)
{
if (err == NIS_SUCCESS)
return (err);
}
__nis_CacheMgrBindMaster(char *dname)
{
if (err == NIS_SUCCESS)
return (err);
}
{
if (err == NIS_SUCCESS)
return (err);
}
int
{
int ret;
uint_t i;
return (1);
/*
* A probable reason for a refresh request from the NIS+
* client code is that a server address has changed. Since we
* don't know which one the client was trying, we toss out
* all of them.
*/
}
/* Ping to get new active bindings */
return (ret);
}
int
{
}
int
{
}
int
__nis_CacheMgrUpdateUaddr(char *uaddr)
{
}
void
{
}
{
}
{
return (mgr_cache->refreshCache());
}
{
return (cur_cache->refreshCache());
}
} /* extern "C" */