cachemgr.h revision b57459abfba36eb3068cfe44c6921168b4c4f774
ccf9d4a5c6453fa9f8b839baeee25147865fbb7dJames Phillpotts/*
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * CDDL HEADER START
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster *
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * The contents of this file are subject to the terms of the
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * Common Development and Distribution License (the "License").
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * You may not use this file except in compliance with the License.
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster *
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * or http://www.opensolaris.org/os/licensing.
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * See the License for the specific language governing permissions
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * and limitations under the License.
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster *
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * When distributing Covered Code, include this CDDL HEADER in each
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * If applicable, add the following below this CDDL HEADER, with the
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * fields enclosed by brackets "[]" replaced with your own identifying
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * information: Portions Copyright [yyyy] [name of copyright owner]
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster *
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * CDDL HEADER END
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster */
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster/*
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * Use is subject to license terms.
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster */
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster#ifndef _CACHEMGR_H
ccf9d4a5c6453fa9f8b839baeee25147865fbb7dJames Phillpotts#define _CACHEMGR_H
bcb85423bc6855cb1c7accc69fa051e1771c000aMark de Reeper
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster#ifdef __cplusplus
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Fosterextern "C" {
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster#endif
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster#include <thread.h>
57a1b25dcdf865eacb2fe2e17c5ca83e942da047David Luna#include <synch.h>
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster#include <unistd.h>
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster#include <procfs.h>
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster#include "ns_sldap.h"
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster#include "ns_internal.h"
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster#include "ns_cache_door.h"
ccf9d4a5c6453fa9f8b839baeee25147865fbb7dJames Phillpotts#include "cachemgr_door.h"
ccf9d4a5c6453fa9f8b839baeee25147865fbb7dJames Phillpotts
ccf9d4a5c6453fa9f8b839baeee25147865fbb7dJames Phillpotts#define LOGFILE "/var/ldap/cachemgr.log"
ccf9d4a5c6453fa9f8b839baeee25147865fbb7dJames Phillpotts#define KILLCACHEMGR "/var/lib/ldap/ldap_cachemgr -K"
ccf9d4a5c6453fa9f8b839baeee25147865fbb7dJames Phillpotts#define MAXBITSIZE 30
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster#define MAXDEBUG DBG_ALL
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster#define DEFAULTTTL 3600 /* 1 hour */
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Fostertypedef union {
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster ldap_data_t data;
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster char space[BUFFERSIZE];
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster} dataunion;
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster/*
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * In ldap_cachemgr, it return -99 for some case, start with -100 here
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster */
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Fostertypedef enum chg_error {
bcb85423bc6855cb1c7accc69fa051e1771c000aMark de Reeper CHG_SUCCESS = 0,
bcb85423bc6855cb1c7accc69fa051e1771c000aMark de Reeper CHG_NO_MEMORY = -100,
ccf9d4a5c6453fa9f8b839baeee25147865fbb7dJames Phillpotts CHG_INVALID_PARAM = -101,
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster CHG_NOT_FOUND_IN_WAITING_LIST = -102,
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster CHG_EXCEED_MAX_THREADS = -103,
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster CHG_NSCD_REPEATED_CALL = -104
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster} chg_error_t;
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Fostertypedef struct waiting_list {
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster pid_t pid; /* pid of the door client */
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster thread_t tid; /* thread id of the server */
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster /* thread */
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster int cleanup; /* 1: the thread will be */
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster /* cleaned up */
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster struct waiting_list *prev; /* previous node in the */
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster /* linked list */
57a1b25dcdf865eacb2fe2e17c5ca83e942da047David Luna struct waiting_list *next; /* next node in the linked */
57a1b25dcdf865eacb2fe2e17c5ca83e942da047David Luna /* list */
57a1b25dcdf865eacb2fe2e17c5ca83e942da047David Luna} waiting_list_t;
ccf9d4a5c6453fa9f8b839baeee25147865fbb7dJames Phillpotts
be34d3a7cf588cb751d61e9acc86f1ff328e0344ian.packer/*
be34d3a7cf588cb751d61e9acc86f1ff328e0344ian.packer * This structure contains the buffer for the chang data and a wating list to
be34d3a7cf588cb751d61e9acc86f1ff328e0344ian.packer * regester all the threads that handle GETSTATUSCHANGE START call and are
be34d3a7cf588cb751d61e9acc86f1ff328e0344ian.packer * waiting for the change notification.
be34d3a7cf588cb751d61e9acc86f1ff328e0344ian.packer * The notification threads save the data in the buffer then send broadcast
be34d3a7cf588cb751d61e9acc86f1ff328e0344ian.packer * to wake up the GETSTATUSCHANGE START threads to copy data to the stack and
be34d3a7cf588cb751d61e9acc86f1ff328e0344ian.packer * door_return().
be34d3a7cf588cb751d61e9acc86f1ff328e0344ian.packer */
be34d3a7cf588cb751d61e9acc86f1ff328e0344ian.packertypedef struct chg_info {
be34d3a7cf588cb751d61e9acc86f1ff328e0344ian.packer mutex_t chg_lock; /* mutex for this data structure */
be34d3a7cf588cb751d61e9acc86f1ff328e0344ian.packer cond_t chg_cv; /* cond var for synchronization */
be34d3a7cf588cb751d61e9acc86f1ff328e0344ian.packer int chg_wakeup; /* flag used with chg_cv for */
be34d3a7cf588cb751d61e9acc86f1ff328e0344ian.packer /* synchronization */
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster waiting_list_t *chg_w_first; /* the head of the linked list */
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster waiting_list_t *chg_w_last; /* the tail of the linked list */
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster char *chg_data; /* the buffer for the change data */
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster int chg_data_size; /* the size of the change data */
} chg_info_t;
extern char *getcacheopt(char *s);
extern void logit(char *format, ...);
extern int load_admin_defaults(admin_t *ptr, int will_become_server);
extern int getldap_init(void);
extern void getldap_revalidate(void);
extern int getldap_uidkeepalive(int keep, int interval);
extern int getldap_invalidate(void);
extern void getldap_lookup(LineBuf *config_info, ldap_call_t *in);
extern void getldap_admincred(LineBuf *config_info, ldap_call_t *in);
extern void getldap_refresh(void);
extern int cachemgr_set_dl(admin_t *ptr, int value);
extern int cachemgr_set_ttl(ldap_stat_t *cache, char *name, int value);
extern int get_clearance(int callnumber);
extern int release_clearance(int callnumber);
#ifdef SLP
extern void discover();
#endif /* SLP */
extern void getldap_serverInfo_refresh(void);
extern void getldap_getserver(LineBuf *config_info, ldap_call_t *in);
extern void getldap_get_cacheData(LineBuf *config_info, ldap_call_t *in);
extern int getldap_set_cacheData(ldap_call_t *in);
extern void getldap_get_cacheStat(LineBuf *stat_info);
extern int is_called_from_nscd(pid_t pid); /* in cachemgr.c */
extern int chg_is_called_from_nscd_or_peruser_nscd(char *dc_str, pid_t *pidp);
extern void *chg_cleanup_waiting_threads(void *arg);
extern int chg_get_statusChange(LineBuf *config_info, ldap_call_t *in,
pid_t nscd_pid);
extern int chg_notify_statusChange(char *str);
extern void chg_test_config_change(ns_config_t *new, int *change_status);
extern void chg_config_cookie_set(ldap_get_chg_cookie_t *cookie);
extern ldap_get_chg_cookie_t chg_config_cookie_get(void);
#ifdef __cplusplus
}
#endif
#endif /* _CACHEMGR_H */