Skip to content

Commit

Permalink
Further improve shutting down the read side of a socket
Browse files Browse the repository at this point in the history
  • Loading branch information
tuexen committed Sep 13, 2023
1 parent 01bab70 commit a0cbf46
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions usrsctplib/netinet/sctp_usrreq.c
Original file line number Diff line number Diff line change
Expand Up @@ -1289,11 +1289,9 @@ sctp_flush(struct socket *so, int how)
return (0);
}
stcb = LIST_FIRST(&inp->sctp_asoc_list);
if (stcb == NULL) {
SCTP_INP_WUNLOCK(inp);
return (ENOTCONN);
if (stcb != NULL) {
SCTP_TCB_LOCK(stcb);
}
SCTP_TCB_LOCK(stcb);
SCTP_INP_READ_LOCK(inp);
inp->sctp_flags |= SCTP_PCB_FLAGS_SOCKET_CANT_READ;
SOCK_LOCK(so);
Expand All @@ -1319,7 +1317,7 @@ sctp_flush(struct socket *so, int how)
}
SOCK_UNLOCK(so);
SCTP_INP_READ_UNLOCK(inp);
if (need_to_abort) {
if (need_to_abort && (stcb != NULL)) {
inp->last_abort_code = SCTP_FROM_SCTP_USRREQ + SCTP_LOC_6;
SCTP_INP_WUNLOCK(inp);
op_err = sctp_generate_cause(SCTP_CAUSE_OUT_OF_RESC, "");
Expand All @@ -1332,7 +1330,9 @@ sctp_flush(struct socket *so, int how)
#endif
return (ECONNABORTED);
}
SCTP_TCB_UNLOCK(stcb);
if (stcb != NULL) {
SCTP_TCB_UNLOCK(stcb);
}
SCTP_INP_WUNLOCK(inp);
return (0);
}
Expand Down

0 comments on commit a0cbf46

Please sign in to comment.