Browse Source

async: Fix faux_async_in() function

Serj Kalichev 1 year ago
parent
commit
5ee5a7703e
2 changed files with 5 additions and 3 deletions
  1. 4 3
      faux/async/async.c
  2. 1 0
      faux/buf/buf.c

+ 4 - 3
faux/async/async.c

@@ -36,6 +36,7 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
+#include <syslog.h>
 
 #include "faux/faux.h"
 #include "faux/str.h"
@@ -412,14 +413,14 @@ ssize_t faux_async_in(faux_async_t *async)
 		// Read data
 		bytes_readed = read(async->fd, data, locked_len);
 		if (bytes_readed < 0) {
+			faux_buf_dwrite_unlock_easy(async->ibuf, 0);
 			if ( // Something went wrong
 				(errno != EINTR) &&
 				(errno != EAGAIN) &&
 				(errno != EWOULDBLOCK)
-			) {
-				faux_buf_dwrite_unlock_easy(async->ibuf, 0);
+			)
 				return -1;
-			}
+			break;
 		}
 		faux_buf_dwrite_unlock_easy(async->ibuf, bytes_readed);
 		total_readed += bytes_readed;

+ 1 - 0
faux/buf/buf.c

@@ -17,6 +17,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <assert.h>
+#include <syslog.h>
 
 #include "faux/faux.h"
 #include "faux/str.h"