/****************************************************************************** * * Deadlock Manager support * * Module %M% Version %I% Date %H% * * (c) Copyright 1998 Ardent Software Inc. - All Rights Reserved * This is unpublished proprietary source code of Ardent Software Inc. * The copyright notice above does not evidence any actual or intended * publication of such source code. * ******************************************************************************* * * Maintenence log - insert most recent change descriptions at top * * Date.... GTAR# WHO Description......................................... * 10/14/98 23801 SAP Change copyrights. * 10/02/98 23765 CSM Implement device licensing * 10/01/98 23316 RJE Added include tokens for daemon initialization. * 12/15/97 21984 DTM Changes to provide more complete dead process cleanup * 09/03/96 18133 PEJ Removed spurious #endif * 08/29/96 18133 NDP Corrected previous changes * 08/28/96 18133 SAP Port 9 to HP-UX 10 * 06/24/96 18650 GMM Split config tokens into LK_readcnf.c * 06/18/96 18650 GMM Ported to NT * 05/31/96 14803 DTM Initial creation ******************************************************************************/ EXTERN struct DBsegment *DBshmseg; EXTERN DBDADDR NET_signature; EXTERN char *_ULOKPTR; /* system group lock table address */ EXTERN int _USMFTAB; /* system file lock semaphore table id */ EXTERN uint *_USEMPTR; EXTERN char *_ULFKPTR; /* system file lock table address */ EXTERN char *_ULOWNPTR; /* address of readl owner's table */ EXTERN char *_ULWAITPTR; /* address of readl owner's table */ EXTERN int _ULOWNOFF; /* size of each table */ EXTERN int _ULWAITOFF; /* size of each table */ EXTERN char *_FSOWNPTR; EXTERN char *_FSWAITPTR; EXTERN int _FSOWNOFF; EXTERN int _FSWAITOFF; EXTERN char scratch_buf[]; #define EXEC_STRING "uvdlockd" #define ERR_LOG "/uvdlockd.log" #define SLEEP_INT 60 #define SLEEP_MINIMUM 15 #define UVDLOCKD_PID DBshmseg->uvdlockd_pid #define PSHM_DLBIT Pshmseg->control.deadlocked #define IS_LICENSED Ushmseg->control.login_seat #define NORMAL_SHUTDOWN 0 /* Normal shutdown */ #define SUPERUSER_ERROR 1 /* Not superuser */ #define FORK_ERROR 2 /* Cannot fork child */ #define LAYER_ERROR 3 /* Cannot get layer */ #define LOG_OPEN_ERROR 4 /* Cannot open log file */ #define BAD_SIG_ERROR 5 /* Bad Signal caught */ #define SIG2_ERROR 6 /* SigUser2 caught */ #define DAEMON_EXISTS_ERROR 7 /* daemon already exists */ #define USER_SHUTDOWN 8 /* User shutdown */ #define ADM_SHUTDOWN 9 /* User shutdown - manual victim select */ #define GETUVHOME_ERROR 10 /* Cannot get uvhome */ #define CHDIR_ERROR 11 /* Cannot change to uvhome */ #define NO_EVENT_ERROR 12 /* Cannot create NT sleep event */ #define NO_SIGNAL_ERROR 13 /* Cannot initialize NT signals */ #define NO_PROCESS_ERROR 14 /* Cannot initialize NT process table */ #define LK_GENMSG(xxxx) ( ( (xxxx) > Dlmmax ) ?\ ( sprintf(Dldefmsg,"Message[DLM%04d]\n",(xxxx)), Dldefmsg ) :\ ( Dlmmsg[(xxxx-1)] != 0 ?\ Dlmmsg[(xxxx-1)] :\ ( sprintf(Dldefmsg,"Message[DLM%04d]\n",(xxxx)),\ Dldefmsg ))) EXTERN int Dlmmax; EXTERN char **Dlmmsg; EXTERN char Dldefmsg[]; #define NO_SUPERUSER_MSG LK_GENMSG(1) #define NO_FORK_MSG LK_GENMSG(2) #define LAYER_ERROR_MSG LK_GENMSG(3) #define LOG_OPEN_MSG LK_GENMSG(4) #define BAD_SIG_MSG LK_GENMSG(5) #define DAEMON_STARTED_MSG LK_GENMSG(6) #define NORMAL_SHUTDOWN_MSG LK_GENMSG(7) #define BEG_DEAD_PROCESS LK_GENMSG(8) #define END_DEAD_PROCESS LK_GENMSG(9) #define BEG_DEADLOCK LK_GENMSG(10) #define END_DEADLOCK LK_GENMSG(11) #define NO_ATTACH_SHM LK_GENMSG(12) #define NO_REMOVE_SHM LK_GENMSG(13) #define REMOVE_SHM_SIG LK_GENMSG(14) #define REMOVE_READU LK_GENMSG(15) #define USR_REQUEST_STOP LK_GENMSG(16) #define DAEMON_EXISTS_MSG LK_GENMSG(18) #define MANUAL_VICTIM_SELECTED LK_GENMSG(19) #define CMD_LINE_OPTIONS LK_GENMSG(20) #define NO_DAEMON_MSG LK_GENMSG(21) #define CONFIG_OPEN_MSG LK_GENMSG(22) #define INVALID_OPTION LK_GENMSG(23) #define INVALID_USE LK_GENMSG(24) #define OPTION_HEADER LK_GENMSG(25) #define OPTION_LINE LK_GENMSG(26) #define OPTION_TIMER LK_GENMSG(27) #define OPTION_RES LK_GENMSG(28) #define OPTION_LOG LK_GENMSG(29) #define OPTION_QUERY LK_GENMSG(30) #define OPTION_VICTIM LK_GENMSG(31) #define OPTION_STOP LK_GENMSG(32) #define OPTION_NOTE LK_GENMSG(33) #define NOTIFY_VICTIM_MSG LK_GENMSG(34) #define NOTIFY_SYSADM_RES LK_GENMSG(35) #define DEADLOCK_MSG LK_GENMSG(36) #define FEWEST_LOCKS_MSG LK_GENMSG(37) #define FEWEST_LOCKS_SIG LK_GENMSG(38) #define YOUNGEST_PROC_MSG LK_GENMSG(39) #define YOUNGEST_PROC_SIG LK_GENMSG(40) #define WALK_DEBUG_MSG LK_GENMSG(41) #define DEADLOCK_FOUND_MSG LK_GENMSG(42) #define NO_DEADLOCK_FOUND_MSG LK_GENMSG(43) #define DEADLOCK_CYCLE_MSG LK_GENMSG(44) #define USER_WAITING_MSG LK_GENMSG(45) #define USER_MSG LK_GENMSG(46) #define WHO_WAITING_MSG LK_GENMSG(47) #define PRINTOUT_MSG LK_GENMSG(48) #define CONTENTS_MSG LK_GENMSG(49) #define DIAG_MSG LK_GENMSG(50) #define NO_GETUVHOME_MSG LK_GENMSG(51) #define NO_CHDIR_MSG LK_GENMSG(52) #define REMOVE_GROUP LK_GENMSG(53) #define REMOVE_FILE LK_GENMSG(54) #define RES_ERR_MSG LK_GENMSG(55) #define TIMER_ERR_MSG LK_GENMSG(56) #define NO_EVENT_MSG LK_GENMSG(57) #define LK_CLEANUP_MSG1 LK_GENMSG(58) #define LK_CLEANUP_MSG2 LK_GENMSG(59) #define LK_CLEANUP_MSG3 LK_GENMSG(60) #define LK_CLEANUP_MSG4 LK_GENMSG(61) #define FIX_LOGIN_CNT_MSG LK_GENMSG(62) #define LK_CLEANUP_FSEM LK_GENMSG(63) #define LK_CLEANUP_GSEM LK_GENMSG(64) #define LK_CLEANUP_LSEM LK_GENMSG(65) #define LK_CLEANUP_PSEM LK_GENMSG(66) #define LK_CLEANUP_T30SEM LK_GENMSG(67) #define LK_CLEANUP_TLOGSEM LK_GENMSG(68) #define LK_CLEANUP_TXSEM LK_GENMSG(69) #define LK_CLEANUP_UDRSHMSEM LK_GENMSG(70) #define LK_CLEANUP_UDRLG0SEM LK_GENMSG(71) #define LK_CLEANUP_UDRLG1SEM LK_GENMSG(72) #define OPTION_DEAD_PROC LK_GENMSG(73) #define NO_SIGNAL_MSG LK_GENMSG(74) #define NO_PROCESS_MSG LK_GENMSG(75) #define DL_FSEMP 0x01 #define DL_GSEMP 0x02 #define DL_FLOCK 0x04 #define DL_GLOCK 0x08 #define DL_RLOCK 0x10 #define DL_LSEMP 0x20 #define DL_PSEMP 0x40 #define DL_TSEMP 0x80 #define DL_TLSEMP 0x100 #define DL_USEMP1 0x200 #define DL_USEMP2 0x400 #define DL_USEMP3 0x800 #define DL_TXSEMP 0x1000 #define RES_RAND 0 /* Random Resolution */ #define RES_OLD 1 /* Oldest transaction */ #define RES_LOCK 2 /* fewest locks */ #define RES_SYSADM 3 /* System Administrator */ #define RES_SPECIAL 4 /* notify victim */ #define DEADLOCK 2 /* Deadlock State */ #define NO_DEADLOCK 0 /* Not in deadlock */ /* Primary WFG structure */ struct wfg_elem { struct wfg_elem *nextp, *previous; int signature; pid_t pid; WAITERS *waitnode; struct wfg_elem *waiting_for; int someone_waiting; int visited; int passed; }; typedef struct wfg_elem WFG; /* Dead process data strcuture */ struct dead_process{ int lock_pid; int lock_type; int lock_sig; struct dead_process *previous; struct dead_process *next; }; typedef struct dead_process LKlist; /* External Function Declaration Section */ EXTERN int DBlist_find(), DBlist_delete(), DBlist_drop(), DBlist_first(), DBlist_next(); EXTERN int sigtopid(); /* External Functions Declaration Section for Deadlock Mgr specific code */ EXTERN void LK_cleanup(), /* LK_clean.c */ LK_get_bad_pshmsegs(), /* LK_clean.c */ LK_get_semaphore_list(), /* LK_clean.c */ LK_get_pid_list(), /* LK_clean.c */ LK_add_dl_list(), /* LK_list.c */ LK_delete_dl_list(), /* LK_list.c */ LK_shutdown_daemon(), /* LK_main.c */ LK_log_message(), /* LK_misc.c */ LK_print_options(), /* LK_misc.c */ LK_debug_print(), /* LK_misc.c */ LK_notify_victim(), /* LK_misc.c */ LK_init_daemon(), /* LK_os.c */ LK_cleanup_wfg(), /* LK_wfg.c */ LK_build_wfg(); /* LK_wfg.c */ EXTERN int LK_read_config(), /* LK_readcnf.c */ LK_init_wfg(), /* LK_wfg.c */ LK_walk_wfg(); /* LK_wfg.c */ #if COMPUTER != HP & COMPUTER != WINNT EXTERN mode_t umask(); #endif #ifndef MSWIN EXTERN int atoi(), kill(); EXTERN uid_t getuid(); EXTERN pid_t fork(), setsid(); EXTERN char *strchr(); #endif