pud: force pending buffer out if not enough space for our message
authorFerry Huberts <ferry.huberts@pelagic.nl>
Fri, 24 Aug 2012 13:10:51 +0000 (15:10 +0200)
committerFerry Huberts <ferry.huberts@pelagic.nl>
Sat, 25 Aug 2012 11:04:12 +0000 (13:04 +0200)
Signed-off-by: Ferry Huberts <ferry.huberts@pelagic.nl>
lib/pud/src/pud.c
lib/pud/src/receiver.c

index 6213777..11c0e82 100644 (file)
@@ -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) {
                                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(
                                        r = net_outbuffer_push(ifn, olsrMessage, olsrMessageLength);
                                        if (r != (int) olsrMessageLength) {
                                                pudError(
index 30e492a..54c6075 100644 (file)
@@ -162,6 +162,10 @@ static void txToAllOlsrInterfaces(TimedTxInterface interfaces) {
                int r;
                struct interface *ifn;
                for (ifn = ifnet; ifn; ifn = ifn->int_next) {
                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(
                        r = net_outbuffer_push(ifn, pu, pu_size);
                        if (r != (int) pu_size) {
                                pudError(