summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2010-12-26 21:52:12 +0000
committerChristian Pointner <equinox@spreadspace.org>2010-12-26 21:52:12 +0000
commitf112b601eb369e632c0a824fab9d85c0331ed463 (patch)
tree7478914258c9383e379b3f8c71be5e6a9d3cb52f
parentcleanup (diff)
removing getfd functions
git-svn-id: https://svn.spreadspace.org/gcsd/trunk@80 ac14a137-c7f1-4531-abe0-07747231d213
-rw-r--r--src/l_sig_handler.c13
-rw-r--r--src/l_util.c10
-rw-r--r--src/modules/debug_shell.lua4
-rw-r--r--src/modules/dummy.lua1
-rw-r--r--src/modules/exec.lua2
-rw-r--r--src/modules/stdio.lua2
-rw-r--r--src/modules/stdout.lua1
7 files changed, 4 insertions, 29 deletions
diff --git a/src/l_sig_handler.c b/src/l_sig_handler.c
index 07f99b0..01e9662 100644
--- a/src/l_sig_handler.c
+++ b/src/l_sig_handler.c
@@ -37,16 +37,6 @@
#include "l_sig_handler.h"
-static int l_signal_getfd(lua_State *L)
-{
- if(!lua_istable(L, -1))
- luaL_error(L, "can't retreive signal fd");
-
- lua_pushliteral(L, "fd");
- lua_gettable(L, -2);
- return 1;
-}
-
static int l_signal_init(lua_State *L)
{
int sig_fd = signal_init();
@@ -57,9 +47,6 @@ static int l_signal_init(lua_State *L)
lua_pushliteral(L, "fd");
lua_pushinteger(L, sig_fd);
lua_settable(L, -3);
- lua_pushliteral(L, "getfd");
- lua_pushcfunction(L, l_signal_getfd);
- lua_settable(L, -3);
return 1;
}
diff --git a/src/l_util.c b/src/l_util.c
index 41bfcdd..93c2aec 100644
--- a/src/l_util.c
+++ b/src/l_util.c
@@ -49,15 +49,9 @@ static int get_fd(lua_State *L)
if(!lua_istable(L, -1))
return -1;
- lua_pushliteral(L, "getfd");
+ lua_pushliteral(L, "fd");
lua_gettable(L, -2);
- if(lua_isnil(L, -1)) {
- lua_pop(L,1);
- return -1;
- }
- lua_pushvalue(L, -2); // self
- lua_call(L, 1, 1);
- int fd = luaL_checkint(L, -1);
+ int fd = luaL_checkint(L, -1);
lua_pop(L, 1);
return fd;
}
diff --git a/src/modules/debug_shell.lua b/src/modules/debug_shell.lua
index 85ea4b6..9632383 100644
--- a/src/modules/debug_shell.lua
+++ b/src/modules/debug_shell.lua
@@ -81,8 +81,8 @@ function debug_shell:new(config, runtype)
server_sock_raw:settimeout(0)
local server_sock = {}
+ server_sock.fd = server_sock_raw:getfd()
server_sock.sock = server_sock_raw
- function server_sock:getfd() return self.sock:getfd() end
function server_sock:read()
local client_sock_raw, err = self.sock:accept()
if(client_sock_raw == nil) then
@@ -94,8 +94,8 @@ function debug_shell:new(config, runtype)
client_sock_raw:setoption('tcp-nodelay', true);
local client_sock = {}
+ client_sock.fd = client_sock_raw:getfd()
client_sock.sock = client_sock_raw
- function client_sock:getfd() return self.sock:getfd() end
client_sock.client_instance = nil
client_sock.in_buffer = ""
client_sock.out_buffer = ""
diff --git a/src/modules/dummy.lua b/src/modules/dummy.lua
index 96d6a1a..f8282a8 100644
--- a/src/modules/dummy.lua
+++ b/src/modules/dummy.lua
@@ -50,7 +50,6 @@ function dummy:new(config, runtype)
local handle = {}
handle.fd = 0
handle.client_instance = nil
- function handle:getfd() return self.fd end
function handle:read() end
function handle:write() end
diff --git a/src/modules/exec.lua b/src/modules/exec.lua
index c034c79..1556087 100644
--- a/src/modules/exec.lua
+++ b/src/modules/exec.lua
@@ -73,7 +73,6 @@ function exec:new(config, runtype)
rawio.setnonblock(in_handle.fd)
in_handle.client_instance = nil
in_handle.in_buffer = ""
- function in_handle:getfd() return self.fd end
function in_handle:read()
-- TODO: which size should we request??
local buffer, err = rawio.read(self.fd, 100)
@@ -98,7 +97,6 @@ function exec:new(config, runtype)
rawio.setnonblock(out_handle.fd)
out_handle.client_instance = nil
out_handle.out_buffer = ""
- function out_handle:getfd() return self.fd end
function out_handle:read() end
function out_handle:write()
local len, err = rawio.write(self.fd, self.out_buffer)
diff --git a/src/modules/stdio.lua b/src/modules/stdio.lua
index 0406844..21fd100 100644
--- a/src/modules/stdio.lua
+++ b/src/modules/stdio.lua
@@ -51,7 +51,6 @@ function stdio:new(config, runtype)
rawio.setnonblock(in_handle.fd)
in_handle.client_instance = nil
in_handle.in_buffer = ""
- function in_handle:getfd() return self.fd end
function in_handle:read()
-- TODO: which size should we request??
local buffer, err = rawio.read(0, 100)
@@ -76,7 +75,6 @@ function stdio:new(config, runtype)
rawio.setnonblock(out_handle.fd)
out_handle.client_instance = nil
out_handle.out_buffer = ""
- function out_handle:getfd() return self.fd end
function out_handle:read() end
function out_handle:write()
local len, err = rawio.write(1, self.out_buffer)
diff --git a/src/modules/stdout.lua b/src/modules/stdout.lua
index 3a3d477..c8231bb 100644
--- a/src/modules/stdout.lua
+++ b/src/modules/stdout.lua
@@ -51,7 +51,6 @@ function stdout:new(config, runtype)
rawio.setnonblock(handle.fd)
handle.client_instance = nil
handle.out_buffer = ""
- function handle:getfd() return self.fd end
function handle:read() end
function handle:write()
local len, err = rawio.write(1, self.out_buffer)