}
}
-/* Prepare for the emission of RESET_STREAM on <qcs> with error code <err>. If
- * <tevt> is non null, it is used as a stream level termination event code.
+/* Prepare for the emission of RESET_STREAM on <qcs> with error code <err> and
+ * notify stream upper layer. If <tevt> is non null, it is used as the stream
+ * level termination event code.
*/
void qcc_reset_stream(struct qcs *qcs, int err, int tevt)
{
struct qcc *qcc = qcs->qcc;
const uint64_t diff = qcs_prep_bytes(qcs);
- if ((qcs->flags & QC_SF_TO_RESET) || qcs_is_close_local(qcs))
+ /* early return if stream reset was already performed */
+ if (qcs->flags & QC_SF_TO_RESET)
return;
+ /* RS is unneeded if stream is already locally closed. Upper layer
+ * still needs to be notified.
+ */
+ if (qcs_is_close_local(qcs)) {
+ TRACE_DEVEL("RS emission skipped", QMUX_EV_QCS_END, qcc->conn, qcs);
+ goto out;
+ }
+
/* TODO if QCS waiting for buffer, it could be removed from
* <qcc.buf_wait_list> if sending is closed now.
*/
qcs->tx.fc.off_soft = qcs->tx.fc.off_real;
}
+ _qcc_send_stream(qcs, 1);
+ tasklet_wakeup(qcc->wait_event.tasklet);
+
+ out:
/* Report send error to stream-endpoint layer. */
- if (qcs_sc(qcs)) {
+ if (qcs_sc(qcs) && !se_fl_test(qcs->sd, SE_FL_ERROR|SE_FL_ERR_PENDING)) {
se_fl_set_error(qcs->sd);
if (tevt)
se_report_term_evt(qcs->sd, tevt);
qcs_alert(qcs);
}
-
- _qcc_send_stream(qcs, 1);
- tasklet_wakeup(qcc->wait_event.tasklet);
}
/* Register <qcs> stream for STREAM emission. Set <urg> to 1 if stream content