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 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140
|
/*
* 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 1996 The Ohio State University
* GDB
*
* $Id: rfstate.c,v 6.7 2002/10/09 20:57:14 brbarret Exp $
*
* Function: - gathers state from a remote filed
* - receives file descriptors from
* filed until reply code is EEOF
*
* Accepts: - target node ID
* - ptr to file descriptor table
* - # of entries in table
*
* Returns: - number of replied descriptors or ERROR
*/
#include <string.h>
#include <unistd.h>
#include <events.h>
#include <freq.h>
#include <ksignal.h>
#include <net.h>
#include <terror.h>
#include <typical.h>
#include <t_types.h>
#include <etc_misc.h>
/*
* local variables
*/
static char hole[MAXNMSGLEN];
int
lam_rfstate(int nodeid, struct fstate ftbl[], int maxcount)
{
struct nmsg nhead; /* network message desc. */
struct freq *request; /* filed request */
struct freply *reply; /* filed reply */
struct fstate *fhole; /* ptr incoming file descs */
int count; /* # descs in this msg */
int totcount; /* total # replied descs */
int i; /* favourite index */
int mask; /* signal mask */
totcount = 0;
fhole = (struct fstate *) hole;
request = (struct freq *) nhead.nh_data;
reply = (struct freply *) nhead.nh_data;
request->fq_src_node = (nodeid == LOCAL) ? nodeid : getnodeid();
request->fq_src_event = -lam_getpid();
request->fq_req = FQSTATE;
nhead.nh_node = nodeid;
nhead.nh_event = EVFILED;
nhead.nh_type = 0;
nhead.nh_flags = 0;
nhead.nh_length = 0;
nhead.nh_msg = (char *) 0;
mask = ksigblock(sigmask(SIGUDIE) | sigmask(SIGARREST));
if (nsend(&nhead)) {
ksigsetmask(mask);
return(LAMERROR);
}
nhead.nh_event = -lam_getpid();
nhead.nh_msg = hole;
do {
nhead.nh_length = MAXNMSGLEN;
if (nrecv(&nhead)) {
ksigsetmask(mask);
return(LAMERROR);
}
count = nhead.nh_length / sizeof(struct fstate);
totcount += count;
if (maxcount > 0) {
/*
* Convert byte ordering (sigh).
*/
for (i = 0; i < count; ++i) {
fhole[i].fs_tfd = ttol(fhole[i].fs_tfd);
fhole[i].fs_tflags = ttol(fhole[i].fs_tflags);
fhole[i].fs_flow = ttol(fhole[i].fs_flow);
fhole[i].fs_count = ttol(fhole[i].fs_count);
fhole[i].fs_src_node =
ttol(fhole[i].fs_src_node);
fhole[i].fs_src_event =
ttol(fhole[i].fs_src_event);
}
if (count > maxcount) count = maxcount;
memcpy((char *) ftbl, hole,
count * sizeof(struct fstate));
maxcount -= count;
ftbl += count;
}
} while (! reply->fr_errno);
ksigsetmask(mask);
if (reply->fr_errno == EEOF) {
return(totcount);
} else {
errno = reply->fr_errno;
return(LAMERROR);
}
}
#if 0
/* Down with backwards compatability! */
/*
* backwards compatibility
*/
int rfstate(nodeid, ftbl, maxcount) int nodeid, maxcount; struct fstate ftbl[];
{ return(lam_rfstate(nodeid, ftbl, maxcount)); }
#endif
|