Browse Source

faux.buf: Fix dread_unblock()

Serj Kalichev 3 years ago
parent
commit
c3aad376c9
1 changed files with 5 additions and 8 deletions
  1. 5 8
      faux/buf/buf.c

+ 5 - 8
faux/buf/buf.c

@@ -423,16 +423,17 @@ ssize_t faux_buf_dread_unblock(faux_buf_t *buf, size_t really_readed,
 	if (!faux_buf_is_rblocked(buf))
 		return -1;
 
+	if (buf->rblocked < really_readed)
+		return -1; // Something went wrong
+	if (buf->len < really_readed)
+		return -1; // Something went wrong
+
 	// Unblock whole buffer. Not 'really readed' bytes only
 	buf->rblocked = 0;
 	faux_free(iov);
 
 	if (0 == really_readed)
 		return really_readed;
-	if (buf->rblocked < really_readed)
-		return -1; // Something went wrong
-	if (buf->len < really_readed)
-		return -1; // Something went wrong
 
 	must_be_read = really_readed;
 	while (must_be_read > 0) {
@@ -454,10 +455,6 @@ ssize_t faux_buf_dread_unblock(faux_buf_t *buf, size_t really_readed,
 			buf->wpos = buf->chunk_size;
 	}
 
-	// Unblock whole buffer. Not 'really readed' bytes only
-	buf->rblocked = 0;
-	faux_free(iov);
-
 	return really_readed;
 }