projects
/
project
/
luci.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
More splicing stuff
[project/luci.git]
/
libs
/
nixio
/
src
/
splice.c
diff --git
a/libs/nixio/src/splice.c
b/libs/nixio/src/splice.c
index
556b4d7
..
cbfc674
100644
(file)
--- a/
libs/nixio/src/splice.c
+++ b/
libs/nixio/src/splice.c
@@
-21,12
+21,13
@@
#include "nixio.h"
#include <fcntl.h>
#include <string.h>
#include "nixio.h"
#include <fcntl.h>
#include <string.h>
+#include <errno.h>
+#include <unistd.h>
#include <sys/sendfile.h>
/* guess what sucks... */
#ifdef __UCLIBC__
#include <unistd.h>
#include <sys/sendfile.h>
/* guess what sucks... */
#ifdef __UCLIBC__
#include <unistd.h>
-#include <errno.h>
#include <sys/syscall.h>
ssize_t splice(int __fdin, __off64_t *__offin, int __fdout,
__off64_t *__offout, size_t __len, unsigned int __flags) {
#include <sys/syscall.h>
ssize_t splice(int __fdin, __off64_t *__offin, int __fdout,
__off64_t *__offout, size_t __len, unsigned int __flags) {
@@
-77,9
+78,11
@@
static int nixio_splice(lua_State *L) {
int fd_out = nixio__checkfd(L, 2);
size_t len = luaL_checkinteger(L, 3);
int flags = luaL_optinteger(L, 4, 0);
int fd_out = nixio__checkfd(L, 2);
size_t len = luaL_checkinteger(L, 3);
int flags = luaL_optinteger(L, 4, 0);
+ long spliced;
-
- long spliced = splice(fd_in, NULL, fd_out, NULL, len, flags);
+ do {
+ spliced = splice(fd_in, NULL, fd_out, NULL, len, flags);
+ } while (spliced == -1 && errno == EINTR);
if (spliced < 0) {
return nixio__perror(L);
if (spliced < 0) {
return nixio__perror(L);
@@
-89,6
+92,12
@@
static int nixio_splice(lua_State *L) {
return 1;
}
return 1;
}
+static int nixio_splice_avail(lua_State *L) {
+ splice(-1, 0, -1, 0, 0, 0);
+ lua_pushboolean(L, errno != ENOSYS);
+ return 1;
+}
+
/**
* sendfile(outfd, infd, length)
*/
/**
* sendfile(outfd, infd, length)
*/
@@
-111,6
+120,7
@@
static int nixio_sendfile(lua_State *L) {
static const luaL_reg R[] = {
{"splice", nixio_splice},
{"splice_flags", nixio_splice_flags},
static const luaL_reg R[] = {
{"splice", nixio_splice},
{"splice_flags", nixio_splice_flags},
+ {"splice_avail", nixio_splice_avail},
{"sendfile", nixio_sendfile},
{NULL, NULL}
};
{"sendfile", nixio_sendfile},
{NULL, NULL}
};