浏览代码

handle clean shutdown of zlib stream

the server can actually close the zlib stream before closing the socket,
so we need to accept it.

we don't do anything beyond that - the actual EOF will be signaled by
the socket, and if the server (erroneously) sends more data, zlib will
tell us about it.

REFMAIL: 1423048708-975-1-git-send-email-alex.bennee@linaro.org
Oswald Buddenhagen 10 年之前
父节点
当前提交
c9b8cefc29
共有 1 个文件被更改,包括 3 次插入2 次删除
  1. 3 2
      src/socket.c

+ 3 - 2
src/socket.c

@@ -597,7 +597,7 @@ static void
 socket_fill_z( conn_t *sock )
 socket_fill_z( conn_t *sock )
 {
 {
 	char *buf;
 	char *buf;
-	int len;
+	int len, ret;
 
 
 	if (prepare_read( sock, &buf, &len ) < 0)
 	if (prepare_read( sock, &buf, &len ) < 0)
 		return;
 		return;
@@ -605,7 +605,8 @@ socket_fill_z( conn_t *sock )
 	sock->in_z->avail_out = len;
 	sock->in_z->avail_out = len;
 	sock->in_z->next_out = (unsigned char *)buf;
 	sock->in_z->next_out = (unsigned char *)buf;
 
 
-	if (inflate( sock->in_z, Z_SYNC_FLUSH ) != Z_OK) {
+	ret = inflate( sock->in_z, Z_SYNC_FLUSH );
+	if (ret != Z_OK && ret != Z_STREAM_END) {
 		error( "Error decompressing data from %s: %s\n", sock->name, sock->in_z->msg );
 		error( "Error decompressing data from %s: %s\n", sock->name, sock->in_z->msg );
 		socket_fail( sock );
 		socket_fail( sock );
 		return;
 		return;