[Olsr-dev] [PATCH v1 2/2] pud: force pending buffer out if not enough space for our message
Ferry Huberts
(spam-protected)
Fri Aug 24 15:13:41 CEST 2012
From: Ferry Huberts <(spam-protected)>
Signed-off-by: Ferry Huberts <(spam-protected)>
---
lib/pud/src/pud.c | 4 ++++
lib/pud/src/receiver.c | 4 ++++
2 files changed, 8 insertions(+)
diff --git a/lib/pud/src/pud.c b/lib/pud/src/pud.c
index 6213777..11c0e82 100644
--- a/lib/pud/src/pud.c
+++ b/lib/pud/src/pud.c
@@ -232,6 +232,10 @@ static void packetReceivedFromDownlink(int skfd, void *data __attribute__ ((unus
int r;
struct interface *ifn;
for (ifn = ifnet; ifn; ifn = ifn->int_next) {
+ /* force the pending buffer out if there's not enough space for our message */
+ if ((int)olsrMessageLength > net_outbuffer_bytes_left(ifn)) {
+ net_output(ifn);
+ }
r = net_outbuffer_push(ifn, olsrMessage, olsrMessageLength);
if (r != (int) olsrMessageLength) {
pudError(
diff --git a/lib/pud/src/receiver.c b/lib/pud/src/receiver.c
index 30e492a..54c6075 100644
--- a/lib/pud/src/receiver.c
+++ b/lib/pud/src/receiver.c
@@ -162,6 +162,10 @@ static void txToAllOlsrInterfaces(TimedTxInterface interfaces) {
int r;
struct interface *ifn;
for (ifn = ifnet; ifn; ifn = ifn->int_next) {
+ /* force the pending buffer out if there's not enough space for our message */
+ if ((int)pu_size > net_outbuffer_bytes_left(ifn)) {
+ net_output(ifn);
+ }
r = net_outbuffer_push(ifn, pu, pu_size);
if (r != (int) pu_size) {
pudError(
--
1.7.11.4
More information about the Olsr-dev
mailing list