nisdb_mt.cc revision 2
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb * CDDL HEADER START
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb * The contents of this file are subject to the terms of the
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb * Common Development and Distribution License, Version 1.0 only
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb * (the "License"). You may not use this file except in compliance
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb * with the License.
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb * See the License for the specific language governing permissions
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb * and limitations under the License.
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb * When distributing Covered Code, include this CDDL HEADER in each
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb * If applicable, add the following below this CDDL HEADER, with the
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb * fields enclosed by brackets "[]" replaced with your own identifying
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb * information: Portions Copyright [yyyy] [name of copyright owner]
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb * CDDL HEADER END
23a9c295bad892ce51d86fda89698563b5810495Gordon Ross * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb * Use is subject to license terms.
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb#pragma ident "%Z%%M% %I% %E% SMI"
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb if (tsd != 0) {
faa1795a28a5c712eed6d0a3f84d98c368a316c6jbextern "C" {
faa1795a28a5c712eed6d0a3f84d98c368a316c6jbstatic void
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb (void) pthread_key_create(&nisdb_tsd_key, __nisdb_tsd_destroy);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb if ((tsd = (nisdb_tsd_t *)pthread_getspecific(nisdb_tsd_key)) == 0) {
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb /* No TSD; create it */
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb /* Initialize TSD */
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb /* Register TSD */
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb /* Can't store key */
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb /* No memory ? */
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb if (tsd != 0) {
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb * Save a copy of 'obj' in the TSD. If the TSD already holds an old object,
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb * delete it before saving the new one.
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb * On successful exit, '*storedP' indicates whether or not the entry was
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb * stored, and hence whether or not we're perfroming a modify operation.
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb * Return 1 if successful, 0 otherwise.
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb return (0);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb if (eObj != 0) {
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States tsd->oldObj = 0;
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States }
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb if (obj != 0) {
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb return (0);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb return (1);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb * Retrieve (and remove) the old object (if any) from the TSD. Returns 1
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb * if successful ('*oldObjP' might be NULL), 0 otherwise ('*oldObjP'
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb * unchanged).
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb return (0);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb return (1);