local_cache.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 1988-1992,2003 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include "mt.h"
#include <stdlib.h>
#include <values.h>
#include <string.h>
#include <syslog.h>
#include "local_cache.h"
#include "cold_start.h"
{
have_coldstart = 0;
sem_writer = -1;
// read in entry from coldstart file
if (readColdStart())
else
}
{
have_coldstart = 0;
sem_writer = -1;
// read in entry from coldstart file
if (readServerColdStart(exp_time))
else
}
{
// We don't free anything because we don't know
// how many threads have a reference to us.
}
// Return the binding for the directory name if it exists in the cache.
// If 'near' is set, then we return a binding to a directory that is
// close to 'dname'.
{
int distance;
int minDistance = MAXINT;
char **target;
int target_levels;
if (target == 0)
return (NIS_NOMEMORY);
lockShared();
if (distance <= minDistance) {
// if two directories are at the same distance
// then we want to select the directory closer to
// the root.
if (distance == minDistance &&
// this one is further from the root, ignore it
continue;
}
}
if (distance == 0)
break;
}
if (found == 0) {
// cache is empty (no coldstart even)
// we wanted an exact match, but it's not there
err = NIS_NOTFOUND;
} else {
// we got an exact match or something near target
err = NIS_SUCCESS;
found->binding_len);
err = NIS_NOMEMORY;
} else {
gettimeofday(&now, 0);
}
}
}
unlockShared();
if (*binding)
return (err);
}
void
{
int is_coldstart = 0;
if (new_entry == 0)
return;
is_coldstart = 1;
} else {
}
if (prev)
else
}
break;
}
}
if (is_coldstart) {
have_coldstart = 1;
if (tail == 0)
} else {
if (tail)
if (head == 0)
}
}
void
{
char *dname;
have_coldstart = 0;
} else {
}
if (prev)
else
}
break;
}
}
}
{
entry = new LocalCacheEntry;
if (!entry)
return (NULL);
return (NULL);
}
return (entry);
}
void
{
if (entry->components)
delete entry;
}
void
{
if (entry) {
}
}
void
{
if (prev)
else
if (all)
goto restart;
break;
}
}
}
int
{
int ret = 0;
lockShared();
ret = 1;
break;
}
}
unlockShared();
return (ret);
}
int
{
int ret = 0;
lockShared();
ret = 1;
break;
}
}
unlockShared();
return (ret);
}
int
{
int ret = 0;
lockShared();
ret++;
}
*actlist = (nis_active_endpoint **)
unlockShared();
return (0);
}
}
unlockShared();
return (ret);
}
{
entry = new LocalActiveEntry;
return (NULL);
return (entry);
}
void
{
delete entry;
}
void
{
int i;
lockShared();
// hack for special format in nisshowcache
if (__nis_debuglevel != 6) {
if (i == 0 && have_coldstart)
(void) printf("\nCold Start directory:\n");
else
(void) printf("\nNisLocalCacheEntry[%d]:\n", i);
}
if (__nis_debuglevel == 1) {
}
if (__nis_debuglevel > 2) {
entry->binding_len);
}
}
}
(void) printf("\nActive servers:\n");
}
unlockShared();
}
void
{
}
void
{
}
void
{
}
void
{
}
int
{
union semun {
int val;
} semarg;
if (sem_writer == -1) {
// get writer semaphore
if (sem_writer == -1) {
return (0);
}
}
// get writer semaphore value
return (0);
}
// check to see if a manager is already handling the cache
if (w_array[NIS_SEM_MGR_UP] == 0)
return (0);
return (1);
}
{
if (!mgrUp()) {
return (0);
}
/*
* read from the "dot" file first. If successful, return the
* TTL value.
*/
ul = loadDotFile();
if (ul > 0)
return (ul);
/* failed to load the Dot file. */
return (0);
}
{
ul = loadPreferredServers();
if (ul > 0) {
return (ul);
}
return (expireTime(ONE_HOUR));
}
int
return (1);
}