Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/sys/rpc/clnt_dg.c b/sys/rpc/clnt_dg.c
- index a412c08..6736949 100644
- --- a/sys/rpc/clnt_dg.c
- +++ b/sys/rpc/clnt_dg.c
- @@ -189,7 +189,6 @@ clnt_dg_create(
- struct cu_data *cu = NULL; /* private data */
- struct cu_socket *cs = NULL;
- struct sockbuf *sb;
- - struct timeval now;
- struct rpc_msg call_msg;
- struct __rpc_sockinfo si;
- XDR xdrs;
- @@ -245,8 +244,7 @@ clnt_dg_create(
- cu->cu_cwnd = MAXCWND / 2;
- cu->cu_sent = 0;
- cu->cu_cwnd_wait = FALSE;
- - (void) getmicrotime(&now);
- - cu->cu_xid = __RPC_GETXID(&now);
- + cu->cu_xid = rpc_get_xid();
- call_msg.rm_xid = cu->cu_xid;
- call_msg.rm_call.cb_prog = program;
- call_msg.rm_call.cb_vers = version;
- @@ -425,7 +423,7 @@ clnt_dg_call(
- call_again:
- mtx_assert(&cs->cs_lock, MA_OWNED);
- - cu->cu_xid++;
- + cu->cu_xid = rpc_get_xid();
- xid = cu->cu_xid;
- send_again:
- @@ -872,8 +870,7 @@ clnt_dg_control(CLIENT *cl, u_int request, void *info)
- case CLSET_XID:
- /* This will set the xid of the NEXT call */
- - /* decrement by 1 as clnt_dg_call() increments once */
- - cu->cu_xid = *(uint32_t *)info - 1;
- + cu->cu_xid = *(uint32_t *)info;
- break;
- case CLGET_VERS:
- diff --git a/sys/rpc/clnt_rc.c b/sys/rpc/clnt_rc.c
- index e263278..44af710 100644
- --- a/sys/rpc/clnt_rc.c
- +++ b/sys/rpc/clnt_rc.c
- @@ -133,6 +133,7 @@ clnt_reconnect_create(
- cl->cl_auth = authnone_create();
- cl->cl_tp = NULL;
- cl->cl_netid = NULL;
- + printf("clnt_rc_create %p\n", cl);
- return (cl);
- }
- @@ -149,6 +150,7 @@ clnt_reconnect_connect(CLIENT *cl)
- CLIENT *newclient = NULL;
- mtx_lock(&rc->rc_lock);
- + printf("clnt_rc_connect %p\n", cl);
- while (rc->rc_connecting) {
- error = msleep(rc, &rc->rc_lock,
- rc->rc_intr ? PCATCH : 0, "rpcrecon", 0);
- @@ -166,6 +168,7 @@ clnt_reconnect_connect(CLIENT *cl)
- return (RPC_SUCCESS);
- }
- + printf("clnt_rc_call %p - connecting\n", cl);
- /*
- * My turn to attempt a connect. The rc_connecting variable
- * serializes the following code sequence, so it is guaranteed
- @@ -197,6 +200,7 @@ clnt_reconnect_connect(CLIENT *cl)
- (struct sockaddr *) &rc->rc_addr, rc->rc_prog, rc->rc_vers,
- rc->rc_sendsz, rc->rc_recvsz, rc->rc_intr);
- td->td_ucred = oldcred;
- + printf("clnt_rc_connect %p dg/vc_clnt=%p\n", cl, newclient);
- if (!newclient) {
- soclose(so);
- @@ -252,6 +256,7 @@ clnt_reconnect_call(
- enum clnt_stat stat;
- int tries, error;
- + printf("clnt_rc_call %p\n", cl);
- tries = 0;
- do {
- mtx_lock(&rc->rc_lock);
- @@ -295,6 +300,8 @@ clnt_reconnect_call(
- CLNT_GETERR(client, &rc->rc_err);
- }
- + printf("clnt_rc_connect %p stat=%d\n", cl, stat);
- +
- if (stat == RPC_TIMEDOUT) {
- /*
- * Check for async send misfeature for NLM
- @@ -503,6 +510,8 @@ clnt_reconnect_destroy(CLIENT *cl)
- {
- struct rc_data *rc = (struct rc_data *)cl->cl_private;
- + printf("clnt_rc_destroy %p\n", cl);
- +
- if (rc->rc_client)
- CLNT_DESTROY(rc->rc_client);
- crfree(rc->rc_ucred);
- diff --git a/sys/rpc/clnt_vc.c b/sys/rpc/clnt_vc.c
- index ea3b7d1..588ab31 100644
- --- a/sys/rpc/clnt_vc.c
- +++ b/sys/rpc/clnt_vc.c
- @@ -175,15 +175,11 @@ clnt_vc_create(
- struct ct_data *ct = NULL; /* client handle */
- struct timeval now;
- struct rpc_msg call_msg;
- - static uint32_t disrupt;
- struct __rpc_sockinfo si;
- XDR xdrs;
- int error, interrupted, one = 1, sleep_flag;
- struct sockopt sopt;
- - if (disrupt == 0)
- - disrupt = (uint32_t)(long)raddr;
- -
- cl = (CLIENT *)mem_alloc(sizeof (*cl));
- ct = (struct ct_data *)mem_alloc(sizeof (*ct));
- @@ -261,8 +257,7 @@ clnt_vc_create(
- /*
- * Initialize call message
- */
- - getmicrotime(&now);
- - ct->ct_xid = ((uint32_t)++disrupt) ^ __RPC_GETXID(&now);
- + ct->ct_xid = rpc_get_xid();
- call_msg.rm_xid = ct->ct_xid;
- call_msg.rm_direction = CALL;
- call_msg.rm_call.cb_rpcvers = RPC_MSG_VERSION;
- @@ -378,7 +373,7 @@ clnt_vc_call(
- call_again:
- mtx_assert(&ct->ct_lock, MA_OWNED);
- - ct->ct_xid++;
- + ct->ct_xid = rpc_get_xid();
- xid = ct->ct_xid;
- mtx_unlock(&ct->ct_lock);
- @@ -691,8 +686,7 @@ clnt_vc_control(CLIENT *cl, u_int request, void *info)
- break;
- case CLSET_XID:
- /* This will set the xid of the NEXT call */
- - /* decrement by 1 as clnt_vc_call() increments once */
- - ct->ct_xid = *(uint32_t *)info - 1;
- + ct->ct_xid = *(uint32_t *)info;
- break;
- case CLGET_VERS:
- /*
- diff --git a/sys/rpc/rpc_com.h b/sys/rpc/rpc_com.h
- index 290a289..4a3590a 100644
- --- a/sys/rpc/rpc_com.h
- +++ b/sys/rpc/rpc_com.h
- @@ -58,8 +58,7 @@
- #ifdef _KERNEL
- -#define __RPC_GETXID(now) ((uint32_t)curproc->p_pid ^ (uint32_t)(now)->tv_sec ^ \
- - (uint32_t)(now)->tv_usec)
- +uint32_t rpc_get_xid(void);
- #else
- diff --git a/sys/rpc/rpc_prot.c b/sys/rpc/rpc_prot.c
- index 294c4e3..1179057 100644
- --- a/sys/rpc/rpc_prot.c
- +++ b/sys/rpc/rpc_prot.c
- @@ -53,12 +53,14 @@ __FBSDID("$FreeBSD$");
- #include <sys/systm.h>
- #include <sys/kernel.h>
- #include <sys/malloc.h>
- +#include <machine/atomic.h>
- #include <rpc/types.h>
- #include <rpc/xdr.h>
- #include <rpc/auth.h>
- #include <rpc/clnt.h>
- #include <rpc/rpc_msg.h>
- +#include <rpc/rpc_com.h>
- MALLOC_DEFINE(M_RPC, "rpc", "Remote Procedure Call");
- @@ -371,3 +373,27 @@ _seterr_reply(struct rpc_msg *msg, struct rpc_err *error)
- return (stat);
- }
- +
- +uint32_t
- +rpc_get_xid(void)
- +{
- + static volatile uint32_t clnt_xid;
- + static uint32_t clnt_xit_initialized;
- +
- + struct timeval now;
- + uint32_t xid;
- +
- + if (!clnt_xit_initialized) {
- + getmicrotime(&now);
- + xid = (uint32_t) (now.tv_sec << 20 | now.tv_usec);
- + atomic_store_rel_32(&clnt_xid, xid);
- + clnt_xit_initialized = 1;
- + }
- +
- + xid = atomic_fetchadd_32(&clnt_xid,1);
- + /* Don't return zero XID. */
- + if (!xid)
- + xid = atomic_fetchadd_32(&clnt_xid,1);
- +
- + return xid;
- +}
Advertisement
Add Comment
Please, Sign In to add comment