/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (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 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <stdlib.h>
#include <stdio.h>
#include "nscd_db.h"
#include "nscd_log.h"
/*
* internal structure representing a nscd internal address
*/
typedef struct nscd_int_addr {
int type;
void *ptr;
/*
* FUNCTION: _nscd_create_int_addrDB
*
* Create the internal address database to keep track of the
* memory allocated by _nscd_alloc.
*/
void *
{
(me, "initializing the internal address database\n");
(void) rw_wrlock(&addrDB_rwlock);
(void) rw_unlock(&addrDB_rwlock);
return (addrDB);
}
(void) rw_unlock(&addrDB_rwlock);
return (ret);
}
/*
* FUNCTION: _nscd_add_int_addr
*
* Add an address of 'type' to the internal address database.
*/
void *ptr,
int type,
{
int size;
return (NSCD_INVALID_ARGUMENT);
return (NSCD_NO_MEMORY);
(void) rw_wrlock(&addrDB_rwlock);
(void) rw_unlock(&addrDB_rwlock);
return (NSCD_SUCCESS);
}
/*
* FUNCTION: _nscd_is_int_addr
*
* Check to see if an address can be found in the internal
* address database, if so, obtain a reader lock on the
* associated rw_lock. The caller needs to unlock it when
* done using the data.
*/
rwlock_t *
void *ptr,
{
return (NULL);
(void) rw_rdlock(&addrDB_rwlock);
(const char *)ptrstr, NSCD_GET_FIRST_DB_ENTRY, 0);
(void) rw_rdlock(addr_rwlock);
/*
* If the data is marked as to be deleted
* or the sequence number does not match,
* return NULL.
*/
(void) rw_unlock(addr_rwlock);
addr_rwlock = NULL;
}
} else
addr_rwlock = NULL;
(void) rw_unlock(&addrDB_rwlock);
return (addr_rwlock);
}
/*
* FUNCTION: _nscd_del_int_addr
*
* Delete an address from the internal address database.
*/
void
void *ptr,
{
return;
(void) rw_rdlock(&addrDB_rwlock);
/*
* first find the db entry and make sure that
* no one is currently locking it. i.e.,
* no one is waiting to use the same address.
* If it is locked, rw_wrlock() will not return
* until it is unlocked.
*/
(const char *)ptrstr,
(void) rw_wrlock(addr_rwlock);
} else {
(void) rw_unlock(&addrDB_rwlock);
return;
}
(void) rw_unlock(&addrDB_rwlock);
/*
* delete the db entry if the sequence numbers match
*/
(void) rw_wrlock(&addrDB_rwlock);
(void) _nscd_delete_db_entry(addrDB,
(const char *)ptrstr,
(void) rw_unlock(&addrDB_rwlock);
}
}
/*
* FUNCTION: _nscd_destroy_int_addrDB
*
* Destroy the internal address database.
*/
void
{
(void) rw_wrlock(&addrDB_rwlock);
(void) rw_unlock(&addrDB_rwlock);
}