From 727d4b9714434e2d8c7cb3784f297e7dddea651c Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Fri, 23 Dec 2016 11:27:50 -0500 Subject: [PATCH] add tests when select returns true, but no bytes available, in single image mode --- src/zm_remote_camera_http.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/zm_remote_camera_http.cpp b/src/zm_remote_camera_http.cpp index 3953c5e6d..c906d2d92 100644 --- a/src/zm_remote_camera_http.cpp +++ b/src/zm_remote_camera_http.cpp @@ -237,6 +237,15 @@ int RemoteCameraHttp::ReadData( Buffer &buffer, int bytes_expected ) if ( total_bytes_to_read == 0 ) { if( mode == SINGLE_IMAGE ) { + int error = 0; + socklen_t len = sizeof (error); + int retval = getsockopt (sd, SOL_SOCKET, SO_ERROR, &error, &len); + if(retval != 0 ) { + Debug( 1, "error getting socket error code %s", strerror(retval) ); + } + if (error != 0) { + return -1; + } // Case where we are grabbing a single jpg, but no content-length was given, so the expectation is that we read until close. return( 0 ); }