From bfd699dac5ebb6a5d91fe3db1e2546fcfcdc1caa Mon Sep 17 00:00:00 2001 From: Roberto De Ioris Date: Sun, 1 Dec 2013 05:44:36 +0100 Subject: [PATCH] another mjpeg fix --- core/sharedarea.c | 2 +- examples/mjpeg_stream.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/core/sharedarea.c b/core/sharedarea.c index 03aa8ea4..680ed0e4 100644 --- a/core/sharedarea.c +++ b/core/sharedarea.c @@ -31,7 +31,7 @@ int64_t uwsgi_sharedarea_read(int id, uint64_t pos, char *blob, uint64_t len) { if (!sa) return -1; if (pos + len > sa->max_pos + 1) return -1; if (len == 0) len = (sa->max_pos + 1) - pos; - if (sa->honour_used) len = sa->used-pos; + if (sa->honour_used && sa->used-pos < len) len = sa->used-pos ; uwsgi_rlock(sa->lock); memcpy(blob, sa->area + pos, len); sa->hits++; diff --git a/examples/mjpeg_stream.py b/examples/mjpeg_stream.py index 761887e8..ae9e5474 100644 --- a/examples/mjpeg_stream.py +++ b/examples/mjpeg_stream.py @@ -10,7 +10,7 @@ def application(env, start_response): ('Cache-Control', 'no-cache'), ('Cache-Control', 'private'), ('Pragma', 'no-cache'), - ('Content-Type', 'multipart/x-mixed-replace; boundary=--' + boundary), + ('Content-Type', 'multipart/x-mixed-replace; boundary=' + boundary), ] ) @@ -21,5 +21,5 @@ def application(env, start_response): print os.system('screencapture -t jpg -m -T 1 screenshot.jpg') f = open('screenshot.jpg') yield env['wsgi.file_wrapper'](f) - yield "--%s\r\n" % boundary + yield "\r\n--%s\r\n" % boundary #os.system('./isightcapture -w 640 -h 480 screenshot.jpg')