Hi

Jonathan here I am attending a code sprint here at CSIR in South Africa.

We are using B.A.T.M.A.N as a mesh networking software. We ran into a bug which occurred with web browser whereby the  data written back through the socket was not complete thereby causing an error with our program.

The fix works by making sure that all the data that is to be sent in the send_buffer is sent. It checks the value of ret until it equals the size of the data to be sent.

--

Index: vis.c
===================================================================
--- vis.c    (revision 1336)
+++ vis.c    (working copy)
@@ -580,8 +580,18 @@
             } else {
                 send_buffer = current->json_buffer;
             }
+            
+            ret = write( thread_data->socket, send_buffer, strlen( send_buffer ));
 
-            ret = write( thread_data->socket, send_buffer, strlen( send_buffer ) );
+            while(ret != strlen( send_buffer )) {
+                send_buffer += ret;
+                
+                if ( fsync(thread_data->socket) != 0 ) {
+                    ret = write(thread_data->socket, send_buffer, strlen( send_buffer ));
+                }
+              
+            }
+    
             if( ret != strlen( send_buffer ) || (thread_data->format == json) )
             {
                 pthread_mutex_lock( &current->mutex );