File: omi_prc_unlk.c

package info (click to toggle)
fis-gtm 6.3-007-1
  • links: PTS, VCS
  • area: main
  • in suites: 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 (95 lines) | stat: -rwxr-xr-x 2,126 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
/****************************************************************
 *								*
 *	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.	*
 *								*
 ****************************************************************/

/*
 *  omi_prc_unlk.c ---
 *
 *	Process an UNLOCK request.
 *
 */

#ifndef lint
static char rcsid[] = "$Header:$";
#endif

#include "mdef.h"
#include "omi.h"
#include "error.h"
#include "mlkdef.h"
#include "mlk_pvtblk_delete.h"
#include "mlk_unlock.h"


int omi_prc_unlk(omi_conn *cptr, char *xend, char *buff, char *bend)
{
	GBLREF int		 omi_pid;
	GBLREF mlk_pvtblk	*mlk_pvt_root;

	omi_li		 li;
	int			 rv;
	omi_si		 si;
	mlk_pvtblk		*next, **prior;

	/*  Global Ref */
	OMI_LI_READ(&li, cptr->xptr);
	/*  Condition handler for DBMS operations */
	ESTABLISH_RET(omi_dbms_ch,0);

	/*  Clean up dead locks in private list */
	for (prior = &mlk_pvt_root; *prior; )
	{
		if (!(*prior)->granted || !(*prior)->nodptr || (*prior)->nodptr->owner != omi_pid)
			mlk_pvtblk_delete(prior);
		else
		{
			(*prior)->trans = 0;
			prior = &(*prior)->next;
		}
	}

	rv = omi_lkextnam(cptr, li.value, cptr->xptr, cptr->xptr + li.value);
	/*  If true, there was an error finding the global reference in the DBMS */
	if (rv <= 0) {
		REVERT;
		return rv;
	}
	cptr->xptr += li.value;

	/*  Client's $JOB */
	OMI_SI_READ(&si, cptr->xptr);
	cptr->xptr += si.value;

	/*  Bounds checking */
	if (cptr->xptr > xend) {
		REVERT;
		return -OMI_ER_PR_INVMSGFMT;
	}

	mlk_pvt_root->trans = 0;
	if (mlk_pvt_root->nodptr && mlk_pvt_root->nodptr->owner == omi_pid)
	{
		assert(mlk_pvt_root->nodptr->auxowner == (UINTPTR_T)cptr);
		if (--mlk_pvt_root->level == 0)
			mlk_unlock(mlk_pvt_root);
	} else
		mlk_pvt_root->level = 0;

	/*  Clean up after the (now dead) lock */
	if (!mlk_pvt_root->level)
	{
		next = mlk_pvt_root->next;
		free(mlk_pvt_root);
		mlk_pvt_root = next;
	}

	REVERT;
	return 0;
}