diff --git a/src/lock/fparamv3.h b/src/lock/fparamv3.h deleted file mode 100644 index 4698bdec7d..0000000000 --- a/src/lock/fparamv3.h +++ /dev/null @@ -1,82 +0,0 @@ -/* - * PROGRAM: Lock manager - * MODULE: fparamv3.h - * DESCRIPTION: Version 3 file parameter definitions - * - * The contents of this file are subject to the Interbase Public - * License Version 1.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy - * of the License at http://www.Inprise.com/IPL.html - * - * Software distributed under the License is distributed on an - * "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express - * or implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code was created by Inprise Corporation - * and its predecessors. Portions created by Inprise Corporation are - * Copyright (C) Inprise Corporation. - * - * All Rights Reserved. - * Contributor(s): ______________________________________. - * - * 2002.10.30 Sean Leyne - Code Cleanup, removed obsolete "SUN3_3" port - * - */ - -#ifdef NOHOSTNAME -#define LOCK_FILE FB_PREFIX "/isc_lock.gbl" -#define EVENT_FILE FB_PREFIX "/isc_event.gbl" -#else -#ifdef SMALL_FILE_NAMES -#define LOCK_FILE FB_PREFIX "/isclm.%s" -#define EVENT_FILE FB_PREFIX "/iscev.%s" -#endif -#endif - -#ifdef VMS -#define EVENT_FILE "[000000]isc_event.%s" -#endif - -#ifndef EVENT_FILE -#define EVENT_FILE FB_PREFIX "/isc_event.gbl.%s" -#endif - -#define EVENT_DEFAULT_SIZE 32768 -#define EVENT_EXTEND_SIZE 32768 -#define EVENT_VERSION 1 -#define EVENT_SEMAPHORES 1 - -#ifndef LOCK_FILE -#define LOCK_FILE FB_PREFIX "/gds.lock.%s" -#endif - -#ifndef LOCK_HEADER -#define LOCK_HEADER FB_PREFIX "/lock_header" -#endif - -#ifdef sun -#include -#include -#define SUNOS4 -#ifndef i386 -#define CSV -#endif -#endif - -#if (defined linux || defined FREEBSD || defined NETBSD) -#include -#include -#ifndef i386 -#define CSV -#endif -#endif - - -#ifdef CSV -/* Central server definitions taken from source/csv/csi.h */ - -#define CSI_FILE FB_PREFIX "/isc_csv.%s" -#define CSI_DEFAULT_SIZE 262144 -#define MAX_PROCESSES 16 -#endif diff --git a/src/lock/lockv3.h b/src/lock/lockv3.h deleted file mode 100644 index fc279f8dc6..0000000000 --- a/src/lock/lockv3.h +++ /dev/null @@ -1,274 +0,0 @@ -/* - * PROGRAM: JRD Lock Manager - * MODULE: lockv3.h - * DESCRIPTION: Version 3 lock manager structure definitions - * - * The contents of this file are subject to the Interbase Public - * License Version 1.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy - * of the License at http://www.Inprise.com/IPL.html - * - * Software distributed under the License is distributed on an - * "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express - * or implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code was created by Inprise Corporation - * and its predecessors. Portions created by Inprise Corporation are - * Copyright (C) Inprise Corporation. - * - * All Rights Reserved. - * Contributor(s): ______________________________________. - * - * 2002.02.15 Sean Leyne - Code Cleanup, removed obsolete "XENIX" port - * 2002.02.15 Sean Leyne - Code Cleanup, removed obsolete "DELTA" port - * 2002.02.15 Sean Leyne - Code Cleanup, removed obsolete "IMP" port - * 2002.02.15 Sean Leyne - Code Cleanup, removed obsolete "M88K" port - * - * 2002.10.27 Sean Leyne - Code Cleanup, removed obsolete "UNIXWARE" port - * 2002.10.27 Sean Leyne - Code Cleanup, removed obsolete "Ultrix" port - * - * 2002.10.28 Sean Leyne - Completed removal of obsolete "DGUX" port - * 2002.10.28 Sean Leyne - Code cleanup, removed obsolete "SGI" port - * - */ - -#include - -#include -#include -#include -#include -#include - -#include "../jrd/common.h" -#include "../lock/fparamv3.h" - -#ifndef HAVE_SEMUN -union semun { - int val; - struct semid_ds *buf; - ushort *array; -}; -#endif - -#define DEFAULT_SIZE 32768 -#define BLOCKING_SIGNAL SIGUSR1 - -#ifndef EXTEND_SIZE -#define EXTEND_SIZE 32768 -#endif - -#ifdef SINIXZ -#define SEMAPHORES 25 -#endif - -#ifdef SOLARIS -#define SEMAPHORES 25 -#endif - -#ifndef SEMAPHORES -#define SEMAPHORES 32 -#endif - -#undef BASE -#define BASE ((UCHAR*) LOCK_header) -#define REL_PTR(item) ((UCHAR*) item - BASE) -#define ABS_PTR(item) (BASE + item) - -#define QUE_INIT(que) {que.srq_forward = que.srq_backward = REL_PTR (&que);} -#define QUE_EMPTY(que) (que.srq_forward == REL_PTR (&que)) -#define QUE_NEXT(que) (SRQ) ABS_PTR (que.srq_forward) - -#define QUE_LOOP(header,que) for (que = QUE_NEXT (header);\ - que != &header; que = QUE_NEXT ((*que))) - -#define PTR long - -/* Lock states */ - -#define LCK_none 0 -#define LCK_null 1 -#define LCK_SR 2 /* Shared Read */ -#define LCK_PR 3 /* Protected Read */ -#define LCK_SW 4 /* Shared Write */ -#define LCK_PW 5 /* Protected Write */ -#define LCK_EX 6 /* Exclusive */ -#define LCK_max 7 - -/* Lock block types */ - -#define type_null 0 -#define type_lhb 1 -#define type_prb 2 -#define type_lrq 3 -#define type_lbl 4 -#define type_his 5 -#define type_smb 6 -#define type_shb 7 - - -/* Self-relative que block. Offsets are from the block itself. */ - -typedef struct srq { - PTR srq_forward; /* Forward offset */ - PTR srq_backward; /* Backward offset */ -} *SRQ; - - -#define LHB_VERSION5 5 -#define LHB_VERSION6 6 -#define LHB_VERSION7 7 -#define LHB_VERSION 7 -#define LHB_PATTERN 123454321 - -/* Lock header block -- one per lock file, lives up front */ - -typedef struct lhb { - UCHAR lhb_type; - UCHAR lhb_version; /* Version of lock table */ - PTR lhb_secondary; /* Secondary lock header block */ - PTR lhb_active_process; /* Active process, if any */ - struct srq lhb_processes; /* Que of active processess */ - struct srq lhb_free_processes; /* Free process blocks */ - struct srq lhb_free_locks; /* Free lock blocks */ - struct srq lhb_free_requests; /* Free lock requests */ - long lhb_length; /* Size of lock table */ - long lhb_used; /* Bytes of lock table in use */ - USHORT lhb_hash_slots; /* Number of hash slots allocated */ - long lhb_mutex[2]; /* Mutex controlling access */ - PTR lhb_history; - int lhb_enqs; - int lhb_converts; - int lhb_denies; - int lhb_deadlocks; - int lhb_scans; - int lhb_blocks; - ULONG lhb_mask; /* Mask of available semaphores */ - struct srq lhb_hash[1]; /* Hash table */ -} *LHB; - -/* Secondary header block -- exists only in V3.3 and later lock - managers. It is pointed to by the word in the lhb that used to contain - a pattern. */ - -typedef struct shb { - UCHAR shb_type; - UCHAR shb_flags; - PTR shb_history; - PTR shb_remove_node; /* Node removing itself */ - PTR shb_insert_que; /* Queue inserting into */ - PTR shb_insert_prior; /* Prior of inserting queue */ - long shb_misc[10]; /* Unused space */ -} *SHB; - - -/* Lock block */ - -typedef struct lbl -{ - UCHAR lbl_type; - UCHAR lbl_state; /* High state granted */ - UCHAR lbl_size; /* Key bytes allocated */ - UCHAR lbl_length; /* Key bytes used */ - struct srq lbl_requests; /* Requests granted */ - struct srq lbl_lhb_hash; /* Collision que for hash table */ - long lbl_data; /* user data */ - PTR lbl_parent; /* Parent */ - UCHAR lbl_series; /* Lock series */ - UCHAR lbl_flags; /* Misc flags */ - UCHAR lbl_counts5[LCK_max]; /* Counts of granted locks */ - UCHAR lbl_key5[1]; /* Key value */ - USHORT lbl_counts7[LCK_max]; /* Counts of granted locks */ - UCHAR lbl_key7[1]; /* Key value */ -} *LBL; - -#define LBL_scanned 1 /* Lock as been scanned */ - -/* Lock requests */ - -typedef struct lrq { - UCHAR lrq_type; - UCHAR lrq_flags; /* Misc crud */ - UCHAR lrq_requested; /* Level requested */ - UCHAR lrq_state; /* State of lock request */ - PTR lrq_process; /* Process making request */ - PTR lrq_lock; /* Lock requested */ - struct srq lrq_prb_requests; /* Locks granted for process */ - struct srq lrq_lbl_requests; /* Que of requests (active, pending) */ - struct srq lrq_prb_blocks; /* Process block que */ - int (*lrq_ast_routine) (); /* Block ast routine */ - int *lrq_ast_argument; /* Ast argument */ -} *LRQ; - -#define LRQ_blocking 1 /* Request is blocking */ -#define LRQ_pending 2 /* Request is pending */ -#define LRQ_converting 4 /* Request is pending conversion */ -#define LRQ_rejected 8 /* Request is rejected */ -#define LRQ_timed_out 16 /* Wait timed out */ - -/* Process block */ - -typedef struct prb -{ - UCHAR prb_type; - UCHAR prb_flags; /* Misc stuff */ - struct srq prb_lhb_processes; /* Processes que */ - struct srq prb_requests; /* Lock requests granted */ - struct srq prb_blocks; /* Lock requests blocking */ - PTR prb_pending_request; /* Request we're waiting on */ - int prb_process_id; /* Process ID */ - int prb_process_uid; /* Process UID */ - UCHAR prb_semaphore5; /* Process semaphore */ - USHORT prb_semaphore7; /* Process semaphore */ -} *PRB; - -#define PRB_blocking 1 /* Process is blocking */ -#define PRB_scanned 2 /* Process has been deadlock scanned */ -#define PRB_manager 4 /* Process is privileged manager */ -#define PRB_signal 8 /* Process needs signal delivered */ -#define PRB_signaled 16 /* Signal is thought to be delivered */ -#define PRB_wakeup 32 /* Process has been awoken */ - -/* Flag in prb_semaphore */ - -#define PRB_semavail5 0x80 /* Process semaphore is available */ -#define PRB_semavail7 0x8000 /* Process semaphore is available */ - -/* Semaphore mask block */ - -#define SMB_SEMAPHORES6 128 - -typedef struct smb { - UCHAR smb_type; - ULONG smb_mask[1]; /* Mask of available semaphores */ -} *SMB; - -/* Lock manager history block */ - -typedef struct his { - UCHAR his_type; - UCHAR his_operation; - PTR his_next; - PTR his_process; - PTR his_lock; - PTR his_request; -} *HIS; - -#define his_enq 1 -#define his_deq 2 -#define his_convert 3 -#define his_signal 4 -#define his_post_ast 5 -#define his_wait 6 -#define his_del_process 7 -#define his_del_lock 8 -#define his_del_request 9 -#define his_deny 10 -#define his_grant 11 -#define his_leave_ast 12 -#define his_scan 13 -#define his_dead 14 -#define his_enter 15 -#define his_bug 16 -#define his_active 17 diff --git a/src/lock/lockv3s4.h b/src/lock/lockv3s4.h deleted file mode 100644 index 13fadb0cb4..0000000000 --- a/src/lock/lockv3s4.h +++ /dev/null @@ -1,237 +0,0 @@ -/* - * PROGRAM: JRD Lock Manager - * MODULE: lockv3s4.h - * DESCRIPTION: Version 3 Sun 4 lock manager structure definitions - * - * The contents of this file are subject to the Interbase Public - * License Version 1.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy - * of the License at http://www.Inprise.com/IPL.html - * - * Software distributed under the License is distributed on an - * "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express - * or implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code was created by Inprise Corporation - * and its predecessors. Portions created by Inprise Corporation are - * Copyright (C) Inprise Corporation. - * - * All Rights Reserved. - * Contributor(s): ______________________________________. - */ - -#include -#include -#include -#include - -#include "../jrd/common.h" -#include "../lock/fparamv3.h" - -#define BLOCKING_SIGNAL SIGUSR1 -#define DEFAULT_SIZE 32768 -#define EXTEND_SIZE 32768 -#define SEM_KEY 100 -#ifdef SINIXZ -#define SEMAPHORES 25 -#else -#define SEMAPHORES 32 -#endif - -#define BASE ((UCHAR*) LOCK_header) -#define REL_PTR(item) ((UCHAR*) item - BASE) -#define ABS_PTR(item) (BASE + item) - -#define QUE_INIT(que) {que.srq_forward = que.srq_backward = REL_PTR (&que);} -#define QUE_EMPTY(que) (que.srq_forward == REL_PTR (&que)) -#define QUE_NEXT(que) ABS_PTR (que.srq_forward) - -#define QUE_LOOP(header,que) for (que = (SRQ) QUE_NEXT (header);\ - que != &header; que = (SRQ) QUE_NEXT ((*que))) - -#define PTR long - -/* Lock states */ - -#define LCK_none 0 -#define LCK_null 1 -#define LCK_SR 2 /* Shared Read */ -#define LCK_PR 3 /* Protected Read */ -#define LCK_SW 4 /* Shared Write */ -#define LCK_PW 5 /* Protected Write */ -#define LCK_EX 6 /* Exclusive */ -#define LCK_max 7 - -/* Lock block types */ - -#define type_null 0 -#define type_lhb 1 -#define type_prb 2 -#define type_lrq 3 -#define type_lbl 4 -#define type_his 5 -#define type_smb 6 -#define type_shb 7 - - -/* Self-relative que block. Offsets are from the block itself. */ - -typedef struct srq { - PTR srq_forward; /* Forward offset */ - PTR srq_backward; /* Backward offset */ -} *SRQ; - -#define LHB_VERSION3 3 -#define LHB_VERSION4 4 -#define LHB_VERSION5 5 -#define LHB_VERSION 5 -#define LHB_PATTERN 123454321 - -/* Lock header block -- one per lock file, lives up front */ - -typedef struct lhb { - UCHAR lhb_type; - UCHAR lhb_version; /* Version of lock table */ - PTR lhb_secondary; /* Secondary lock header block */ - PTR lhb_active_process; /* Active process, if any */ - struct srq lhb_processes; /* Que of active processess */ - struct srq lhb_free_processes; /* Free process blocks */ - struct srq lhb_free_locks; /* Free lock blocks */ - struct srq lhb_free_requests; /* Free lock requests */ - long lhb_length; /* Size of lock table */ - long lhb_used; /* Bytes of lock table in use */ - USHORT lhb_hash_slots; /* Number of hash slots allocated */ - PTR lhb_history; - int lhb_enqs; - int lhb_converts; - int lhb_denies; - int lhb_deadlocks; - int lhb_scans; - int lhb_blocks; - ULONG lhb_mask; /* Mask of available semaphores */ - struct srq lhb_hash[1]; /* Hash table */ -} *LHB; - -/* Secondary header block -- exists only in V3.3 and later lock - managers. It is pointed to by the word in the lhb that used to contain - a pattern. */ - -typedef struct shb { - UCHAR shb_type; - UCHAR shb_flags; - PTR shb_history; - PTR shb_remove_node; /* Node removing itself */ - PTR shb_insert_que; /* Queue inserting into */ - PTR shb_insert_prior; /* Prior of inserting queue */ - long shb_misc[10]; /* Unused space */ -} *SHB; - - -/* Lock block */ - -typedef struct lbl { - UCHAR lbl_type; - UCHAR lbl_state; /* High state granted */ - UCHAR lbl_size; /* Key bytes allocated */ - UCHAR lbl_length; /* Key bytes used */ - struct srq lbl_requests; /* Requests granted */ - struct srq lbl_lhb_hash; /* Collision que for hash table */ - long lbl_data; /* user data */ - PTR lbl_parent; /* Parent */ - UCHAR lbl_series; /* Lock series */ - UCHAR lbl_flags; /* Misc flags */ - UCHAR lbl_counts3[LCK_max]; /* Counts of granted locks */ - UCHAR lbl_key3[1]; /* Key value */ - USHORT lbl_counts5[LCK_max]; /* Counts of granted locks */ - UCHAR lbl_key5[1]; /* Key value */ -} *LBL; - -#define LBL_scanned 1 /* Lock as been scanned */ - -/* Lock requests */ - -typedef struct lrq { - UCHAR lrq_type; - UCHAR lrq_flags; /* Misc crud */ - UCHAR lrq_requested; /* Level requested */ - UCHAR lrq_state; /* State of lock request */ - PTR lrq_process; /* Process making request */ - PTR lrq_lock; /* Lock requested */ - struct srq lrq_prb_requests; /* Locks granted for process */ - struct srq lrq_lbl_requests; /* Que of requests (active, pending) */ - struct srq lrq_prb_blocks; /* Process block que */ - int (*lrq_ast_routine) (); /* Block ast routine */ - int *lrq_ast_argument; /* Ast argument */ -} *LRQ; - -#define LRQ_blocking 1 /* Request is blocking */ -#define LRQ_pending 2 /* Request is pending */ -#define LRQ_converting 4 /* Request is pending conversion */ -#define LRQ_rejected 8 /* Request is rejected */ - - -/* Process block */ - -typedef struct prb { - UCHAR prb_type; - UCHAR prb_flags; /* Misc stuff */ - struct srq prb_lhb_processes; /* Processes que */ - struct srq prb_requests; /* Lock requests granted */ - struct srq prb_blocks; /* Lock requests blocking */ - PTR prb_pending_request; /* Request we're waiting on */ - int prb_process_id; /* Process ID */ - int prb_process_uid; /* Process user ID */ - UCHAR prb_semaphore3; /* Process semaphore */ - USHORT prb_semaphore5; /* Process semaphore */ -} *PRB; - -#define PRB_blocking 1 /* Process is blocking */ -#define PRB_scanned 2 /* Process has been deadlock scanned */ -#define PRB_manager 4 /* Process is privileged manager */ -#define PRB_signal 8 /* Process needs signal delivered */ -#define PRB_wakeup 16 /* Process has been awoken */ - -/* Flag in prb_semaphore */ - -#define PRB_semavail3 0x80 /* Process semaphore is available */ -#define PRB_semavail5 0x8000 /* Process semaphore is available */ - -/* Semaphore mask block */ - -#define SMB_SEMAPHORES4 128 - -typedef struct smb { - UCHAR smb_type; - ULONG smb_mask[1]; /* Mask of available semaphores */ -} *SMB; - -/* Lock manager history block */ - -typedef struct his { - UCHAR his_type; - UCHAR his_operation; - PTR his_next; - PTR his_process; - PTR his_lock; - PTR his_request; -} *HIS; - -#define his_enq 1 -#define his_deq 2 -#define his_convert 3 -#define his_signal 4 -#define his_post_ast 5 -#define his_wait 6 -#define his_del_process 7 -#define his_del_lock 8 -#define his_del_request 9 -#define his_deny 10 -#define his_grant 11 -#define his_leave_ast 12 -#define his_scan 13 -#define his_dead 14 -#define his_enter 15 -#define his_cleanup 16 -#define his_bug 17 -#define his_active 18 diff --git a/src/lock/print.cpp b/src/lock/print.cpp index 775b95d8ae..a0b7601b96 100644 --- a/src/lock/print.cpp +++ b/src/lock/print.cpp @@ -44,7 +44,6 @@ #include "../jrd/gds_proto.h" #include "../jrd/isc_proto.h" #include "../jrd/isc_s_proto.h" -#include "../lock/prtv3_proto.h" #ifdef HAVE_UNISTD_H #include @@ -556,13 +555,6 @@ int CLIB_ROUTINE main( int argc, char *argv[]) if (LOCK_header->lhb_secondary != LHB_PATTERN) prt_history(outfile, LOCK_header, shb->shb_history, "Event log"); -#if !(defined WIN_NT) - if (!sw_nobridge) { - FPRINTF(outfile, "\nBRIDGE RESOURCES\n\n"); - V3_lock_print(orig_argc, (UCHAR**) orig_argv); - } -#endif - if (header) gds__free(header); exit(FINI_OK); diff --git a/src/lock/printv3.cpp b/src/lock/printv3.cpp deleted file mode 100644 index bce0922298..0000000000 --- a/src/lock/printv3.cpp +++ /dev/null @@ -1,505 +0,0 @@ -/* - * PROGRAM: JRD Lock Manager - * MODULE: printv3.c - * DESCRIPTION: Version 3 lock Table printer - * - * The contents of this file are subject to the Interbase Public - * License Version 1.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy - * of the License at http://www.Inprise.com/IPL.html - * - * Software distributed under the License is distributed on an - * "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express - * or implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code was created by Inprise Corporation - * and its predecessors. Portions created by Inprise Corporation are - * Copyright (C) Inprise Corporation. - * - * All Rights Reserved. - * Contributor(s): ______________________________________. - * - * 2002.02.15 Sean Leyne - Code Cleanup, removed obsolete "IMP" port - * - */ - -#include "firebird.h" -#include "../jrd/ib_stdio.h" -#include -#include - -#include "../jrd/common.h" -#include "../jrd/isc.h" -#include "../jrd/isc_proto.h" -#include "../jrd/isc_s_proto.h" -#include "../jrd/gds_proto.h" -#include "../lock/lockv3.h" -#include "../lock/prtv3_proto.h" - -#include - -#ifndef FOPEN_READ_TYPE -#define FOPEN_READ_TYPE "r" -#endif - -static USHORT sw_requests, sw_processes, sw_locks, sw_series, sw_history, - sw_mutex; - -static LHB LOCK_header; -static int LOCK_shmid, LOCK_semid, LOCK_pid; -static LRQ LOCK_wait_request; -static long LOCK_shm_size = DEFAULT_SIZE; - -static struct { - char *tptr; - long *vptr; -} LOCK_hdrtbl[] = { -"SHMSIZE", &LOCK_shm_size, NULL, NULL}; - -static void prt_lock_init(); -static void get_lock_header(); -static void prt_history(PTR, char *); -static void prt_lock(LBL ); -static void prt_process(PRB ); -static void prt_request(LRQ ); -static void prt_que(UCHAR *, SRQ ); - -static TEXT *history_names[] = { - "n/a", "ENQ", "DEQ", "CONVERT", "SIGNAL", "POST", "WAIT", - "DEL_PROC", "DEL_LOCK", "DEL_REQ", "DENY", "GRANT", "LEAVE", - "SCAN", "DEAD", "ENTER", "BUG", "ACTIVE" -}; - - -static UCHAR compatibility[] = { - -/* Shared Prot Shared Prot - none null Read Read Write Write Exclusive */ - -/* none */ 1, 1, 1, 1, 1, 1, 1, -/* null */ 1, 1, 1, 1, 1, 1, 1, -/* SR */ 1, 1, 1, 1, 1, 1, 0, -/* PR */ 1, 1, 1, 1, 0, 0, 0, -/* SW */ 1, 1, 1, 0, 1, 0, 0, -/* PW */ 1, 1, 1, 0, 0, 0, 0, -/* EX */ 1, 1, 0, 0, 0, 0, 0 -}; - -#define COMPATIBLE(st1, st2) compatibility [st1 * LCK_max + st2] - - -int V3_lock_print(USHORT argc, UCHAR **argv) -{ -/************************************** - * - * V 3 _ l o c k _ p r i n t - * - ************************************** - * - * Functional description - * Print a v3 lock table for v4 - * - **************************************/ - USHORT name_length, i; - long start, length; - int fd; - SHB shb; - SRQ que, slot; - PRB process; - LBL lock; - UCHAR *p, c; - STATUS status_vector[ISC_STATUS_LENGTH]; - SH_MEM_T shmem_data; - TEXT expanded_filename[512], hostname[64]; - struct stat stat_buf; - -/* Handle switches, etc. */ - - argv++; - sw_processes = TRUE; - - while (--argc) { - p = (UCHAR*) *argv++; - while (c = *p++) - switch (c) { - case 'o': /* Owners: compatible with v4 */ - case 'p': - sw_processes = TRUE; - break; - - case 'l': - sw_locks = TRUE; - break; - - case 'r': - sw_requests = TRUE; - break; - - case 'a': - sw_locks = TRUE; - sw_processes = TRUE; - sw_requests = TRUE; - sw_history = TRUE; - break; - - case 'h': - sw_history = TRUE; - break; - - case 's': - sw_series = atoi((char*) *argv++); - --argc; - break; - - case '-': - break; - - default: - /* Silently ignore invalid options - - * the V4 option parser reported any appropriate error */ - break; - } - } - -/* first, make sure there's a v3 lock table */ - -#ifdef NOHOSTNAME - strcpy(expanded_filename, LOCK_FILE); -#else - sprintf(expanded_filename, LOCK_FILE, - ISC_get_host(hostname, sizeof(hostname))); -#endif - if (stat(expanded_filename, &stat_buf)) { - /* Silently return - there doesn't have to be a bridge file */ - return FB_FAILURE; - } - - get_lock_header(); - -#ifdef UNIX - shmem_data.sh_mem_semaphores = 0; -#endif - LOCK_header = (LHB) ISC_map_file(status_vector, LOCK_FILE, (void (*)(void *, sh_mem *, int)) prt_lock_init, 0, 0, /* Map entire length of segment */ - &shmem_data); - -/* if there's nothing mapped, there's nothing to print */ - - if (!shmem_data.sh_mem_length_mapped) - LOCK_header = (LHB) NULL; - - if (LOCK_header && shmem_data.sh_mem_length_mapped < sizeof(struct lhb)) { - /* File is obviously too small to really be a lock file */ - ib_printf("Bridge lock file too small.\n%s\n", expanded_filename); - return FB_FAILURE; - } - - if (LOCK_header && LOCK_header->lhb_length > LOCK_shm_size) { - length = LOCK_header->lhb_length; - LOCK_header = - (LHB) ISC_remap_file(status_vector, &shmem_data, length, FALSE); - LOCK_shm_size = length; - } - - if (!LOCK_header) { - ib_printf("Unable to access bridge lock table\n"); - gds__print_status(status_vector); - return FB_FAILURE; - } - - LOCK_shm_size = shmem_data.sh_mem_length_mapped; - -/* if there's no version number - admit there's nothing to say and return. */ - - if (!LOCK_header->lhb_version) { - ib_printf("LOCK_HEADER BLOCK\n"); - ib_printf("\tNo bridge lock table present.\n"); - return FB_FAILURE; - } - -/* Print lock header block */ - - ib_printf("LOCK_HEADER BLOCK\n"); - ib_printf("\tVersion: %d, Active process: %d, Length: %d, Used: %d\n", - LOCK_header->lhb_version, LOCK_header->lhb_active_process, - LOCK_header->lhb_length, LOCK_header->lhb_used); - - ib_printf("\tSemmask: %x\n", LOCK_header->lhb_mask); - - ib_printf("\tEnqs: %d, Converts: %d, Rejects: %d, Blocks: %d\n", - LOCK_header->lhb_enqs, LOCK_header->lhb_converts, - LOCK_header->lhb_denies, LOCK_header->lhb_blocks); - - ib_printf("\tDeadlock scans: %d, Deadlocks: %d\n", - LOCK_header->lhb_scans, LOCK_header->lhb_deadlocks); - - if (LOCK_header->lhb_secondary != LHB_PATTERN) { - shb = (SHB) ABS_PTR(LOCK_header->lhb_secondary); - ib_printf("\tRemove node: %d, Insert queue: %d, Insert prior: %d\n", - shb->shb_remove_node, shb->shb_insert_que, - shb->shb_insert_prior); - } - - prt_que((UCHAR*) "\tProcesses", &LOCK_header->lhb_processes); - prt_que((UCHAR*) "\tFree processes", &LOCK_header->lhb_free_processes); - prt_que((UCHAR*) "\tFree locks", &LOCK_header->lhb_free_locks); - prt_que((UCHAR*) "\tFree requests", &LOCK_header->lhb_free_requests); - ib_printf("\n"); - -/* Print known processes */ - - if (sw_processes) - QUE_LOOP(LOCK_header->lhb_processes, que) - prt_process((PRB)(UCHAR *) que - OFFSET(PRB, prb_lhb_processes)); - -/* Print known locks */ - - if (sw_locks || sw_series) - for (slot = LOCK_header->lhb_hash, i = 0; - i < LOCK_header->lhb_hash_slots; slot++, i++) - for (que = (SRQ) ABS_PTR(slot->srq_forward); que != slot; - que = (SRQ) ABS_PTR(que->srq_forward)) - prt_lock((LBL)(UCHAR *) que - OFFSET(LBL, lbl_lhb_hash)); - - if (sw_history) - prt_history(LOCK_header->lhb_history, "History"); - - if (LOCK_header->lhb_secondary != LHB_PATTERN) - prt_history(shb->shb_history, "Event log"); - - return FB_SUCCESS; -} - - -static void get_lock_header() -{ -/************************************* - * - * g e t _ l o c k _ h e a d e r - * - ************************************* - * - * Functional description - * Read user-defined values for shared memory - * and semaphores from LOCK_HEADER. - * - ************************************/ - IB_FILE *fd; - char *p, *q, buf[40]; - int i; - - if (fd = ib_fopen(LOCK_HEADER, FOPEN_READ_TYPE)) { - while (p = ib_fgets(buf, 40, fd)) - for (i = 0; q = LOCK_hdrtbl[i].tptr; i++) { - p = buf; - while (*p++ == *q++); - if (!*--q) { - *LOCK_hdrtbl[i].vptr = atoi(p); - break; - } - } - ib_fclose(fd); - } -} - - -static void prt_lock_init() -{ -/************************************** - * - * l o c k _ i n i t - * - ************************************** - * - * Functional description - * Initialize a lock table to looking -- i.e. don't do - * nuthin. - * - **************************************/ -} - - -static void prt_history(PTR history_header, char *title) -{ -/************************************** - * - * p r t _ h i s t o r y - * - ************************************** - * - * Functional description - * Print history list of lock table. - * - **************************************/ - HIS history; - - ib_printf("%s:\n", title); - - for (history = (HIS) ABS_PTR(history_header); TRUE; - history = (HIS) ABS_PTR(history->his_next)) { - if (history->his_operation) - ib_printf(" %s:\tprocess = %d, lock = %d, request = %d\n", - history_names[history->his_operation], - history->his_process, history->his_lock, - history->his_request); - if (history->his_next == history_header) - break; - } -} - - -static void prt_lock(LBL lock) -{ -/************************************** - * - * p r t _ l o c k - * - ************************************** - * - * Functional description - * Print a formatted lock block - * - **************************************/ - long key; - UCHAR c, *p, *q, *end, temp[512]; - SRQ que; - LRQ request; - - if (sw_series && lock->lbl_series != sw_series) - return; - - if (LOCK_header->lhb_version >= LHB_VERSION7) - q = lock->lbl_key7; - else - q = lock->lbl_key5; - for (p = temp, end = q + lock->lbl_length; q < end; q++) { - c = *q; - if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '/') - *p++ = c; - else { - sprintf((char*) p, "<%d>", c); - while (*p) - p++; - } - } - - *p = 0; - - ib_printf("LOCK BLOCK %d\n", REL_PTR(lock)); - ib_printf - ("\tSeries: %d, Parent: %d, State: %d, size: %d length: %d data: %d\n", - lock->lbl_series, lock->lbl_parent, lock->lbl_state, lock->lbl_size, - lock->lbl_length, lock->lbl_data); - - if (lock->lbl_length == 4) { - p = (UCHAR *) & key; - if (LOCK_header->lhb_version >= LHB_VERSION7) - q = lock->lbl_key7; - else - q = lock->lbl_key5; - for (end = q + 4; q < end; q++) - *p++ = *q; - ib_printf("\tKey: %d\n", key); - } - else - ib_printf("\tKey: %s\n", temp); - - prt_que((UCHAR*) "\tHash que", &lock->lbl_lhb_hash); - - prt_que((UCHAR*) "\tRequests", &lock->lbl_requests); - QUE_LOOP(lock->lbl_requests, que) { - request = (LRQ) ((UCHAR *) que - OFFSET(LRQ, lrq_lbl_requests)); - ib_printf("\t\tRequest %d, Process: %d, State: %d (%d), Flags: %d\n", - REL_PTR(request), request->lrq_process, request->lrq_state, - request->lrq_requested, request->lrq_flags); - } - - ib_printf("\n"); -} - - -static void prt_process(PRB process) -{ -/************************************** - * - * p r t _ p r o c e s s - * - ************************************** - * - * Functional description - * Print a formatted process block. - * - **************************************/ - SRQ que; - - ib_printf("PROCESS BLOCK %d\n", REL_PTR(process)); - ib_printf - ("\tProcess id: %d, flags: %d, pending: %d, UID: %x, semid: %d\n", - process->prb_process_id, process->prb_flags, - process->prb_pending_request, process->prb_process_uid, - (LOCK_header->lhb_version >= - LHB_VERSION7) ? process->prb_semaphore7 : process->prb_semaphore5); - - prt_que((UCHAR*) "\tRequests", &process->prb_requests); - prt_que((UCHAR*) "\tBlocks", &process->prb_blocks); - ib_printf("\n"); - - if (sw_requests) - QUE_LOOP(process->prb_requests, que) - prt_request((LRQ) (UCHAR *) que - OFFSET(LRQ, lrq_prb_requests)); -} - - -static void prt_request(LRQ request) -{ -/************************************** - * - * p r t _ r e q u e s t - * - ************************************** - * - * Functional description - * Print a format request block. - * - **************************************/ - - ib_printf("REQUEST BLOCK %d\n", REL_PTR(request)); - ib_printf("\tProcess: %d, Lock: %d, State: %d, Mode: %d, Flags: %x\n", - request->lrq_process, request->lrq_lock, request->lrq_state, - request->lrq_requested, request->lrq_flags); - ib_printf("\tAST: %x, argument: %x\n", request->lrq_ast_routine, - request->lrq_ast_argument); - ib_printf("\n"); -} - - -static void prt_que(UCHAR *string, SRQ que) -{ -/************************************** - * - * p r t _ q u e - * - ************************************** - * - * Functional description - * Print the contents of a self-relative que. - * - **************************************/ - long count, offset; - SRQ next; - - offset = REL_PTR(que); - - if (offset == que->srq_forward && offset == que->srq_backward) { - ib_printf("%s: *empty*\n", string); - return; - } - - count = 0; - - QUE_LOOP((*que), next) - ++ count; - - ib_printf("%s (%ld):\tforward: %d, backward: %d\n", - string, count, que->srq_forward, que->srq_backward); -} diff --git a/src/lock/printv3s4.cpp b/src/lock/printv3s4.cpp deleted file mode 100644 index 7a23c359a3..0000000000 --- a/src/lock/printv3s4.cpp +++ /dev/null @@ -1,411 +0,0 @@ -/* - * PROGRAM: JRD Lock Manager - * MODULE: printv3s4.c - * DESCRIPTION: Version 3 Sun 4 lock Table printer - * - * The contents of this file are subject to the Interbase Public - * License Version 1.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy - * of the License at http://www.Inprise.com/IPL.html - * - * Software distributed under the License is distributed on an - * "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express - * or implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code was created by Inprise Corporation - * and its predecessors. Portions created by Inprise Corporation are - * Copyright (C) Inprise Corporation. - * - * All Rights Reserved. - * Contributor(s): ______________________________________. - */ - -#include "firebird.h" -#include "../jrd/ib_stdio.h" -#include "../lock/lockv3s4.h" -#include "../lock/prtv3_proto.h" - -#ifndef MAXHOSTNAMELEN -#define MAXHOSTNAMELEN 64 -#endif - -#include -#include - -static USHORT sw_requests, sw_processes, sw_locks, sw_series, sw_history, - sw_mutex; - -static LHB LOCK_header; -static long LOCK_size_mapped; -static LOCK_fd; - -#define default_size 8192 -#define hash_slots 101 - -static TEXT *history_names[] = { - "n/a", "ENQ", "DEQ", "CONVERT", "SIGNAL", "POST", "WAIT", - "DEL_PROC", "DEL_LOCK", "DEL_REQ", "DENY", "GRANT", "LEAVE", - "SCAN", "DEAD", "ENTER", "CLEANUP", "BUG", "ACTIVE" -}; - - - -static UCHAR compatibility[] = { - -/* Shared Prot Shared Prot - none null Read Read Write Write Exclusive */ - -/* none */ 1, 1, 1, 1, 1, 1, 1, -/* null */ 1, 1, 1, 1, 1, 1, 1, -/* SR */ 1, 1, 1, 1, 1, 1, 0, -/* PR */ 1, 1, 1, 1, 0, 0, 0, -/* SW */ 1, 1, 1, 0, 1, 0, 0, -/* PW */ 1, 1, 1, 0, 0, 0, 0, -/* EX */ 1, 1, 0, 0, 0, 0, 0 -}; - -#define COMPATIBLE(st1, st2) compatibility [st1 * LCK_max + st2] - - -V3_lock_print(argc, argv) - USHORT argc; - UCHAR *argv[]; -{ -/************************************** - * - * V 3 _ l o c k _ p r i n t - * - ************************************** - * - * Functional description - * Print v3 lock table structure - * - **************************************/ - USHORT name_length, i; - long start, length; - SHB shb; - SRQ que, slot; - PRB process; - LBL lock; - UCHAR *p, c; - char lock_file[MAXPATHLEN]; - char host_name[MAXHOSTNAMELEN]; - struct stat stat_buf; - -/* Handle switches, etc. */ - - argv++; - sw_processes = TRUE; - - while (--argc) { - p = *argv++; - while (c = *p++) - switch (c) { - case 'o': /* Owners: compatible with v4 */ - case 'p': - sw_processes = TRUE; - break; - - case 'l': - sw_locks = TRUE; - break; - - case 'r': - sw_requests = TRUE; - break; - - case 'a': - sw_locks = TRUE; - sw_processes = TRUE; - sw_requests = TRUE; - sw_history = TRUE; - break; - - case 'h': - sw_history = TRUE; - break; - - case 's': - sw_series = atoi(*argv++); - --argc; - break; - - case '-': - break; - - default: - /* Silently ignore invalid options - - * the V4 option parser reported any appropriate error */ - break; - } - } - -/* Construct a node-specific filename of the form "gds.lockfile." */ - - if (gethostname(host_name, sizeof(host_name))) { - ib_printf("gethostname failed\n"); - return FB_FAILURE; - } - - sprintf(lock_file, LOCK_FILE, host_name); - - LOCK_fd = open(lock_file, O_RDWR, 0660); - if (LOCK_fd == -1) { - /* Silently return - there doesn't have to be a bridge lock file */ - return FB_FAILURE; - } - - if (stat(lock_file, &stat_buf)) { - ib_printf("stat failed for bridge lock table %s\n", lock_file); - return FB_FAILURE; - } - - if (stat_buf.st_size < sizeof(struct lhb)) { - /* File is obviously too small to really be a lock file */ - ib_printf("Bridge lock file too small: %s\n", lock_file); - return FB_FAILURE; - } - - LOCK_size_mapped = DEFAULT_SIZE; - LOCK_header = - (LHB) mmap(NULL, LOCK_size_mapped, PROT_READ | PROT_WRITE, MAP_SHARED, - LOCK_fd, 0); - - if ((int) LOCK_header == -1) { - ib_printf("mmap failed\n"); - return FB_FAILURE; - } - -/* If the table is larger than usual, remap it */ - - if (LOCK_header->lhb_length > LOCK_size_mapped) { - length = LOCK_header->lhb_length; - LOCK_header = - (LHB) mmap(NULL, length, PROT_READ | PROT_WRITE, MAP_SHARED, - LOCK_fd, 0); - } - -/* Print lock header block */ - - ib_printf("LOCK_HEADER BLOCK\n"); - ib_printf("\tVersion: %d, Active process: %d, Length: %d, Used: %d\n", - LOCK_header->lhb_version, LOCK_header->lhb_active_process, - LOCK_header->lhb_length, LOCK_header->lhb_used); - - ib_printf("\tEnqs: %d, Converts: %d, Rejects: %d, Blocks: %d\n", - LOCK_header->lhb_enqs, LOCK_header->lhb_converts, - LOCK_header->lhb_denies, LOCK_header->lhb_blocks); - - ib_printf("\tDeadlock scans: %d, Deadlocks: %d\n", - LOCK_header->lhb_scans, LOCK_header->lhb_deadlocks); - - if (LOCK_header->lhb_secondary != LHB_PATTERN) { - shb = (SHB) ABS_PTR(LOCK_header->lhb_secondary); - ib_printf("\tRemove node: %d, Insert queue: %d, Insert prior: %d\n", - shb->shb_remove_node, shb->shb_insert_que, - shb->shb_insert_prior); - } - - prt_que("\tProcesses", &LOCK_header->lhb_processes); - prt_que("\tFree processes", &LOCK_header->lhb_free_processes); - prt_que("\tFree locks", &LOCK_header->lhb_free_locks); - prt_que("\tFree requests", &LOCK_header->lhb_free_requests); - ib_printf("\n"); - -/* Print known processes */ - - if (sw_processes) - QUE_LOOP(LOCK_header->lhb_processes, que) - prt_process((UCHAR *) que - OFFSET(PRB, prb_lhb_processes)); - -/* Print known locks */ - - if (sw_locks || sw_series) - for (slot = LOCK_header->lhb_hash, i = 0; - i < LOCK_header->lhb_hash_slots; slot++, i++) - for (que = (SRQ) ABS_PTR(slot->srq_forward); que != slot; - que = (SRQ) ABS_PTR(que->srq_forward)) - prt_lock((UCHAR *) que - OFFSET(LBL, lbl_lhb_hash)); - - if (sw_history) - prt_history(LOCK_header->lhb_history, "History"); - - if (LOCK_header->lhb_secondary != LHB_PATTERN) - prt_history(shb->shb_history, "Event log"); - - return FB_SUCCESS; -} - - -static void prt_history(history_header, title) - PTR history_header; - char *title; -{ -/************************************** - * - * p r t _ h i s t o r y - * - ************************************** - * - * Functional description - * Print history list of lock table. - * - **************************************/ - HIS history; - - ib_printf("%s:\n", title); - - for (history = (HIS) ABS_PTR(history_header); TRUE; - history = (HIS) ABS_PTR(history->his_next)) { - if (history->his_operation) - ib_printf(" %s:\tprocess = %d, lock = %d, request = %d\n", - history_names[history->his_operation], - history->his_process, history->his_lock, - history->his_request); - if (history->his_next == history_header) - break; - } -} - - -static void prt_lock(lock) - LBL lock; -{ -/************************************** - * - * p r t _ l o c k - * - ************************************** - * - * Functional description - * Print a formatted lock block - * - **************************************/ - long key; - UCHAR *p, *q, *end; - SRQ que; - LRQ request; - - if (sw_series && lock->lbl_series != sw_series) - return; - - ib_printf("LOCK BLOCK %d\n", REL_PTR(lock)); - ib_printf - ("\tSeries: %d, Parent: %d, State: %d, size: %d length: %d data: %d\n", - lock->lbl_series, lock->lbl_parent, lock->lbl_state, lock->lbl_size, - lock->lbl_length, lock->lbl_data); - - if (LOCK_header->lhb_version >= LHB_VERSION5) - q = lock->lbl_key5; - else - q = lock->lbl_key3; - if (lock->lbl_length == 4) { - p = (UCHAR *) & key; - for (end = q + 4; q < end; q++) - *p++ = *q; - ib_printf("\tKey: %d\n", key); - } - else - ib_printf("\tKey: %.*s\n", lock->lbl_length, q); - - prt_que("\tHash que", &lock->lbl_lhb_hash); - prt_que("\tRequests", &lock->lbl_requests); - - QUE_LOOP(lock->lbl_requests, que) { - request = (LRQ) ((UCHAR *) que - OFFSET(LRQ, lrq_lbl_requests)); - ib_printf("\t\tRequest %d, Process: %d, State: %d (%d), Flags: %d\n", - REL_PTR(request), request->lrq_process, request->lrq_state, - request->lrq_requested, request->lrq_flags); - } - - ib_printf("\n"); -} - - -static void prt_process(process) - PRB process; -{ -/************************************** - * - * p r t _ p r o c e s s - * - ************************************** - * - * Functional description - * Print a formatted process block. - * - **************************************/ - SRQ que; - - ib_printf("PROCESS BLOCK %d\n", REL_PTR(process)); - ib_printf("\tProcess id: %d, flags: %d, pending: %d\n", - process->prb_process_id, process->prb_flags, - process->prb_pending_request); - - prt_que("\tRequests", &process->prb_requests); - prt_que("\tBlocks", &process->prb_blocks); - ib_printf("\n"); - - if (sw_requests) - QUE_LOOP(process->prb_requests, que) - prt_request((UCHAR *) que - OFFSET(LRQ, lrq_prb_requests)); -} - - -static void prt_request(request) - LRQ request; -{ -/************************************** - * - * p r t _ r e q u e s t - * - ************************************** - * - * Functional description - * Print a format request block. - * - **************************************/ - - ib_printf("REQUEST BLOCK %d\n", REL_PTR(request)); - ib_printf("\tProcess: %d, Lock: %d, State: %d, Mode: %d, Flags: %x\n", - request->lrq_process, request->lrq_lock, request->lrq_state, - request->lrq_requested, request->lrq_flags); - ib_printf("\tAST: %x, argument: %x\n", request->lrq_ast_routine, - request->lrq_ast_argument); - ib_printf("\n"); -} - - -static void prt_que(string, que) - UCHAR *string; - SRQ que; -{ -/************************************** - * - * p r t _ q u e - * - ************************************** - * - * Functional description - * Print the contents of a self-relative que. - * - **************************************/ - long count, offset; - SRQ next; - - offset = REL_PTR(que); - - if (offset == que->srq_forward && offset == que->srq_backward) { - ib_printf("%s: *empty*\n", string); - return; - } - - count = 0; - - QUE_LOOP((*que), next) - ++ count; - - ib_printf("%s (%ld):\tforward: %d, backward: %d\n", - string, count, que->srq_forward, que->srq_backward); -} diff --git a/src/lock/prtv3_proto.h b/src/lock/prtv3_proto.h deleted file mode 100644 index 09bb001f7a..0000000000 --- a/src/lock/prtv3_proto.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * PROGRAM: JRD Lock Manager - * MODULE: prtv3_proto.h - * DESCRIPTION: Version 3 lock Table printer prototype - * - * The contents of this file are subject to the Interbase Public - * License Version 1.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy - * of the License at http://www.Inprise.com/IPL.html - * - * Software distributed under the License is distributed on an - * "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express - * or implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code was created by Inprise Corporation - * and its predecessors. Portions created by Inprise Corporation are - * Copyright (C) Inprise Corporation. - * - * All Rights Reserved. - * Contributor(s): ______________________________________. - */ - -#ifndef _LOCK_PRTV3_PROTO_H_ -#define _LOCK_PRTV3_PROTO_H_ - -extern int V3_lock_print(USHORT , UCHAR **); - -#endif /* _LOCK_PRTV3_PROTO_H_ */ diff --git a/src/utilities/drop.cpp b/src/utilities/drop.cpp index 0093e88566..1ce6db69cf 100644 --- a/src/utilities/drop.cpp +++ b/src/utilities/drop.cpp @@ -20,7 +20,7 @@ * All Rights Reserved. * Contributor(s): ______________________________________. * - * $Id: drop.cpp,v 1.14 2002-12-07 13:32:34 dimitr Exp $ + * $Id: drop.cpp,v 1.15 2003-02-11 15:22:59 brodsom Exp $ * * 2002.10.27 Sean Leyne - Completed removal of obsolete "DELTA" port * 2002.10.27 Sean Leyne - Completed removal of obsolete "IMP" port @@ -42,7 +42,6 @@ #include "../jrd/license.h" #include "../jrd/gds_proto.h" #include "../jrd/isc_proto.h" -#include "../utilities/drpv3_proto.h" #include "../common/config/config.h" #ifdef HAVE_SYS_TYPES_H @@ -165,13 +164,6 @@ int CLIB_ROUTINE main( int argc, char *argv[]) shut_manager("lock manager"); #endif -#if !(defined WIN_NT || defined linux || defined FREEBSD || defined NETBSD || defined AIX_PPC || defined DARWIN) - if (!sw_nobridge) { - ib_printf("\nBRIDGE RESOURCES\n\n"); - V3_drop(orig_argc, (UCHAR **)orig_argv); - } -#endif - exit(FINI_OK); } diff --git a/src/utilities/dropv3.cpp b/src/utilities/dropv3.cpp deleted file mode 100644 index 15f111f0db..0000000000 --- a/src/utilities/dropv3.cpp +++ /dev/null @@ -1,414 +0,0 @@ -/* - * PROGRAM: UNIX resource removal program - * MODULE: dropv3.c - * DESCRIPTION: Version 3 drop shared memory and semaphores - * - * The contents of this file are subject to the Interbase Public - * License Version 1.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy - * of the License at http://www.Inprise.com/IPL.html - * - * Software distributed under the License is distributed on an - * "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express - * or implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code was created by Inprise Corporation - * and its predecessors. Portions created by Inprise Corporation are - * Copyright (C) Inprise Corporation. - * - * All Rights Reserved. - * Contributor(s): ______________________________________. - * - * 2002.02.15 Sean Leyne - Code Cleanup, removed obsolete "IMP" port - * - */ - -#include "firebird.h" -#include "../jrd/ib_stdio.h" -#include -#include -#include -#include - -#include "../jrd/common.h" -#include "../jrd/isc.h" -#if ( defined( sun) && defined( sparc) && !defined( SOLARIS)) -#include "../lock/lockv3s4.h" -#define SUN_V3_LOCK_MANAGER -#else -#include "../lock/lockv3.h" -#endif -#include "../jrd/license.h" -#include "../jrd/isc_proto.h" -#include "../jrd/isc_s_proto.h" -#include "../utilities/drpv3_proto.h" - -#define FTOK_KEY 15 - -static long get_key(); -static void dummy_init(); -static void get_lock_header(); -static int sem_exclusive(long , int ); -#ifndef HAVE_MMAP -static void remove_resource(int , TEXT *, int, int , TEXT *); -#else -static void remove_resource(int, TEXT *,int ,int ,TEXT *); -#endif - -static int LOCK_shm_size, LOCK_sem_key, LOCK_blk_signal, LOCK_sem_count; - -static struct { - char *tptr; - int *vptr; -} LOCK_hdrtbl[] = { -#ifndef HAVE_MMAP - {"SHMSIZE", &LOCK_shm_size}, -#else - {"SEMKEY", &LOCK_sem_key}, - {"BLKSIG", &LOCK_blk_signal}, -#endif - {"SEMCOUNT", &LOCK_sem_count}, - {NULL, NULL} -}; - - -void V3_drop(int argc, UCHAR **argv) -{ -/************************************** - * - * V 3 _ d r o p - * - ************************************** - * - * Functional description - * Drop Lock Table and associated semaphores. - * - **************************************/ - UCHAR **end, *p; - int sw_csv, sw_lockmngr, sw_events, sw_version; - - sw_csv = sw_lockmngr = sw_events = sw_version = FALSE; - end = argv + argc; - while (++argv < end) - if (**argv == '-') - for (p = *argv + 1; *p; p++) - switch (UPPER(*p)) { -#ifdef CSV - case 'C': - sw_csv = TRUE; - break; -#endif - - case 'E': - sw_events = TRUE; - break; - - case 'L': - sw_lockmngr = TRUE; - break; - - case 'A': - sw_csv = sw_events = sw_lockmngr = TRUE; - break; - - case 'Z': - sw_version = TRUE; - break; - - default: - ib_printf("***Ignoring unknown switch %c.\n", *p); - break; - } - - if (sw_version) - ib_printf("gds_drop version %s\n", GDS_VERSION); - - if (sw_events) - remove_resource(FALSE, EVENT_FILE, EVENT_DEFAULT_SIZE, - EVENT_SEMAPHORES, "events"); - - if (sw_lockmngr) { - get_lock_header(); - remove_resource(TRUE, LOCK_FILE, LOCK_shm_size, LOCK_sem_count, - "lock manager"); - } - -#ifdef CSV - if (sw_csv) - remove_resource(FALSE, CSI_FILE, CSI_DEFAULT_SIZE, MAX_PROCESSES, - "central server"); -#endif - - exit(FINI_OK); -} - - -static void dummy_init() -{ -/************************************** - * - * d u m m y _ i n i t - * - ************************************** - * - * Functional description - * A dummy callback routine for ISC_map_file. - * - **************************************/ -} - - -static long get_key(TEXT *filename) -{ -/************************************* - * - * g e t _ k e y - * - ************************************* - * - * Functional description - * Find the semaphore/shared memory key for a file. - * - ************************************/ - TEXT expanded_filename[128], hostname[64]; - -#ifdef NOHOSTNAME - strcpy(expanded_filename, filename); -#else - sprintf(expanded_filename, filename, - ISC_get_host(hostname, sizeof(hostname))); -#endif - -/* Produce shared memory key for file */ - - return ftok(expanded_filename, FTOK_KEY); -} - - -static void get_lock_header() -{ -/************************************* - * - * g e t _ l o c k _ h e a d e r - * - ************************************* - * - * Functional description - * Read user-defined values for shared memory - * and semaphores from LOCK_HEADER. - * - ************************************/ - IB_FILE *fd; - TEXT lock_header[MAXPATHLEN]; - char *p, *q, buf[40]; - int i; - -#ifndef HAVE_MMAP - LOCK_shm_size = DEFAULT_SIZE; -#else -#ifdef SUN_V3_LOCK_MANAGER - LOCK_sem_key = SEM_KEY; -#endif - LOCK_blk_signal = BLOCKING_SIGNAL; -#endif - LOCK_sem_count = SEMAPHORES; - - if (fd = ib_fopen(LOCK_HEADER, "r")) { - while (p = ib_fgets(buf, sizeof(buf) - 1, fd)) - for (i = 0; q = LOCK_hdrtbl[i].tptr; i++) { - p = buf; - while (*p++ == *q++); - if (!*--q) { - *LOCK_hdrtbl[i].vptr = atoi(p); - break; - } - } - ib_fclose(fd); - } -} - - -#ifndef HAVE_MMAP -static void remove_resource(int lock_flag, TEXT *filename, int shm_length, - int sem_count, TEXT *label) -{ -/************************************** - * - * r e m o v e _ r e s o u r c e ( G E N E R I C ) - * - ************************************** - * - * Functional description - * - **************************************/ - STATUS status_vector[ISC_STATUS_LENGTH]; - long length, key, shmid, semid; - SH_MEM_T shmem; - TEXT expanded_filename[512], hostname[64]; - struct stat stat_buf; - -#ifdef NOHOSTNAME - strcpy(expanded_filename, filename); -#else - sprintf(expanded_filename, filename, - ISC_get_host(hostname, sizeof(hostname))); -#endif - if (stat(expanded_filename, &stat_buf) == -1) { - ib_printf("\n***No bridge %s file found.\n", label); - return; - } - - shmem.sh_mem_semaphores = sem_count; - if (!ISC_map_file - (status_vector, filename, dummy_init, 0, shm_length, &shmem)) { - ib_printf("\n***Unable to access bridge %s resources:\n", label); - return; - } - - if ((key = get_key(filename)) == -1) { - ib_printf("\n***Unable to get the key value of the bridge %s file.\n", - label); - return; - } - - if ((shmid = shm_exclusive(key, shmem.sh_mem_length_mapped)) == -1 || - (semid = sem_exclusive(key, sem_count)) == -1) { - ib_printf - ("\n***File or semaphores for bridge %s are currently in use.\n", - label); - return; - } - - if (shmctl(shmid, IPC_RMID, 0) == -1) - ib_printf("\n***Error trying to drop bridge %s file. ERRNO = %d.\n", - label, errno); - else - ib_printf("Successfully removed %s file.\n", label); - - if (semctl(semid, sem_count, IPC_RMID, 0) == -1) - ib_printf - ("\n***Error trying to drop bridge %s semaphores. ERRNO = %d.\n", - label, errno); - else - ib_printf("Successfully removed bridge %s semaphores.\n", label); -} -#endif - - -#ifdef HAVE_MMAP -static void remove_resource(int lock_flag, TEXT *filename, int shm_length, - int sem_count, TEXT *label) -{ -/************************************** - * - * r e m o v e _ r e s o u r c e ( S U N O S 4 ) - * - ************************************** - * - * Functional description - * - **************************************/ - STATUS status_vector[ISC_STATUS_LENGTH]; - long length, key, shmid, semid; - TEXT expanded_filename[512], hostname[64]; - struct stat stat_buf; - #ifdef DARWIN - union semun semctlArg; - #endif - -#ifdef NOHOSTNAME - strcpy(expanded_filename, filename); -#else - sprintf(expanded_filename, filename, - ISC_get_host(hostname, sizeof(hostname))); -#endif - if (stat(expanded_filename, &stat_buf) == -1) { - ib_printf("\n***No bridge %s file found.\n", label); - return; - } - -#ifdef SUN_V3_LOCK_MANAGER - if (lock_flag) - key = LOCK_sem_key; - else -#endif - if ((key = get_key(filename)) == -1) { - ib_printf("\n***Unable to get the key value of the bridge %s file.\n", - label); - return; - } - - if ((semid = sem_exclusive(key, sem_count)) == -1) { - ib_printf("\n***Semaphores for bridge %s are currently in use.\n", - label); - return; - } - - #ifdef DARWIN - semctlArg.val = 0; - if (semctl(semid, sem_count, IPC_RMID, semctlArg) == -1) - #else - if (semctl(semid, sem_count, IPC_RMID, 0) == -1) - #endif - ib_printf - ("\n***Error trying to drop bridge %s semaphores. ERRNO = %d.\n", - label, errno); - else - ib_printf("Successfully removed bridge %s semaphores.\n", label); -} -#endif - - -static int sem_exclusive(long key, int count) -{ -/************************************** - * - * s e m _ e x c l u s i v e - * - ************************************** - * - * Functional description - * Check to see if we are the only ones accessing - * semaphores. Return a semaphore id if so, - * -1 otherwise. - * - **************************************/ - int semid; - -#ifndef HAVE_MMAP - return semget(key, count, IPC_EXCL); -#else - if ((semid = semget(key, count, IPC_EXCL)) != -1) - return semid; - else - return semget(key, count, IPC_EXCL | IPC_CREAT); -#endif -} - - -#ifndef HAVE_MMAP -static int shm_exclusive(long key, int length) -{ -/************************************** - * - * s h m _ e x c l u s i v e - * - ************************************** - * - * Functional description - * Check to see if we are the only ones accessing - * shared memory. Return a shared memory id - * if so, -1 otherwise. - * - **************************************/ - int id; - struct shmid_ds buf; - - if ((id = shmget(key, length, IPC_ALLOC)) == -1 || - shmctl(id, IPC_STAT, &buf) == -1 || buf.shm_nattch != 1) - return -1; - - return id; -} -#endif diff --git a/src/utilities/drpv3_proto.h b/src/utilities/drpv3_proto.h deleted file mode 100644 index 612611e492..0000000000 --- a/src/utilities/drpv3_proto.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * PROGRAM: UNIX resource removal program - * MODULE: drpv3_proto.h - * DESCRIPTION: Version 3 drop shared memory prototype - * - * The contents of this file are subject to the Interbase Public - * License Version 1.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy - * of the License at http://www.Inprise.com/IPL.html - * - * Software distributed under the License is distributed on an - * "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express - * or implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code was created by Inprise Corporation - * and its predecessors. Portions created by Inprise Corporation are - * Copyright (C) Inprise Corporation. - * - * All Rights Reserved. - * Contributor(s): ______________________________________. - */ - -#ifndef _UTILITIES_DRPV3_PROTO_H_ -#define _UTILITIES_DRPV3_PROTO_H_ - -extern void V3_drop( int, UCHAR**); - -#endif /* _UTILITIES_DRPV3_PROTO_H_ */