File: op_decrlock.c

package info (click to toggle)
fis-gtm 6.3-014-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 36,680 kB
  • sloc: ansic: 333,039; asm: 5,180; csh: 4,956; sh: 1,924; awk: 291; makefile: 66; sed: 13
file content (83 lines) | stat: -rwxr-xr-x 2,262 bytes parent folder | download | duplicates (2)
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
/****************************************************************
 *								*
 * Copyright (c) 2001-2017 Fidelity National Information	*
 * Services, Inc. and/or its subsidiaries. All rights reserved.	*
 *								*
 *	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 "iotimer.h"
#include "locklits.h"
#include "tp_frame.h"
#include "op.h"
#include "mlk_pvtblk_delete.h"
#include "mlk_unlock.h"
#include "gvcmx.h"
#include "lckclr.h"

GBLREF boolean_t	gtcm_connection;
GBLREF unsigned short	lks_this_cmd;
GBLREF mlk_pvtblk	*mlk_pvt_root;
GBLREF bool		remlkreq;
GBLREF unsigned char	cm_action;
GBLREF tp_frame		*tp_pointer;

error_def(ERR_TPLOCK);

int	op_decrlock(mval *timeout)
{
	int		count;
	mlk_pvtblk	**prior;
	void		lckclr(void);

	lckclr();
	if (tp_pointer)
	{
		prior = &mlk_pvt_root;
		for (count = 0; count < lks_this_cmd; count++)
		{
			/* if there were any old locks before TSTART, they can't be  unlocked */
			if ((*prior)->granted && (*prior)->tp &&
				(*prior)->tp->level > (*prior)->level - (*prior)->translev)
				rts_error_csa(NULL, VARLSTCNT(1) ERR_TPLOCK);
			prior = &((*prior)->next);
		}
	}
	prior = &mlk_pvt_root;
	for (count = 0; count < lks_this_cmd; count++)
	{
		if (prior)
		{
			if (!(*prior)->granted)
			{	/* if entry was never granted, delete list entry */
				mlk_pvtblk_delete(prior);
			}
			else
			{
				(*prior)->level -= (*prior)->translev > (*prior)->level ? (*prior)->level : (*prior)->translev;
				if (!(*prior)->zalloc && (0 == (*prior)->level))
				{
					mlk_unlock(*prior);
					mlk_pvtblk_delete(prior);
				}
				else
					prior = &((*prior)->next);
			}
		}
	}
	if (gtcm_connection && remlkreq)
	{
		cm_action = INCREMENTAL;
		gvcmx_unlock(0, TRUE, INCREMENTAL);
		remlkreq = FALSE;
	}
	lks_this_cmd = 0;	/* reset so we can check whether an extrinsic is trying to nest a LOCK operation */
	return TRUE;	/* return TRUE unconditionally (since this is a timed unlock) so $TEST gets set to 1 as per M-standard */
}