File: gtcml_blklck.c

package info (click to toggle)
fis-gtm 6.3-007-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 36,284 kB
  • sloc: ansic: 328,861; asm: 5,182; csh: 5,102; sh: 1,918; awk: 291; makefile: 69; sed: 13
file content (119 lines) | stat: -rwxr-xr-x 2,960 bytes parent folder | download | duplicates (3)
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/****************************************************************
 *								*
 *	Copyright 2001, 2009 Fidelity Information Services, 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"
#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 "gtcml.h"

GBLREF cm_lckblkreg		*blkdlist;
GBLREF connection_struct	*curr_entry;

void gtcml_blklck(cm_region_list *region, mlk_pvtblk *lock, uint4 wake)
{
	cm_lckblkreg	*b, *b1;
	cm_lckblklck	*l, *l1, *l2, *tl1;
	cm_lckblkprc	*p, *p1, *p2, *pl1;
	uint4		status;
	boolean_t	new;

	region->blkd = lock;
	if (curr_entry->state != CMMS_L_LKACQUIRE)
		return;
	new = FALSE;
	if (!region->reghead->wakeup)
		region->reghead->wakeup = wake;
	for (b1 = b = blkdlist; b; b1 = b, b = b->next)
		if (b->region == region->reghead)
			break;
	if (!b)
	{
		new = TRUE;
		b = (cm_lckblkreg *)malloc(SIZEOF(cm_lckblkreg));
		b->next = 0;
		b->region = region->reghead;
		b->pass = CM_BLKPASS;
		b->lock	 = (cm_lckblklck *)malloc(SIZEOF(cm_lckblklck));
		l = (cm_lckblklck *)malloc(SIZEOF(cm_lckblklck));
		l->node = lock->nodptr;
		l->next = l->last = b->lock;
		l->sequence = lock->nodptr->sequence;
		sys_get_curr_time(&l->blktime);
		p = (cm_lckblkprc *)malloc(SIZEOF(cm_lckblkprc));
		p->user = curr_entry;
		p->blocked = lock->blocked;
		assert(lock->blocked);
		p->blk_sequence = lock->blocked->sequence;
		p->next = p->last = p;
		l->prc = p;
		b->lock->next = b->lock->last = l;
	}
	if (!blkdlist)
	{
		blkdlist = b;
		return;
	}
	if (b1 != b)
		b1->next = b;
	if (!new)
	{
		for (l1 = b->lock->next, l2 = l1->next; l2 != b->lock;l1 = l1->next, l2 = l1->next)
		{
			if (l1->node == lock->nodptr)
				break;
		}
		if (l1->node != lock->nodptr)
		{
			tl1 = (cm_lckblklck *)malloc(SIZEOF(cm_lckblklck));
			tl1->node = lock->nodptr;
			tl1->next = l1->next;
			tl1->last = l1;
			l1->next->last = tl1;
			l1->next = tl1;
			tl1->prc = 0;
			sys_get_curr_time(&tl1->blktime); /* get blking time */
			l1 = tl1;
		}
		l1->sequence = lock->nodptr->sequence;
		p1 = l1->prc;
		if (p1)
		{
			for (p2 = p1->next; p2 != l1->prc;p1 = p1->next, p2 = p1->next)
			{
				if (p1->user == curr_entry)
					break;
			}
		}
		if (!p1 || p1->user != curr_entry)
		{
			pl1 = (cm_lckblkprc *)malloc(SIZEOF(cm_lckblkprc));
			if (!p1)
			{
				l1->prc = pl1;
				pl1->next = pl1->last = pl1;
			} else
			{
				pl1->next = p1->next;
				pl1->last = p1;
				p1->next->last = pl1;
				p1->next = pl1;
			}
			pl1->user = curr_entry;
			pl1->blocked = lock->blocked;
			assert(lock->blocked);
			pl1->blk_sequence = lock->blocked->sequence;
		}
	}
}