X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=sunrpc%2Fclnt_tcp.c;h=6825ca57ee590d7dc33b4240b46836951d662fac;hb=bb87237534eee688ad8c8eab10e433ae6238fc03;hp=be74f0dc0e5dbc5267be0afd33bf739613316f90;hpb=099a6fbd8a703336c73f6bb7396b77e4a6e31a3e;p=platform%2Fupstream%2Fglibc.git diff --git a/sunrpc/clnt_tcp.c b/sunrpc/clnt_tcp.c index be74f0d..6825ca5 100644 --- a/sunrpc/clnt_tcp.c +++ b/sunrpc/clnt_tcp.c @@ -54,10 +54,16 @@ static char sccsid[] = "@(#)clnt_tcp.c 1.37 87/10/05 Copyr 1984 Sun Micro"; #include #include #include +#include #include #include #include #include +#ifdef USE_IN_LIBIO +# include +#endif + +extern u_long _create_xid (void); #define MCALL_MSG_SIZE 24 @@ -85,7 +91,7 @@ static bool_t clnttcp_freeres (CLIENT *, xdrproc_t, caddr_t); static bool_t clnttcp_control (CLIENT *, int, char *); static void clnttcp_destroy (CLIENT *); -static struct clnt_ops tcp_ops = +static const struct clnt_ops tcp_ops = { clnttcp_call, clnttcp_abort, @@ -114,24 +120,17 @@ clnttcp_create (struct sockaddr_in *raddr, u_long prog, u_long vers, int *sockp, u_int sendsz, u_int recvsz) { CLIENT *h; - struct ct_data *ct = (struct ct_data *) mem_alloc (sizeof (*ct)); - struct timeval now; + struct ct_data *ct; struct rpc_msg call_msg; h = (CLIENT *) mem_alloc (sizeof (*h)); - if (h == NULL) - { - (void) fprintf (stderr, _("clnttcp_create: out of memory\n")); - rpc_createerr.cf_stat = RPC_SYSTEMERROR; - rpc_createerr.cf_error.re_errno = errno; - goto fooy; - } - /* ct = (struct ct_data *) mem_alloc (sizeof (*ct)); */ - if (ct == NULL) + ct = (struct ct_data *) mem_alloc (sizeof (*ct)); + if (h == NULL || ct == NULL) { - (void) fprintf (stderr, _("clnttcp_create: out of memory\n")); - rpc_createerr.cf_stat = RPC_SYSTEMERROR; - rpc_createerr.cf_error.re_errno = errno; + struct rpc_createerr *ce = &get_rpc_createerr (); + (void) __fxprintf (NULL, "%s: %s", __func__, _("out of memory\n")); + ce->cf_stat = RPC_SYSTEMERROR; + ce->cf_error.re_errno = ENOMEM; goto fooy; } @@ -155,16 +154,17 @@ clnttcp_create (struct sockaddr_in *raddr, u_long prog, u_long vers, */ if (*sockp < 0) { - *sockp = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP); + *sockp = __socket (AF_INET, SOCK_STREAM, IPPROTO_TCP); (void) bindresvport (*sockp, (struct sockaddr_in *) 0); if ((*sockp < 0) - || (connect (*sockp, (struct sockaddr *) raddr, - sizeof (*raddr)) < 0)) + || (__connect (*sockp, (struct sockaddr *) raddr, + sizeof (*raddr)) < 0)) { - rpc_createerr.cf_stat = RPC_SYSTEMERROR; - rpc_createerr.cf_error.re_errno = errno; + struct rpc_createerr *ce = &get_rpc_createerr (); + ce->cf_stat = RPC_SYSTEMERROR; + ce->cf_error.re_errno = errno; if (*sockp >= 0) - (void) close (*sockp); + (void) __close (*sockp); goto fooy; } ct->ct_closeit = TRUE; @@ -185,8 +185,7 @@ clnttcp_create (struct sockaddr_in *raddr, u_long prog, u_long vers, /* * Initialize call message */ - (void) gettimeofday (&now, (struct timezone *) 0); - call_msg.rm_xid = getpid () ^ now.tv_sec ^ now.tv_usec; + call_msg.rm_xid = _create_xid (); call_msg.rm_direction = CALL; call_msg.rm_call.cb_rpcvers = RPC_MSG_VERSION; call_msg.rm_call.cb_prog = prog; @@ -195,13 +194,13 @@ clnttcp_create (struct sockaddr_in *raddr, u_long prog, u_long vers, /* * pre-serialize the static part of the call msg and stash it away */ - xdrmem_create (&(ct->ct_xdrs), ct->ct_mcall, MCALL_MSG_SIZE, - XDR_ENCODE); - if (!xdr_callhdr (&(ct->ct_xdrs), &call_msg)) + INTUSE(xdrmem_create) (&(ct->ct_xdrs), ct->ct_mcall, MCALL_MSG_SIZE, + XDR_ENCODE); + if (!INTUSE(xdr_callhdr) (&(ct->ct_xdrs), &call_msg)) { if (ct->ct_closeit) { - (void) close (*sockp); + (void) __close (*sockp); } goto fooy; } @@ -212,11 +211,11 @@ clnttcp_create (struct sockaddr_in *raddr, u_long prog, u_long vers, * Create a client handle which uses xdrrec for serialization * and authnone for authentication. */ - xdrrec_create (&(ct->ct_xdrs), sendsz, recvsz, - (caddr_t) ct, readtcp, writetcp); - h->cl_ops = &tcp_ops; + INTUSE(xdrrec_create) (&(ct->ct_xdrs), sendsz, recvsz, + (caddr_t) ct, readtcp, writetcp); + h->cl_ops = (struct clnt_ops *) &tcp_ops; h->cl_private = (caddr_t) ct; - h->cl_auth = authnone_create (); + h->cl_auth = INTUSE(authnone_create) (); return h; fooy: @@ -227,6 +226,7 @@ fooy: mem_free ((caddr_t) h, sizeof (CLIENT)); return ((CLIENT *) NULL); } +INTDEF (clnttcp_create) static enum clnt_stat clnttcp_call (h, proc, xdr_args, args_ptr, xdr_results, results_ptr, timeout) @@ -252,8 +252,8 @@ clnttcp_call (h, proc, xdr_args, args_ptr, xdr_results, results_ptr, timeout) } shipnow = - (xdr_results == (xdrproc_t) 0 && timeout.tv_sec == 0 - && timeout.tv_usec == 0) ? FALSE : TRUE; + (xdr_results == (xdrproc_t) 0 && ct->ct_wait.tv_sec == 0 + && ct->ct_wait.tv_usec == 0) ? FALSE : TRUE; call_again: xdrs->x_op = XDR_ENCODE; @@ -266,17 +266,17 @@ call_again: { if (ct->ct_error.re_status == RPC_SUCCESS) ct->ct_error.re_status = RPC_CANTENCODEARGS; - (void) xdrrec_endofrecord (xdrs, TRUE); + (void) INTUSE(xdrrec_endofrecord) (xdrs, TRUE); return (ct->ct_error.re_status); } - if (!xdrrec_endofrecord (xdrs, shipnow)) + if (!INTUSE(xdrrec_endofrecord) (xdrs, shipnow)) return ct->ct_error.re_status = RPC_CANTSEND; if (!shipnow) return RPC_SUCCESS; /* * Hack to provide rpc-based message passing */ - if (timeout.tv_sec == 0 && timeout.tv_usec == 0) + if (ct->ct_wait.tv_sec == 0 && ct->ct_wait.tv_usec == 0) { return ct->ct_error.re_status = RPC_TIMEDOUT; } @@ -290,17 +290,17 @@ call_again: { reply_msg.acpted_rply.ar_verf = _null_auth; reply_msg.acpted_rply.ar_results.where = NULL; - reply_msg.acpted_rply.ar_results.proc = (xdrproc_t)xdr_void; - if (!xdrrec_skiprecord (xdrs)) + reply_msg.acpted_rply.ar_results.proc = (xdrproc_t)INTUSE(xdr_void); + if (!INTUSE(xdrrec_skiprecord) (xdrs)) return (ct->ct_error.re_status); /* now decode and validate the response header */ - if (!xdr_replymsg (xdrs, &reply_msg)) + if (!INTUSE(xdr_replymsg) (xdrs, &reply_msg)) { if (ct->ct_error.re_status == RPC_SUCCESS) continue; return ct->ct_error.re_status; } - if (reply_msg.rm_xid == x_id) + if ((u_int32_t) reply_msg.rm_xid == (u_int32_t) x_id) break; } @@ -324,7 +324,8 @@ call_again: if (reply_msg.acpted_rply.ar_verf.oa_base != NULL) { xdrs->x_op = XDR_FREE; - (void) xdr_opaque_auth (xdrs, &(reply_msg.acpted_rply.ar_verf)); + (void) INTUSE(xdr_opaque_auth) (xdrs, + &(reply_msg.acpted_rply.ar_verf)); } } /* end successful completion */ else @@ -454,7 +455,7 @@ clnttcp_destroy (CLIENT *h) if (ct->ct_closeit) { - (void) close (ct->ct_sock); + (void) __close (ct->ct_sock); } XDR_DESTROY (&(ct->ct_xdrs)); mem_free ((caddr_t) ct, sizeof (struct ct_data)); @@ -496,7 +497,7 @@ readtcp (char *ctptr, char *buf, int len) } break; } - switch (len = read (ct->ct_sock, buf, len)) + switch (len = __read (ct->ct_sock, buf, len)) { case 0: @@ -522,7 +523,7 @@ writetcp (char *ctptr, char *buf, int len) for (cnt = len; cnt > 0; cnt -= i, buf += i) { - if ((i = write (ct->ct_sock, buf, cnt)) == -1) + if ((i = __write (ct->ct_sock, buf, cnt)) == -1) { ct->ct_error.re_errno = errno; ct->ct_error.re_status = RPC_CANTSEND;