diff options
author | Chuck Lever <chuck.lever@oracle.com> | 2008-12-31 16:06:04 -0500 |
---|---|---|
committer | J. Bruce Fields <bfields@citi.umich.edu> | 2009-01-07 15:40:44 -0500 |
commit | d3fe5ea7cf815c037c90b1f1464ffc1ab5e8601b (patch) | |
tree | a2d8724d2c730dc1837aafc623f2139220884871 /fs/lockd/svc.c | |
parent | 55ef1274dddd4de387c54d110e354ffbb6cdc706 (diff) | |
download | lwn-d3fe5ea7cf815c037c90b1f1464ffc1ab5e8601b.tar.gz lwn-d3fe5ea7cf815c037c90b1f1464ffc1ab5e8601b.zip |
NLM: Refactor make_socks() function
Clean up: extract common logic in NLM's make_socks() function
into a helper.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
Diffstat (limited to 'fs/lockd/svc.c')
-rw-r--r-- | fs/lockd/svc.c | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/fs/lockd/svc.c b/fs/lockd/svc.c index 3e5f9f079110..cf3899aec375 100644 --- a/fs/lockd/svc.c +++ b/fs/lockd/svc.c @@ -204,6 +204,19 @@ lockd(void *vrqstp) 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. * @@ -217,23 +230,11 @@ lockd(void *vrqstp) static int make_socks(struct svc_serv *serv) { static int warned; - struct svc_xprt *xprt; int err = 0; - xprt = svc_find_xprt(serv, "udp", 0, 0); - if (!xprt) - err = svc_create_xprt(serv, "udp", nlm_udpport, - 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); - } + err = create_lockd_listener(serv, "udp", nlm_udpport); + if (err >= 0) + err = create_lockd_listener(serv, "tcp", nlm_tcpport); if (err >= 0) { warned = 0; err = 0; |