Skip to content

Commit

Permalink
Improve handling of socket which was shutdown for reading
Browse files Browse the repository at this point in the history
  • Loading branch information
tuexen committed Aug 24, 2023
1 parent f4d3996 commit ad30176
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions usrsctplib/netinet/sctp_indata.c
Original file line number Diff line number Diff line change
Expand Up @@ -1306,16 +1306,18 @@ sctp_add_chk_to_control(struct sctp_queued_to_read *control,
* data from the chk onto the control and free
* up the chunk resources.
*/
uint32_t added=0;
int i_locked = 0;
uint32_t added = 0;
bool i_locked = false;

if (control->on_read_q && (hold_rlock == 0)) {
/*
* Its being pd-api'd so we must
* do some locks.
*/
SCTP_INP_READ_LOCK(stcb->sctp_ep);
i_locked = 1;
if (control->on_read_q) {
if (hold_rlock == 0) {
/* Its being pd-api'd so we must do some locks. */
SCTP_INP_READ_LOCK(stcb->sctp_ep);
i_locked = true;
}
if (stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_SOCKET_CANT_READ) {
goto out;
}
}
if (control->data == NULL) {
control->data = chk->data;
Expand Down Expand Up @@ -1363,6 +1365,7 @@ sctp_add_chk_to_control(struct sctp_queued_to_read *control,
control->end_added = 1;
control->last_frag_seen = 1;
}
out:
if (i_locked) {
SCTP_INP_READ_UNLOCK(stcb->sctp_ep);
}
Expand Down

0 comments on commit ad30176

Please sign in to comment.