Skip to content

Commit

Permalink
Shutdown only if CLOSE has been set to xprt->xp_flags
Browse files Browse the repository at this point in the history
Signed-off-by: Rojin George <[email protected]>
  • Loading branch information
rojingeorge committed Aug 27, 2024
1 parent ddb9ccc commit 59e14fc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
9 changes: 6 additions & 3 deletions ntirpc/rpc/svc.h
Original file line number Diff line number Diff line change
Expand Up @@ -560,9 +560,12 @@ static inline void svc_destroy_it(SVCXPRT *xprt,
(*(xprt)->xp_ops->xp_unref_user_data)(xprt);
}

/* Let's shutdown the sockets so that FIN-ACK could be sent to the
* client immediately. */
if (xprt->xp_fd != RPC_ANYFD) {
/* Check if the connection was already set as dead or closed,
* If set, let's cleanup and close the FDs, so that FIN-ACK
* could be sent to the client immediately.
* Also for UDP xprt, this is never set, needn't enter here */
if ((atomic_fetch_uint16_t(&xprt->xp_flags) & SVC_XPRT_FLAG_CLOSE)
&& xprt->xp_fd != RPC_ANYFD) {
(void)shutdown(xprt->xp_fd, SHUT_RDWR);
if (xprt->xp_fd_send != RPC_ANYFD)
(void)shutdown(xprt->xp_fd_send, SHUT_RDWR);
Expand Down
10 changes: 5 additions & 5 deletions src/svc_dg.c
Original file line number Diff line number Diff line change
Expand Up @@ -280,16 +280,16 @@ svc_dg_rendezvous(SVCXPRT *xprt)
}

if (sp->sa_family == (sa_family_t) 0xffff) {
__warnx(TIRPC_DEBUG_FLAG_ERROR,
"%s: Bad message sa_family is 0xffff",
__func__);
__warnx(TIRPC_DEBUG_FLAG_ERROR,
"%s: xprt(%p) newxprt(%p) fd %d Bad message sa_family is 0xffff",
__func__, xprt, newxprt, newxprt->xp_fd);
return SVC_STAT(xprt);
}

if (rlen == -1 || (rlen < (ssize_t) (4 * sizeof(u_int32_t)))) {
__warnx(TIRPC_DEBUG_FLAG_ERROR,
"%s: Bad message rlen: %d",
__func__, rlen);
"%s: xprt(%p) newxprt(%p) fd %d Bad message rlen: %d",
__func__, xprt, newxprt, newxprt->xp_fd, rlen);
return SVC_STAT(xprt);
}

Expand Down

0 comments on commit 59e14fc

Please sign in to comment.