File: bfselect.c

package info (click to toggle)
lam 7.1.2-1.4
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 54,608 kB
  • ctags: 17,034
  • sloc: ansic: 156,264; sh: 9,976; cpp: 7,699; makefile: 5,589; perl: 476; fortran: 260; asm: 83
file content (106 lines) | stat: -rw-r--r-- 2,728 bytes parent folder | download | duplicates (10)
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
/*
 * Copyright (c) 2001-2002 The Trustees of Indiana University.  
 *                         All rights reserved.
 * Copyright (c) 1998-2001 University of Notre Dame. 
 *                         All rights reserved.
 * Copyright (c) 1994-1998 The Ohio State University.  
 *                         All rights reserved.
 * 
 * This file is part of the LAM/MPI software package.  For license
 * information, see the LICENSE file in the top level directory of the
 * LAM/MPI source distribution.
 * 
 * $HEADER$
 *	Ohio Trollius
 *	Copyright 1995 The Ohio State University
 *	GDB
 *
 *	$Log: bfselect.c,v $
 *	Revision 6.3  2002/10/09 20:59:49  brbarret
 *	* Update tree to match the latest, greatest, license for LAM/MPI.  And this
 *	  one is even done properly :)
 *
 *	Revision 6.2  1999/05/26 18:22:02  kmeyer1
 *	added copyright
 *	
 *	Revision 6.1  1996/11/23 23:56:34  nevin
 *	Ohio Release
 *	
 * Revision 6.0  96/02/29  13:57:53  gdburns
 * Ohio Release
 * 
 *	Function:	- blocking probe on multiple SQL sync points
 *	Accepts:	- synchronization array
 *			- array size
 *			- additional flags
 *	Returns:	- index of matched sync pt or ERROR
 *			- updates bfk_type with probed sync point
 *			- does not return probed length
 */

#include <bfreq.h>
#include <events.h>
#include <net.h>
#include <terror.h>
#include <typical.h>

int
bfselect(pbfk, nbfk, flags, sync_index)

struct bfsync		*pbfk;
int			nbfk;
int4			flags;
int			*sync_index;

{
	struct bfreq	*req;		/* bufferd request */
	struct nmsg	nhreq;		/* bufferd req msg */
	struct nmsg	nhprobe;	/* probed message */
	int		i;

	if ((nbfk < 0) || (nbfk > (MAXNMSGLEN / sizeof(struct bfsync)))) {
		errno = EINVAL;
		return(LAMERROR);
	}
/*
 * Send a query message to the buffer.
 */
	req = (struct bfreq *) nhreq.nh_data;
	req->bfq_req = BFQRECV;
	req->bfq_event = pbfk->bfk_event;
	req->bfq_type = pbfk->bfk_type;
	req->bfq_flags = flags | KSYNCSQL;
/*
 * Set up bufferd request message.
 */
	nhreq.nh_dl_event = EVBUFFERD;
	nhreq.nh_node = LOCAL;
	nhreq.nh_event = EVBUFFERD;
	nhreq.nh_type = DLCTL;
	nhreq.nh_flags = flags & KTRACE;
	nhreq.nh_length = (nbfk == 1) ? 0 : sizeof(struct bfsync) * nbfk;
	nhreq.nh_msg = (char *) pbfk;

	nhprobe.nh_flags = KPROBE | KSYNCSQL | (flags & KTRACE);
	nhprobe.nh_msg = 0;
/*
 * Receive probes using the full SQL wildcard until a probe
 * matches one of the sync points.
 */
	for (;;) {
		nhprobe.nh_event =  req->bfq_event | KEVENTHI;
		nhprobe.nh_type = KTYPEHI | KTYPELO;
		nhprobe.nh_length = MAXNMSGLEN;

		if (dsfr(&nhreq, &nhprobe)) return(LAMERROR);

		for (i = 0; i < nbfk; ++i) {

			if (bfk_nh_cmp(pbfk + i, &nhprobe)) {
				pbfk[i].bfk_type = nhprobe.nh_type;
				*sync_index = i;
				return(0);
			}
		}
	}
}