File: gtcml_chkprc.c

package info (click to toggle)
fis-gtm 6.2-000-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 30,784 kB
  • ctags: 42,554
  • sloc: ansic: 358,483; asm: 4,847; csh: 4,574; sh: 2,261; awk: 200; makefile: 86; sed: 13
file content (99 lines) | stat: -rw-r--r-- 2,415 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/****************************************************************
 *								*
 *	Copyright 2001, 2004 Sanchez Computer Associates, Inc.	*
 *								*
 *	This source code contains the intellectual property	*
 *	of its copyright holder(s), and is made available	*
 *	under a license.  If you do not know the terms of	*
 *	the license, please stop and do not read further.	*
 *								*
 ****************************************************************/

#include "mdef.h"

#if defined(VMS)
#include <ssdef.h>
#endif

#if defined(UNIX)
#include <signal.h>
#endif

#include "gdsroot.h"
#include "gtm_facility.h"
#include "fileinfo.h"
#include "gdsbt.h"
#include "gdsfhead.h"
#include "mlkdef.h"
#include "cmidef.h"
#include "hashtab_mname.h"	/* needed for cmmdef.h */
#include "cmmdef.h"
#include "gt_timer.h"
#include "gtcmlkdef.h"
#include "ast.h"
#include "gtcml.h"
#include "gtcm_action_pending.h"

GBLREF relque		action_que;
GBLREF gd_region	*gv_cur_region;
GBLREF struct NTD	*ntd_root;

void gtcml_chkprc(cm_lckblklck *lck)
{
	cm_lckblkprc	*prc, *prc1;
	boolean_t	found;
	long		status;
	CMI_MUTEX_DECL;

	error_def(CMERR_CMINTQUE);

	CMI_MUTEX_BLOCK;
	found = FALSE;
	prc = lck->prc;
	/* it appears that the design assumes that prc should never be null, but we have empirical evidence that it happens.
	 * because we do not (at the moment of writing) have resources to pursue the discrepancy, we simply protect
	 * against it, and hope that we don't encounter other symptoms
	 */
	while ((FALSE == found) && (NULL != prc))
	{
		if (CMMS_L_LKACQUIRE != prc->user->state || prc->user->transnum == prc->user->lk_cancel)
		{
			prc->next->last = prc->last;
			prc->last->next = prc->next;
			prc1 = prc->next;
			if (prc->next == prc)
				lck->prc = 0;
			else if (prc == lck->prc)
				lck->prc = prc1;
			free(prc);
			if (!lck->prc || prc1->next == lck->prc)
				break;
			prc = prc1;
			continue;
		}
		if (lck->sequence != lck->node->sequence)
		{
			lck->sequence = lck->node->sequence;
			found = TRUE;
		} else
		{
			if (prc->next == lck->prc)
				break;
			prc = prc->next;
		}
	}
	if (found)
	{
		status = gtcm_action_pending(prc->user);
		if (INTERLOCK_FAIL == status)
			rts_error(VARLSTCNT(1) CMERR_CMINTQUE);
		prc->next->last = prc->last;
		prc->last->next = prc->next;
		if (prc->next == prc)
			lck->prc = 0;
		else if (prc == lck->prc)
			lck->prc = prc->next;
		free(prc);
	}
	CMI_MUTEX_RESTORE;
}