xref: /onnv-gate/usr/src/lib/libnisdb/yptol/lock_update.c (revision 4574:4e479ec6ce6f)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*4574Sraf  * Common Development and Distribution License (the "License").
6*4574Sraf  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
21*4574Sraf 
220Sstevel@tonic-gate /*
23*4574Sraf  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
240Sstevel@tonic-gate  * Use is subject to license terms.
250Sstevel@tonic-gate  */
260Sstevel@tonic-gate 
270Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
280Sstevel@tonic-gate 
290Sstevel@tonic-gate /*
300Sstevel@tonic-gate  * DESCRIPTION: Contains code supporting the 'update in progress' flag. This is
310Sstevel@tonic-gate  *		a near copy of lock flag code (in
320Sstevel@tonic-gate  *		usr/src/cmd/ypcmd/shared/lockmp.c) If we implement a clean
330Sstevel@tonic-gate  *		version	of the locking code this file will probably disappear.
340Sstevel@tonic-gate  *
350Sstevel@tonic-gate  *		These locks are held while a map is being updated from the
360Sstevel@tonic-gate  *		DIT. They prevent a second update being started while this is
370Sstevel@tonic-gate  *		in progress. This is independant from the `lockmap` mechanism
380Sstevel@tonic-gate  *		which protects maps, generally for a much shorter period,
390Sstevel@tonic-gate  *		while their control structures are modified.
400Sstevel@tonic-gate  */
410Sstevel@tonic-gate 
420Sstevel@tonic-gate #include <unistd.h>
430Sstevel@tonic-gate #include <syslog.h>
440Sstevel@tonic-gate #include <sys/mman.h>
450Sstevel@tonic-gate #include <thread.h>
460Sstevel@tonic-gate #include <synch.h>
470Sstevel@tonic-gate #include <ndbm.h>
480Sstevel@tonic-gate #include <strings.h>
490Sstevel@tonic-gate #include "ypsym.h"
500Sstevel@tonic-gate #include "shim.h"
510Sstevel@tonic-gate #include "yptol.h"
520Sstevel@tonic-gate #include "../ldap_util.h"
530Sstevel@tonic-gate 
540Sstevel@tonic-gate #define	LOCKFILE "/var/run/yp_mapupdate"
550Sstevel@tonic-gate struct updatearray {
560Sstevel@tonic-gate 	mutex_t		updatenode[MAXHASH];
570Sstevel@tonic-gate };
580Sstevel@tonic-gate typedef struct updatearray updatearray;
590Sstevel@tonic-gate 
600Sstevel@tonic-gate /*
610Sstevel@tonic-gate  * Cross-process robust mutex locks.
620Sstevel@tonic-gate  * Provide synchronization between YP processes
630Sstevel@tonic-gate  * by implementing an exclusive locking mechanism
640Sstevel@tonic-gate  * via a memory-mapped file.
650Sstevel@tonic-gate  */
660Sstevel@tonic-gate static struct updatearray	*shmupdatearray;
670Sstevel@tonic-gate static int	lockfile;
680Sstevel@tonic-gate 
690Sstevel@tonic-gate bool_t
init_update_locks_mem()700Sstevel@tonic-gate init_update_locks_mem()
710Sstevel@tonic-gate {
720Sstevel@tonic-gate 	int iiter, rc;
730Sstevel@tonic-gate 	int ebusy_cnt = 0;
740Sstevel@tonic-gate 
750Sstevel@tonic-gate 	/*
760Sstevel@tonic-gate 	 * Initialize cross-process locks in memory-mapped file.
770Sstevel@tonic-gate 	 */
780Sstevel@tonic-gate 	for (iiter = 0; iiter < MAXHASH; iiter++) {
790Sstevel@tonic-gate 		if (rc = mutex_init(&(shmupdatearray->updatenode[iiter]),
80*4574Sraf 		    USYNC_PROCESS | LOCK_ROBUST, 0)) {
810Sstevel@tonic-gate 			if (rc == EBUSY) {
820Sstevel@tonic-gate 				ebusy_cnt++;
830Sstevel@tonic-gate 			} else {
840Sstevel@tonic-gate 				logmsg(MSG_NOTIMECHECK, LOG_ERR,
850Sstevel@tonic-gate 					"init_update_locks_mem():mutex_init():"
860Sstevel@tonic-gate 					"error=%d", rc);
870Sstevel@tonic-gate 				return (FALSE);
880Sstevel@tonic-gate 			}
890Sstevel@tonic-gate 		}
900Sstevel@tonic-gate 	}
910Sstevel@tonic-gate 
920Sstevel@tonic-gate 	/*
930Sstevel@tonic-gate 	 * EBUSY for all locks OK, it means another process
940Sstevel@tonic-gate 	 * has already initialized locks.
950Sstevel@tonic-gate 	 */
960Sstevel@tonic-gate 	if ((ebusy_cnt > 0) && (ebusy_cnt != MAXHASH)) {
970Sstevel@tonic-gate 		logmsg(MSG_NOTIMECHECK, LOG_ERR,
980Sstevel@tonic-gate 		"%s inconsistent. Remove this file and restart NIS (YP)",
990Sstevel@tonic-gate 								LOCKFILE);
1000Sstevel@tonic-gate 		return (FALSE);
1010Sstevel@tonic-gate 	}
1020Sstevel@tonic-gate 	return (TRUE);
1030Sstevel@tonic-gate }
1040Sstevel@tonic-gate 
1050Sstevel@tonic-gate bool_t
init_update_lock_map()1060Sstevel@tonic-gate init_update_lock_map()
1070Sstevel@tonic-gate {
1080Sstevel@tonic-gate 	char buff[ sizeof (updatearray) ];
1090Sstevel@tonic-gate 	int write_cnt, lf_size;
1100Sstevel@tonic-gate 	struct stat fdata;
1110Sstevel@tonic-gate 
1120Sstevel@tonic-gate 	/*
1130Sstevel@tonic-gate 	 * Locking file initialization algorithm, with recovery mechanism.
1140Sstevel@tonic-gate 	 * This mechanism has been devised to ensure proper creation
1150Sstevel@tonic-gate 	 * of a memory-mapped lock file containing mutexes for robust,
1160Sstevel@tonic-gate 	 * inter-process communication.
1170Sstevel@tonic-gate 	 * File name is /var/run/yp_mapupate (LOCKFILE).  It might or might
1180Sstevel@tonic-gate 	 * not exist.
1190Sstevel@tonic-gate 	 *
1200Sstevel@tonic-gate 	 * Algorithm:
1210Sstevel@tonic-gate 	 * Try to open the file. If file doesn't exist, or size is too small,
1220Sstevel@tonic-gate 	 * create/rewrite the file, m-map it into memory and initialize the
1230Sstevel@tonic-gate 	 * mutexes in it.
1240Sstevel@tonic-gate 	 * If file exists and size is at least large enough, assume it's a
1250Sstevel@tonic-gate 	 * good file, and m-map the lock structure directly to it.
1260Sstevel@tonic-gate 	 *
1270Sstevel@tonic-gate 	 * Recovery from inconsistent state is easy - simply delete the file
1280Sstevel@tonic-gate 	 * and restart NIS (YP).
1290Sstevel@tonic-gate 	 */
1300Sstevel@tonic-gate 
1310Sstevel@tonic-gate 	lockfile = open(LOCKFILE, O_RDWR|O_CREAT, 0600);
1320Sstevel@tonic-gate 	if (lockfile != -1) {
1330Sstevel@tonic-gate 		if (lockf(lockfile, F_LOCK, 0) == 0) {
1340Sstevel@tonic-gate 			if (fstat(lockfile, &fdata) == 0) {
1350Sstevel@tonic-gate 				lf_size = fdata.st_size;
1360Sstevel@tonic-gate 				if (lf_size < sizeof (updatearray)) {
1370Sstevel@tonic-gate 					bzero(buff, sizeof (buff));
1380Sstevel@tonic-gate 					if ((write_cnt = write(lockfile, buff,
1390Sstevel@tonic-gate 					    sizeof (buff)) != sizeof (buff))) {
1400Sstevel@tonic-gate 						if (write_cnt < 0) {
1410Sstevel@tonic-gate 							logmsg(MSG_NOTIMECHECK,
1420Sstevel@tonic-gate 								LOG_ERR,
1430Sstevel@tonic-gate 						"write(%s) => errno=%d",
1440Sstevel@tonic-gate 							    LOCKFILE, errno);
1450Sstevel@tonic-gate 						} else {
1460Sstevel@tonic-gate 							logmsg(MSG_NOTIMECHECK,
1470Sstevel@tonic-gate 								LOG_ERR,
1480Sstevel@tonic-gate 		    "write(%s) => %d!=%d: wrong number of bytes written",
1490Sstevel@tonic-gate 							    LOCKFILE,
1500Sstevel@tonic-gate 							    write_cnt,
1510Sstevel@tonic-gate 							    sizeof (buff));
1520Sstevel@tonic-gate 						}
1530Sstevel@tonic-gate 						lockf(lockfile, F_ULOCK, 0);
1540Sstevel@tonic-gate 						close(lockfile);
1550Sstevel@tonic-gate 						return (FALSE);
1560Sstevel@tonic-gate 					}
1570Sstevel@tonic-gate 				}
1580Sstevel@tonic-gate 			} else {
1590Sstevel@tonic-gate 				logmsg(MSG_NOTIMECHECK, LOG_ERR,
1600Sstevel@tonic-gate 				    "fstat(%s) => errno=%d", LOCKFILE, errno);
1610Sstevel@tonic-gate 				lockf(lockfile, F_ULOCK, 0);
1620Sstevel@tonic-gate 				close(lockfile);
1630Sstevel@tonic-gate 				return (FALSE);
1640Sstevel@tonic-gate 			}
1650Sstevel@tonic-gate 		} else {
1660Sstevel@tonic-gate 			logmsg(MSG_NOTIMECHECK, LOG_ERR,
1670Sstevel@tonic-gate 			    "lockf(%s,F_LOCK) => errno=%d", LOCKFILE, errno);
1680Sstevel@tonic-gate 			close(lockfile);
1690Sstevel@tonic-gate 			return (FALSE);
1700Sstevel@tonic-gate 		}
1710Sstevel@tonic-gate 	} else {
1720Sstevel@tonic-gate 		logmsg(MSG_NOTIMECHECK, LOG_ERR,
1730Sstevel@tonic-gate 			"open(%s) => errno=%d", LOCKFILE, errno);
1740Sstevel@tonic-gate 		return (FALSE);
1750Sstevel@tonic-gate 	}
1760Sstevel@tonic-gate 
1770Sstevel@tonic-gate 	/*
1780Sstevel@tonic-gate 	 * File exists with correct size, is open, and we're holding
1790Sstevel@tonic-gate 	 * the file lock.
1800Sstevel@tonic-gate 	 */
1810Sstevel@tonic-gate 	shmupdatearray = (updatearray *)mmap((caddr_t)0, sizeof (updatearray),
1820Sstevel@tonic-gate 	    PROT_READ | PROT_WRITE, MAP_SHARED, lockfile, 0);
1830Sstevel@tonic-gate 	if (shmupdatearray == MAP_FAILED) {
1840Sstevel@tonic-gate 		logmsg(MSG_NOTIMECHECK, LOG_ERR,
1850Sstevel@tonic-gate 				"mmap(%s) => errno=%d", LOCKFILE, errno);
1860Sstevel@tonic-gate 		lockf(lockfile, F_ULOCK, 0);
1870Sstevel@tonic-gate 		close(lockfile);
1880Sstevel@tonic-gate 		return (FALSE);
1890Sstevel@tonic-gate 	}
1900Sstevel@tonic-gate 
1910Sstevel@tonic-gate 	/*
1920Sstevel@tonic-gate 	 * If we wrote zeroes to the file, we also need to initialize
1930Sstevel@tonic-gate 	 * the mutex locks.
1940Sstevel@tonic-gate 	 */
1950Sstevel@tonic-gate 	if (lf_size < sizeof (updatearray)) {
1960Sstevel@tonic-gate 		if (init_update_locks_mem() == FALSE) {
1970Sstevel@tonic-gate 			lockf(lockfile, F_ULOCK, 0);
1980Sstevel@tonic-gate 			close(lockfile);
1990Sstevel@tonic-gate 			if (remove(LOCKFILE) != 0) {
2000Sstevel@tonic-gate 				logmsg(MSG_NOTIMECHECK, LOG_ERR,
2010Sstevel@tonic-gate 				"remove(%s) => errno=%d: Please delete file",
2020Sstevel@tonic-gate 							LOCKFILE, errno);
2030Sstevel@tonic-gate 			}
2040Sstevel@tonic-gate 			return (FALSE);
2050Sstevel@tonic-gate 		}
2060Sstevel@tonic-gate 	}
2070Sstevel@tonic-gate 
2080Sstevel@tonic-gate 	if (lockf(lockfile, F_ULOCK, 0) != 0) {
2090Sstevel@tonic-gate 		logmsg(MSG_NOTIMECHECK, LOG_ERR,
2100Sstevel@tonic-gate 			"lockf(%s,F_ULOCK) => errno=%d", LOCKFILE, errno);
2110Sstevel@tonic-gate 		close(lockfile);
2120Sstevel@tonic-gate 		return (FALSE);
2130Sstevel@tonic-gate 	}
2140Sstevel@tonic-gate 
2150Sstevel@tonic-gate 	if (close(lockfile) == 0) {
2160Sstevel@tonic-gate 		return (TRUE);
2170Sstevel@tonic-gate 	} else {
2180Sstevel@tonic-gate 		logmsg(MSG_NOTIMECHECK, LOG_ERR,
2190Sstevel@tonic-gate 				"close(%s) => errno=%d", LOCKFILE, errno);
2200Sstevel@tonic-gate 		return (FALSE);
2210Sstevel@tonic-gate 	}
2220Sstevel@tonic-gate }
2230Sstevel@tonic-gate 
2240Sstevel@tonic-gate suc_code
lock_map_update(map_ctrl * map)2250Sstevel@tonic-gate lock_map_update(map_ctrl *map)
2260Sstevel@tonic-gate {
2270Sstevel@tonic-gate 	int hashval = map->hash_val;
2280Sstevel@tonic-gate 	int rc;
2290Sstevel@tonic-gate 
2300Sstevel@tonic-gate 	/*
2310Sstevel@tonic-gate 	 * Robust, cross-process lock implementation
2320Sstevel@tonic-gate 	 */
2330Sstevel@tonic-gate 	rc = mutex_lock(&(shmupdatearray->updatenode[hashval]));
2340Sstevel@tonic-gate 	while (rc != 0) {
2350Sstevel@tonic-gate 		switch (rc) {
2360Sstevel@tonic-gate 		case EOWNERDEAD:
2370Sstevel@tonic-gate 			/*
2380Sstevel@tonic-gate 			 * Previous lock owner died, resetting lock
2390Sstevel@tonic-gate 			 * to recover from error.
2400Sstevel@tonic-gate 			 */
241*4574Sraf 			rc = mutex_consistent(
242*4574Sraf 			    &(shmupdatearray->updatenode[hashval]));
2430Sstevel@tonic-gate 			if (rc != 0) {
2440Sstevel@tonic-gate 				logmsg(MSG_NOTIMECHECK, LOG_ERR,
245*4574Sraf 					"mutex_consistent(): error=%d", rc);
2460Sstevel@tonic-gate 				return (FAILURE);
2470Sstevel@tonic-gate 			}
2480Sstevel@tonic-gate 			rc = mutex_unlock(
249*4574Sraf 			    &(shmupdatearray->updatenode[hashval]));
2500Sstevel@tonic-gate 			if (rc != 0) {
2510Sstevel@tonic-gate 				logmsg(MSG_NOTIMECHECK, LOG_ERR,
252*4574Sraf 					"mutex_unlock(): error=%d", rc);
2530Sstevel@tonic-gate 				return (FAILURE);
2540Sstevel@tonic-gate 			}
2550Sstevel@tonic-gate 			break;
2560Sstevel@tonic-gate 		default:
2570Sstevel@tonic-gate 			/*
2580Sstevel@tonic-gate 			 * Unrecoverable problem - nothing to do
2590Sstevel@tonic-gate 			 * but exit YP and delete lock file.
2600Sstevel@tonic-gate 			 */
2610Sstevel@tonic-gate 			logmsg(MSG_NOTIMECHECK, LOG_ERR,
2620Sstevel@tonic-gate 						"mutex_lock(): error=%d", rc);
2630Sstevel@tonic-gate 			logmsg(MSG_NOTIMECHECK, LOG_ERR,
2640Sstevel@tonic-gate 					"Please restart NIS (ypstop/ypstart)");
2650Sstevel@tonic-gate 			if (remove(LOCKFILE) != 0) {
2660Sstevel@tonic-gate 				logmsg(MSG_NOTIMECHECK, LOG_ERR,
2670Sstevel@tonic-gate 				"remove(%s) => errno=%d: Please delete file",
2680Sstevel@tonic-gate 							LOCKFILE, errno);
2690Sstevel@tonic-gate 			}
2700Sstevel@tonic-gate 			return (FAILURE);
2710Sstevel@tonic-gate 		}
2720Sstevel@tonic-gate 		rc = mutex_lock(&(shmupdatearray->updatenode[hashval]));
2730Sstevel@tonic-gate 	}
2740Sstevel@tonic-gate 
2750Sstevel@tonic-gate 	/* Success */
2760Sstevel@tonic-gate 	return (SUCCESS);
2770Sstevel@tonic-gate }
2780Sstevel@tonic-gate 
2790Sstevel@tonic-gate 
2800Sstevel@tonic-gate suc_code
unlock_map_update(map_ctrl * map)2810Sstevel@tonic-gate unlock_map_update(map_ctrl *map)
2820Sstevel@tonic-gate {
2830Sstevel@tonic-gate 	int hashval = map->hash_val;
2840Sstevel@tonic-gate 	int rc;
2850Sstevel@tonic-gate 
2860Sstevel@tonic-gate 	rc = mutex_unlock(&(shmupdatearray->updatenode[hashval]));
2870Sstevel@tonic-gate 	if (rc != 0) {
2880Sstevel@tonic-gate 		logmsg(MSG_NOTIMECHECK, LOG_ERR,
2890Sstevel@tonic-gate 						"mutex_unlock(): error=%d", rc);
2900Sstevel@tonic-gate 		logmsg(MSG_NOTIMECHECK, LOG_ERR,
2910Sstevel@tonic-gate 					"Please restart NIS (ypstop/ypstart)");
2920Sstevel@tonic-gate 		if (remove(LOCKFILE) != 0) {
2930Sstevel@tonic-gate 			logmsg(MSG_NOTIMECHECK, LOG_ERR,
2940Sstevel@tonic-gate 			    "remove(%s) => errno=%d: Please delete file",
2950Sstevel@tonic-gate 			    LOCKFILE, errno);
2960Sstevel@tonic-gate 		}
2970Sstevel@tonic-gate 		return (FAILURE);
2980Sstevel@tonic-gate 	}
2990Sstevel@tonic-gate 
3000Sstevel@tonic-gate 	/* Success */
3010Sstevel@tonic-gate 	return (SUCCESS);
3020Sstevel@tonic-gate }
3030Sstevel@tonic-gate 
3040Sstevel@tonic-gate /*
3050Sstevel@tonic-gate  * FUNCTION :   is_map_updating()
3060Sstevel@tonic-gate  *
3070Sstevel@tonic-gate  * DESCRIPTION: Determines if a map is currently locked for update
3080Sstevel@tonic-gate  *
3090Sstevel@tonic-gate  * GIVEN :      Pointer to map_ctrl structure
3100Sstevel@tonic-gate  *
3110Sstevel@tonic-gate  * RETURNS :    TRUE = Map is locked
3120Sstevel@tonic-gate  *              FALSE = Map is not locked
3130Sstevel@tonic-gate  */
3140Sstevel@tonic-gate bool_t
is_map_updating(map_ctrl * map)3150Sstevel@tonic-gate is_map_updating(map_ctrl *map)
3160Sstevel@tonic-gate {
3170Sstevel@tonic-gate 	int ret;
3180Sstevel@tonic-gate 
3190Sstevel@tonic-gate 	/* It appears not to be possible to just read a mutex. Try to lock it */
3200Sstevel@tonic-gate 	ret = mutex_trylock(&(shmupdatearray->updatenode[map->hash_val]));
3210Sstevel@tonic-gate 
3220Sstevel@tonic-gate 	if (0 != ret) {
3230Sstevel@tonic-gate 		/* Didn't get the lock ... was already locked */
3240Sstevel@tonic-gate 		return (TRUE);
3250Sstevel@tonic-gate 	}
3260Sstevel@tonic-gate 
3270Sstevel@tonic-gate 	/* Didn't need the lock so free it again */
3280Sstevel@tonic-gate 	mutex_unlock(&(shmupdatearray->updatenode[map->hash_val]));
3290Sstevel@tonic-gate 	return (FALSE);
3300Sstevel@tonic-gate }
3310Sstevel@tonic-gate 
3320Sstevel@tonic-gate /*
3330Sstevel@tonic-gate  * FUNCTION :	try_lock_map_update()
3340Sstevel@tonic-gate  *
3350Sstevel@tonic-gate  * DESCRIPTION: Tries to to lock a map for update.
3360Sstevel@tonic-gate  *
3370Sstevel@tonic-gate  * GIVEN :	Pointer to the map to lock
3380Sstevel@tonic-gate  *
3390Sstevel@tonic-gate  * RETURNS :	0 = The map is now locked
3400Sstevel@tonic-gate  *		EBUSY = The map was already locked lock not obtained.
3410Sstevel@tonic-gate  *		Other = There was an error
3420Sstevel@tonic-gate  */
3430Sstevel@tonic-gate int
try_lock_map_update(map_ctrl * map)3440Sstevel@tonic-gate try_lock_map_update(map_ctrl *map)
3450Sstevel@tonic-gate {
3460Sstevel@tonic-gate 	int hashval = map->hash_val;
3470Sstevel@tonic-gate 	int rc;
3480Sstevel@tonic-gate 
3490Sstevel@tonic-gate 	/*
3500Sstevel@tonic-gate 	 * Robust, cross-process lock implementation
3510Sstevel@tonic-gate 	 *
3520Sstevel@tonic-gate 	 * Keep trying until either lock is obtained or somebody else gets it.
3530Sstevel@tonic-gate 	 */
3540Sstevel@tonic-gate 	while (1) {
3550Sstevel@tonic-gate 		rc = mutex_trylock(&(shmupdatearray->updatenode[hashval]));
3560Sstevel@tonic-gate 
3570Sstevel@tonic-gate 		switch (rc) {
3580Sstevel@tonic-gate 
3590Sstevel@tonic-gate 		case 0:
3600Sstevel@tonic-gate 		case EBUSY:
3610Sstevel@tonic-gate 			/* Either got it or somebody else has it */
3620Sstevel@tonic-gate 			return (rc);
3630Sstevel@tonic-gate 
3640Sstevel@tonic-gate 		case EOWNERDEAD:
3650Sstevel@tonic-gate 			/*
3660Sstevel@tonic-gate 			 * Previous lock owner died, resetting lock
3670Sstevel@tonic-gate 			 * to recover from error.
3680Sstevel@tonic-gate 			 */
369*4574Sraf 			rc = mutex_consistent(
370*4574Sraf 			    &(shmupdatearray->updatenode[hashval]));
3710Sstevel@tonic-gate 			if (rc != 0) {
3720Sstevel@tonic-gate 				logmsg(MSG_NOTIMECHECK, LOG_ERR,
373*4574Sraf 					"mutex_consistent(): error=%d", rc);
3740Sstevel@tonic-gate 				return (rc);
3750Sstevel@tonic-gate 			}
3760Sstevel@tonic-gate 			rc = mutex_unlock(
377*4574Sraf 			    &(shmupdatearray->updatenode[hashval]));
3780Sstevel@tonic-gate 			if (rc != 0) {
3790Sstevel@tonic-gate 				logmsg(MSG_NOTIMECHECK, LOG_ERR,
380*4574Sraf 					"mutex_unlock(): error=%d", rc);
3810Sstevel@tonic-gate 				return (rc);
3820Sstevel@tonic-gate 			}
3830Sstevel@tonic-gate 			break;
3840Sstevel@tonic-gate 		default:
3850Sstevel@tonic-gate 			/*
3860Sstevel@tonic-gate 			 * Unrecoverable problem - nothing to do
3870Sstevel@tonic-gate 			 * but exit YP and delete lock file.
3880Sstevel@tonic-gate 			 */
3890Sstevel@tonic-gate 			logmsg(MSG_NOTIMECHECK, LOG_ERR,
3900Sstevel@tonic-gate 						"mutex_lock(): error=%d", rc);
3910Sstevel@tonic-gate 			logmsg(MSG_NOTIMECHECK, LOG_ERR,
3920Sstevel@tonic-gate 					"Please restart NIS (ypstop/ypstart)");
3930Sstevel@tonic-gate 			if (remove(LOCKFILE) != 0) {
3940Sstevel@tonic-gate 				logmsg(MSG_NOTIMECHECK, LOG_ERR,
3950Sstevel@tonic-gate 				"remove(%s) => errno=%d: Please delete file",
3960Sstevel@tonic-gate 							LOCKFILE, errno);
3970Sstevel@tonic-gate 			}
3980Sstevel@tonic-gate 			return (rc);
3990Sstevel@tonic-gate 		}
4000Sstevel@tonic-gate 	}
4010Sstevel@tonic-gate }
402