[vis] fixed partial json output

Message ID 1739bfe0907170010n67ae2bd8m9bf9813d09687951@mail.gmail.com (mailing list archive)
State Rejected, archived
Headers

Commit Message

jonathan mzengeza July 17, 2009, 7:10 a.m. UTC
  I looked at the site and it talked about something I had already tried
which works well. Here is another patch hope its better.

Signed-off-by: Jonathan Mzengeza <jtmze87@gmail.com>
  

Comments

Marek Lindner July 17, 2009, 6:53 p.m. UTC | #1
On Friday 17 July 2009 15:10:55 jonathan mzengeza wrote:
> I looked at the site and it talked about something I had already tried
> which works well. Here is another patch hope its better.
>
> +	shutdown(thread_data->socket, SHUT_WR);

Does your patch also work without the shutdown ? Some clients (e.g. s3d) read 
the constant stream of vis data to update their visualization without  re-
opening the connection. 

Regards,
Marek
  

Patch

Index: vis.c
===================================================================
--- vis.c	(revision 1343)
+++ vis.c	(working copy)
@@ -566,6 +566,7 @@ 
 	buffer_t *last_send = NULL;
 	size_t ret;
 	char* send_buffer = NULL;
+  	char tmp[4096];

 	while ( !is_aborted() ) {

@@ -600,6 +601,17 @@ 

 	}

+	shutdown(thread_data->socket, SHUT_WR);
+	
+	for(;;) {
+		ret=read(thread_data->socket, tmp, sizeof(tmp));
+		if(ret < 0) {
+			break;
+		}
+		if(!ret) {
+			break;
+		}
+	}			
 	if ( debug_level > 0 )
 		debug_output( "TCP client has left: %s \n", thread_data->ip );