提交 d3fe5ea7 编写于 作者: C Chuck Lever 提交者: J. Bruce Fields

NLM: Refactor make_socks() function

Clean up: extract common logic in NLM's make_socks() function
into a helper.
Signed-off-by: NChuck Lever <chuck.lever@oracle.com>
Signed-off-by: NJ. Bruce Fields <bfields@citi.umich.edu>
上级 55ef1274
...@@ -204,6 +204,19 @@ lockd(void *vrqstp) ...@@ -204,6 +204,19 @@ lockd(void *vrqstp)
return 0; return 0;
} }
static int create_lockd_listener(struct svc_serv *serv, char *name,
unsigned short port)
{
struct svc_xprt *xprt;
xprt = svc_find_xprt(serv, name, 0, 0);
if (xprt == NULL)
return svc_create_xprt(serv, name, port, SVC_SOCK_DEFAULTS);
svc_xprt_put(xprt);
return 0;
}
/* /*
* Ensure there are active UDP and TCP listeners for lockd. * Ensure there are active UDP and TCP listeners for lockd.
* *
...@@ -217,23 +230,11 @@ lockd(void *vrqstp) ...@@ -217,23 +230,11 @@ lockd(void *vrqstp)
static int make_socks(struct svc_serv *serv) static int make_socks(struct svc_serv *serv)
{ {
static int warned; static int warned;
struct svc_xprt *xprt;
int err = 0; int err = 0;
xprt = svc_find_xprt(serv, "udp", 0, 0); err = create_lockd_listener(serv, "udp", nlm_udpport);
if (!xprt) if (err >= 0)
err = svc_create_xprt(serv, "udp", nlm_udpport, err = create_lockd_listener(serv, "tcp", nlm_tcpport);
SVC_SOCK_DEFAULTS);
else
svc_xprt_put(xprt);
if (err >= 0) {
xprt = svc_find_xprt(serv, "tcp", 0, 0);
if (!xprt)
err = svc_create_xprt(serv, "tcp", nlm_tcpport,
SVC_SOCK_DEFAULTS);
else
svc_xprt_put(xprt);
}
if (err >= 0) { if (err >= 0) {
warned = 0; warned = 0;
err = 0; err = 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册