lib/libc/tests/rpc: Correctly set timeout

The rpc_control() API does not accept the CLCR_SET_RPCB_TIMEOUT command,
it only accepts RPC_SVC_CONNMAXREC_GET/RPC_SVC_CONNMAXREC_SET, so it was
not doing anything.
Instead of incorrectly calling this API, use clnt_create_timed() instead.

I noticed this because the test was timing out after 120s in the CheriBSD CI.

Reviewed By:	ngie
Differential Revision: https://reviews.freebsd.org/D28478
This commit is contained in:
Alex Richardson 2021-02-13 13:52:59 +00:00
parent 0ff1014944
commit 90b5fc9583

View File

@ -72,11 +72,21 @@ onehost(const char *host, const char *transp)
*/ */
tv.tv_sec = 0; tv.tv_sec = 0;
tv.tv_usec = 500000; tv.tv_usec = 500000;
#ifdef __FreeBSD__
/*
* FreeBSD does not allow setting the timeout using __rpc_control,
* but does have clnt_create_timed() that allows passing a timeout.
*/
if ((clnt = clnt_create_timed(host, RPCBPROG, RPCBVERS, transp,
&tv)) == NULL)
SKIPX(, "clnt_create (%s)", clnt_spcreateerror(""));
#else
#define CLCR_SET_RPCB_TIMEOUT 2 #define CLCR_SET_RPCB_TIMEOUT 2
__rpc_control(CLCR_SET_RPCB_TIMEOUT, &tv); __rpc_control(CLCR_SET_RPCB_TIMEOUT, &tv);
if ((clnt = clnt_create(host, RPCBPROG, RPCBVERS, transp)) == NULL) if ((clnt = clnt_create(host, RPCBPROG, RPCBVERS, transp)) == NULL)
SKIPX(, "clnt_create (%s)", clnt_spcreateerror("")); SKIPX(, "clnt_create (%s)", clnt_spcreateerror(""));
#endif
tv.tv_sec = 1; tv.tv_sec = 1;
tv.tv_usec = 0; tv.tv_usec = 0;