aboutsummaryrefslogtreecommitdiff
path: root/sunrpc/thrsvc.c
diff options
context:
space:
mode:
authorZack Weinberg <zackw@panix.com>2017-06-08 15:39:03 -0400
committerZack Weinberg <zackw@panix.com>2017-06-08 15:39:03 -0400
commit5046dbb4a7eba5eccfd258f92f4735c9ffc8d069 (patch)
tree4470480d904b65cf14ca524f96f79eca818c3eaf /sunrpc/thrsvc.c
parent199fc19d3aaaf57944ef036e15904febe877fc93 (diff)
downloadglibc-zack/build-layout-experiment.tar
glibc-zack/build-layout-experiment.tar.gz
glibc-zack/build-layout-experiment.tar.bz2
glibc-zack/build-layout-experiment.zip
Prepare for radical source tree reorganization.zack/build-layout-experiment
All top-level files and directories are moved into a temporary storage directory, REORG.TODO, except for files that will certainly still exist in their current form at top level when we're done (COPYING, COPYING.LIB, LICENSES, NEWS, README), all old ChangeLog files (which are moved to the new directory OldChangeLogs, instead), and the generated file INSTALL (which is just deleted; in the new order, there will be no generated files checked into version control).
Diffstat (limited to 'sunrpc/thrsvc.c')
-rw-r--r--sunrpc/thrsvc.c109
1 files changed, 0 insertions, 109 deletions
diff --git a/sunrpc/thrsvc.c b/sunrpc/thrsvc.c
deleted file mode 100644
index 63cfbf9810..0000000000
--- a/sunrpc/thrsvc.c
+++ /dev/null
@@ -1,109 +0,0 @@
-#include <pthread.h>
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-#include <rpc/rpc.h>
-#include <arpa/inet.h>
-
-#define PROGNUM 1234
-#define VERSNUM 1
-#define PROCNUM 1
-#define PROCQUIT 2
-
-static int exitcode;
-
-struct rpc_arg
-{
- CLIENT *client;
- u_long proc;
-};
-
-static void
-dispatch(struct svc_req *request, SVCXPRT *xprt)
-{
- svc_sendreply(xprt, (xdrproc_t)xdr_void, 0);
- if (request->rq_proc == PROCQUIT)
- exit (0);
-}
-
-static void
-test_one_call (struct rpc_arg *a)
-{
- struct timeval tout = { 60, 0 };
- enum clnt_stat result;
-
- printf ("test_one_call: ");
- result = clnt_call (a->client, a->proc,
- (xdrproc_t) xdr_void, 0,
- (xdrproc_t) xdr_void, 0, tout);
- if (result == RPC_SUCCESS)
- puts ("success");
- else
- {
- clnt_perrno (result);
- putchar ('\n');
- exitcode = 1;
- }
-}
-
-static void *
-thread_wrapper (void *arg)
-{
- struct rpc_arg a;
-
- a.client = (CLIENT *)arg;
- a.proc = PROCNUM;
- test_one_call (&a);
- a.client = (CLIENT *)arg;
- a.proc = PROCQUIT;
- test_one_call (&a);
- return 0;
-}
-
-int
-main (void)
-{
- pthread_t tid;
- pid_t pid;
- int err;
- SVCXPRT *svx;
- CLIENT *clnt;
- struct sockaddr_in sin;
- struct timeval wait = { 5, 0 };
- int sock = RPC_ANYSOCK;
- struct rpc_arg a;
-
- svx = svcudp_create (RPC_ANYSOCK);
- svc_register (svx, PROGNUM, VERSNUM, dispatch, 0);
-
- pid = fork ();
- if (pid == -1)
- {
- perror ("fork");
- return 1;
- }
- if (pid == 0)
- svc_run ();
-
- inet_aton ("127.0.0.1", &sin.sin_addr);
- sin.sin_port = htons (svx->xp_port);
- sin.sin_family = AF_INET;
-
- clnt = clntudp_create (&sin, PROGNUM, VERSNUM, wait, &sock);
-
- a.client = clnt;
- a.proc = PROCNUM;
-
- /* Test in this thread */
- test_one_call (&a);
-
- /* Test in a child thread */
- err = pthread_create (&tid, 0, thread_wrapper, (void *) clnt);
- if (err)
- fprintf (stderr, "pthread_create: %s\n", strerror (err));
- err = pthread_join (tid, 0);
- if (err)
- fprintf (stderr, "pthread_join: %s\n", strerror (err));
-
- return exitcode;
-}