File: gtmsource_checkforbacklog.c

package info (click to toggle)
fis-gtm 7.1-006-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 32,908 kB
  • sloc: ansic: 344,906; asm: 5,184; csh: 4,859; sh: 2,000; awk: 294; makefile: 73; sed: 13
file content (86 lines) | stat: -rw-r--r-- 2,758 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
/****************************************************************
 *								*
 * Copyright (c) 2006-2020 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 "gtm_string.h"
#include "gtm_stdio.h"

#if !defined(__MVS__) && !defined(VMS)
#include <sys/param.h>
#endif

#include <sys/time.h>
#include "gtm_inet.h"
#include <errno.h>

#ifdef VMS
#include <descrip.h> /* Required for gtmsource.h */
#endif

#include "error.h"
#include "gdsroot.h"
#include "gdsblk.h"
#include "gtm_facility.h"
#include "fileinfo.h"
#include "gdsbt.h"
#include "gdsfhead.h"
#include "filestruct.h"
#include "repl_msg.h"
#include "gtmsource.h"
#include "repl_dbg.h"
#include "repl_shutdcode.h"
#include "repl_sem.h"
#include "util.h"
#include "repl_log.h"
#include "is_proc_alive.h"

GBLREF	jnlpool_addrs_ptr_t	jnlpool;
GBLREF	gtmsource_options_t	gtmsource_options;

seq_num gtmsource_checkforbacklog(void)
{
	seq_num			seq_num, heartbeat_jnl_seqno, jnl_seqno, read_jnl_seqno, backlog_count = 0;
	gtmsource_local_ptr_t	gtmsourcelocal_ptr;
	int4	 		index;
	boolean_t		srv_alive;
	uint4			gtmsource_pid;

	jnl_seqno = jnlpool->jnlpool_ctl->jnl_seqno;
	if (NULL != jnlpool->gtmsource_local)
		gtmsourcelocal_ptr = jnlpool->gtmsource_local;
	else
		gtmsourcelocal_ptr = &jnlpool->gtmsource_local_array[0];
	for (index = 0; index < NUM_GTMSRC_LCL; index++, gtmsourcelocal_ptr++)
	{
		if ('\0' == gtmsourcelocal_ptr->secondary_instname[0])
		{
			assert(NULL == jnlpool->gtmsource_local);
			continue;
		}
		gtmsource_pid = gtmsourcelocal_ptr->gtmsource_pid;
		/* 0 == gtmsource_pid evaluates to TRUE when a Source Server has been shut down */
		if ((NULL == jnlpool->gtmsource_local) && (0 == gtmsource_pid))
			continue;
		read_jnl_seqno = gtmsourcelocal_ptr->read_jnl_seqno;
		heartbeat_jnl_seqno = gtmsourcelocal_ptr->heartbeat_jnl_seqno;
		/* jnl_seqno >= read_jnl_seqno is the most common case; see gtmsource_readpool() for when the rare case can occur */
		seq_num = (jnl_seqno >= read_jnl_seqno) ? jnl_seqno - read_jnl_seqno : 0;
		/* read_jnl_seqno is 1 for empty databases */
		if ((seq_num == 0) && (read_jnl_seqno != 1))
			seq_num = (read_jnl_seqno > heartbeat_jnl_seqno) ? 1 : 0;
		backlog_count += seq_num;
		if (NULL != jnlpool->gtmsource_local)
			break;
	}
	return backlog_count; /* backlog_count is non-zero when any one Source Server has a backlog and -INST is not specified. */
}