MINOR: quic: simplify return path in send functions
This patch simply clean up return paths used in various send function of
quic-conn module. This will simplify the implementation of poller
subscribing on sendto() error which add another error handling path.
This should be backported up to 2.7.
diff --git a/src/quic_conn.c b/src/quic_conn.c
index 6e6b6b1..6fd10cc 100644
--- a/src/quic_conn.c
+++ b/src/quic_conn.c
@@ -4216,7 +4216,7 @@
buf = qc_txb_alloc(qc);
if (!buf) {
TRACE_ERROR("buffer allocation failed", QUIC_EV_CONN_TXPKT, qc);
- goto leave;
+ goto err;
}
/* Prepare and send packets until we could not further prepare packets. */
@@ -4231,25 +4231,28 @@
b_reset(buf);
ret = qc_prep_app_pkts(qc, buf, frms);
- if (ret == -1)
+ if (ret == -1) {
+ qc_txb_release(qc);
goto err;
- else if (ret == 0)
- goto out;
+ }
- if (!qc_send_ppkts(buf, qc->xprt_ctx))
+ if (!ret)
+ break;
+
+ if (!qc_send_ppkts(buf, qc->xprt_ctx)) {
+ qc_txb_release(qc);
goto err;
+ }
}
- out:
status = 1;
qc_txb_release(qc);
- leave:
TRACE_LEAVE(QUIC_EV_CONN_TXPKT, qc);
return status;
err:
- qc_txb_release(qc);
- goto leave;
+ TRACE_DEVEL("leaving in error", QUIC_EV_CONN_TXPKT, qc);
+ return 0;
}
/* Try to send application frames from list <frms> on connection <qc>. Use this
@@ -4327,20 +4330,22 @@
}
ret = qc_prep_pkts(qc, buf, tel, tel_frms, next_tel, next_tel_frms);
- if (ret == -1)
+ if (ret == -1) {
+ qc_txb_release(qc);
goto out;
- else if (ret == 0)
- goto skip_send;
+ }
- if (!qc_send_ppkts(buf, qc->xprt_ctx))
+ if (ret && !qc_send_ppkts(buf, qc->xprt_ctx)) {
+ qc_txb_release(qc);
goto out;
+ }
- skip_send:
+ qc_txb_release(qc);
status = 1;
+
out:
TRACE_STATE("no more need old data for probing", QUIC_EV_CONN_TXPKT, qc);
qc->flags &= ~QUIC_FL_CONN_RETRANS_OLD_DATA;
- qc_txb_release(qc);
leave:
TRACE_LEAVE(QUIC_EV_CONN_TXPKT, qc);
return status;
@@ -4628,13 +4633,17 @@
ret = qc_prep_pkts(qc, buf, tel, &qc->els[tel].pktns->tx.frms,
next_tel, &qc->els[next_tel].pktns->tx.frms);
- if (ret == -1)
+ if (ret == -1) {
+ qc_txb_release(qc);
goto out;
- else if (ret == 0)
- goto skip_send;
+ }
- if (!qc_send_ppkts(buf, qc->xprt_ctx))
+ if (ret && !qc_send_ppkts(buf, qc->xprt_ctx)) {
+ qc_txb_release(qc);
goto out;
+ }
+
+ qc_txb_release(qc);
skip_send:
/* Check if there is something to do for the next level.
@@ -4648,7 +4657,6 @@
}
out:
- qc_txb_release(qc);
TRACE_LEAVE(QUIC_EV_CONN_IO_CB, qc, &st, &ssl_err);
return t;
}