ReactOS 0.4.15-dev-5667-ged97270
clnt_simple.c File Reference
#include <wintirpc.h>
#include <reentrant.h>
#include <stdio.h>
#include <errno.h>
#include <rpc/rpc.h>
#include <string.h>
#include <stdlib.h>
#include <fcntl.h>
#include <rpc/clnt.h>
Include dependency graph for clnt_simple.c:

Go to the source code of this file.

Classes

struct  rpc_call_private
 

Macros

#define MAXHOSTNAMELEN   64
 
#define NETIDLEN   32
 

Functions

static void rpc_call_destroy (void *)
 
enum clnt_stat rpc_call (char *host, rpcprog_t prognum, rpcvers_t versnum, rpcproc_t procnum, xdrproc_t inproc, const char *in, xdrproc_t outproc, char *out, const char *nettype) const
 

Macro Definition Documentation

◆ MAXHOSTNAMELEN

#define MAXHOSTNAMELEN   64

Definition at line 53 of file clnt_simple.c.

◆ NETIDLEN

#define NETIDLEN   32

Definition at line 57 of file clnt_simple.c.

Function Documentation

◆ rpc_call()

enum clnt_stat rpc_call ( char host,
rpcprog_t  prognum,
rpcvers_t  versnum,
rpcproc_t  procnum,
xdrproc_t  inproc,
const char in,
xdrproc_t  outproc,
char out,
const char nettype 
) const

Definition at line 92 of file clnt_simple.c.

101{
102 struct rpc_call_private *rcp = (struct rpc_call_private *) 0;
103 enum clnt_stat clnt_stat;
104 struct timeval timeout, tottimeout;
106 extern mutex_t tsd_lock;
107
108 if (rpc_call_key == -1) {
110 if (rpc_call_key == -1)
113 }
115 if (rcp == NULL) {
116 rcp = malloc(sizeof (*rcp));
117 if (rcp == NULL) {
119 rpc_createerr.cf_error.re_errno = errno;
120 return (rpc_createerr.cf_stat);
121 }
122 thr_setspecific(rpc_call_key, (void *) rcp);
123 rcp->valid = 0;
124 rcp->client = NULL;
125 }
126 if ((nettype == NULL) || (nettype[0] == 0))
127 nettype = "netpath";
128 if (!(rcp->valid && rcp->pid == getpid() &&
129 (rcp->prognum == prognum) &&
130 (rcp->versnum == versnum) &&
131 (!strcmp(rcp->host, host)) &&
132 (!strcmp(rcp->nettype, nettype)))) {
133 int fd;
134
135 rcp->valid = 0;
136 if (rcp->client)
137 CLNT_DESTROY(rcp->client);
138 /*
139 * Using the first successful transport for that type
140 */
142 rcp->pid = getpid();
143 if (rcp->client == NULL) {
144 return (rpc_createerr.cf_stat);
145 }
146 /*
147 * Set time outs for connectionless case. Do it
148 * unconditionally. Faster than doing a t_getinfo()
149 * and then doing the right thing.
150 */
151 timeout.tv_usec = 0;
152 timeout.tv_sec = 5;
153 (void) CLNT_CONTROL(rcp->client,
154 CLSET_RETRY_TIMEOUT, (char *)(void *)&timeout);
155 if (CLNT_CONTROL(rcp->client, CLGET_FD, (char *)(void *)&fd))
156 ; // XXX fcntl(fd, F_SETFD, 1); /* make it "close on exec" */
157 rcp->prognum = prognum;
158 rcp->versnum = versnum;
159 if ((strlen(host) < (size_t)MAXHOSTNAMELEN) &&
161 (void) strcpy(rcp->host, host);
162 (void) strcpy(rcp->nettype, nettype);
163 rcp->valid = 1;
164 } else {
165 rcp->valid = 0;
166 }
167 } /* else reuse old client */
168 tottimeout.tv_sec = 25;
169 tottimeout.tv_usec = 0;
170
171 /* LINTED const castaway */
172 clnt_stat = CLNT_CALL(rcp->client, procnum, inproc, (char *) in,
173 outproc, out, tottimeout);
174 /*
175 * if call failed, empty cache
176 */
177 if (clnt_stat != RPC_SUCCESS)
178 rcp->valid = 0;
179 return (clnt_stat);
180}
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
#define CLGET_FD
Definition: clnt.h:249
#define CLSET_RETRY_TIMEOUT
Definition: clnt.h:265
#define CLNT_CALL(rh, proc, xargs, argsp, xres, resp, secs)
Definition: clnt.h:199
#define CLNT_CONTROL(cl, rq, in)
Definition: clnt.h:240
#define CLNT_DESTROY(rh)
Definition: clnt.h:275
CLIENT * clnt_create(const char *hostname, const rpcprog_t prog, const rpcvers_t vers, const char *nettype)
Definition: clnt_generic.c:179
static void rpc_call_destroy(void *)
Definition: clnt_simple.c:73
#define NETIDLEN
Definition: clnt_simple.c:57
#define MAXHOSTNAMELEN
Definition: clnt_simple.c:53
clnt_stat
Definition: clnt_stat.h:21
@ RPC_SUCCESS
Definition: clnt_stat.h:22
@ RPC_SYSTEMERROR
Definition: clnt_stat.h:43
#define malloc
Definition: debug_ros.c:4
#define NULL
Definition: types.h:112
__kernel_size_t size_t
Definition: linux.h:237
GLuint in
Definition: glext.h:9616
thread_key_t rpc_call_key
Definition: mt_misc.c:90
mutex_t tsd_lock
Definition: mt_misc.c:86
static const struct timeval tottimeout
Definition: pmap_getport.c:44
#define thr_setspecific(k, p)
Definition: reentrant.h:146
#define mutex_lock(m)
Definition: reentrant.h:128
#define thr_getspecific(k)
Definition: reentrant.h:147
#define mutex_unlock(m)
Definition: reentrant.h:129
#define thr_keycreate(k, d)
Definition: reentrant.h:144
#define thread_key_t
Definition: reentrant.h:124
static FILE * out
Definition: regtests2xml.c:44
#define errno
Definition: errno.h:18
static int fd
Definition: io.c:51
Definition: module.h:446
char host[MAXHOSTNAMELEN]
Definition: clnt_simple.c:66
char nettype[NETIDLEN]
Definition: clnt_simple.c:67
rpcvers_t versnum
Definition: clnt_simple.c:65
rpcprog_t prognum
Definition: clnt_simple.c:64
CLIENT * client
Definition: clnt_simple.c:62
struct rpc_err cf_error
Definition: clnt.h:497
enum clnt_stat cf_stat
Definition: clnt.h:496
Definition: dhcpd.h:245
char * host
Definition: whois.c:55
#define getpid
Definition: wintirpc.h:52

◆ rpc_call_destroy()

static void rpc_call_destroy ( void vp)
static

Definition at line 73 of file clnt_simple.c.

74{
75 struct rpc_call_private *rcp = (struct rpc_call_private *)vp;
76
77 if (rcp) {
78 if (rcp->client)
79 CLNT_DESTROY(rcp->client);
80 free(rcp);
81 }
82}
#define free
Definition: debug_ros.c:5

Referenced by rpc_call().