Commit 0cd14a061e32d4ddaadad24d86d06cc860010591

Authored by Jeff Layton
Committed by J. Bruce Fields
1 parent 78a8d7c8ca

nfsd: fix error handling in __write_ports_addxprt

__write_ports_addxprt calls nfsd_create_serv. That increases the
refcount of nfsd_serv (which is tracked in sv_nrthreads). The service
only decrements the thread count on error, not on success like
__write_ports_addfd does, so using this interface leaves the nfsd
thread count high.

Fix this by having this function call svc_destroy() on error to release
the reference (and possibly to tear down the service) and simply
decrement the refcount without tearing down the service on success.

This makes the sv_threads handling work basically the same in both
__write_ports_addxprt and __write_ports_addfd.

Signed-off-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>

Showing 1 changed file with 4 additions and 2 deletions Side-by-side Diff

... ... @@ -1018,6 +1018,9 @@
1018 1018 PF_INET6, port, SVC_SOCK_ANONYMOUS);
1019 1019 if (err < 0 && err != -EAFNOSUPPORT)
1020 1020 goto out_close;
  1021 +
  1022 + /* Decrease the count, but don't shut down the service */
  1023 + nfsd_serv->sv_nrthreads--;
1021 1024 return 0;
1022 1025 out_close:
1023 1026 xprt = svc_find_xprt(nfsd_serv, transport, PF_INET, port);
... ... @@ -1026,8 +1029,7 @@
1026 1029 svc_xprt_put(xprt);
1027 1030 }
1028 1031 out_err:
1029   - /* Decrease the count, but don't shut down the service */
1030   - nfsd_serv->sv_nrthreads--;
  1032 + svc_destroy(nfsd_serv);
1031 1033 return err;
1032 1034 }
1033 1035