summaryrefslogtreecommitdiffhomepage
path: root/buffer.c
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2021-08-21 16:44:02 +0200
committerAki <please@ignore.pl>2021-08-21 16:44:02 +0200
commit38c611cff6d03383e111dd4c9c9f2c5f8dfc87d6 (patch)
tree57439eec383ce29988c7b486278752090266577f /buffer.c
parent506fa912f42d31fd1760d9b3b9f3fbcfe43da2be (diff)
downloadplop-38c611cff6d03383e111dd4c9c9f2c5f8dfc87d6.zip
plop-38c611cff6d03383e111dd4c9c9f2c5f8dfc87d6.tar.gz
plop-38c611cff6d03383e111dd4c9c9f2c5f8dfc87d6.tar.bz2
Moved error handling and lua state out of buffer_prepare_at_least
Diffstat (limited to 'buffer.c')
-rw-r--r--buffer.c16
1 files changed, 2 insertions, 14 deletions
diff --git a/buffer.c b/buffer.c
index a3f527f..ab39cb7 100644
--- a/buffer.c
+++ b/buffer.c
@@ -5,10 +5,6 @@
#include <string.h>
#include <unistd.h>
-#include <lua.h>
-
-#include "stream.h"
-
int buffer_grow(struct buffer * b)
{
int allocated = b->allocated + 1024;
@@ -57,7 +53,7 @@ int buffer_read_more(int fd, struct buffer * in, int minimum_length)
return length;
}
-int buffer_prepare_at_least(lua_State * L, int fd, struct buffer * in, int minimum_length, lua_KContext ctx)
+int buffer_prepare_at_least(int fd, struct buffer * in, int minimum_length)
{
const int remaining_bytes = in->length - in->next;
@@ -65,15 +61,7 @@ int buffer_prepare_at_least(lua_State * L, int fd, struct buffer * in, int minim
{
const int res = buffer_read_more(fd, in, minimum_length);
if (-1 == res)
- {
- if (EWOULDBLOCK == errno || EAGAIN == errno)
- return lua_yieldk(L, 0, ctx, stream_readk);
- else
- {
- lua_pushstring(L, strerror(errno));
- return lua_error(L);
- }
- }
+ return res;
}
return remaining_bytes;