reduce CPU load in dot_draw
[olsrd.git] / lib / dot_draw / src / olsrd_dot_draw.c
index c4ffdb2..31fe705 100644 (file)
@@ -303,7 +303,7 @@ dotdraw_write_data(void *foo __attribute__ ((unused))) {
     if (result > 0)
       abuf_pull(&outbuffer, result);
 
-    if (result < 0) {
+    if (result <= 0) {
       /* close this socket and cleanup*/
       close(outbuffer_socket);
       abuf_free(&outbuffer);
@@ -312,6 +312,14 @@ dotdraw_write_data(void *foo __attribute__ ((unused))) {
       outbuffer_socket = -1;
     }
   }
+  if (outbuffer.len == 0) {
+    /* close this socket and cleanup*/
+    close(outbuffer_socket);
+    abuf_free(&outbuffer);
+    olsr_stop_timer(writetimer_entry);
+    writetimer_entry = NULL;
+    outbuffer_socket = -1;
+  }
 }
 
 /**