aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Harning Jr <harningt@gmail.com>2007-11-25 18:16:32 -0500
committerThomas Harning Jr <harningt@gmail.com>2007-11-25 18:16:32 -0500
commit8d922b9f096b384fefb0b62f04a493515a9c582e (patch)
tree782ebef72d9a984ef2e6e54116c179ebe9363b3b
parentfead5abe2ad7d185e3a2434d5e1695193339adf5 (diff)
downloadluaevent-prosody-8d922b9f096b384fefb0b62f04a493515a9c582e.tar.gz
luaevent-prosody-8d922b9f096b384fefb0b62f04a493515a9c582e.zip
bufferevent learned (get|set)_timeouts
-rw-r--r--doc/modules/luaevent.core.bufferevent.mdwn10
-rw-r--r--src/buffer_event.c23
2 files changed, 33 insertions, 0 deletions
diff --git a/doc/modules/luaevent.core.bufferevent.mdwn b/doc/modules/luaevent.core.bufferevent.mdwn
index 259a638..d63f4fb 100644
--- a/doc/modules/luaevent.core.bufferevent.mdwn
+++ b/doc/modules/luaevent.core.bufferevent.mdwn
@@ -50,3 +50,13 @@ Functions:
## bufferevent:get_write_watermarks
* Output: `low, high`
* See `set_write_watermarks`
+
+## bufferevent:set_timeouts
+* Sets timeouts for the bufferevent's events
+* Input: `(read, write)`
+ * `read` - Read readiness timeout
+ * `write` - Write readiness timeout
+
+## bufferevent:get_timeouts
+* Output: `read, write`
+* See `set_timeouts`
diff --git a/src/buffer_event.c b/src/buffer_event.c
index e32fa04..3cb0296 100644
--- a/src/buffer_event.c
+++ b/src/buffer_event.c
@@ -185,6 +185,27 @@ static int buffer_event_get_write_watermarks(lua_State* L) {
return 2;
}
+static int buffer_event_set_timeouts(lua_State* L) {
+ int timeout_read, timeout_write;
+ le_bufferevent* ev = buffer_event_get(L, 1);
+ if(!ev->ev) return 0;
+
+ timeout_read = lua_tointeger(L, 2);
+ timeout_write = lua_tointeger(L, 3);
+
+ bufferevent_settimeout(ev->ev, timeout_read, timeout_write);
+ return 0;
+}
+
+static int buffer_event_get_timeouts(lua_State* L) {
+ le_bufferevent* ev = buffer_event_get(L, 1);
+ if(!ev->ev) return 0;
+
+ lua_pushinteger(L, ev->ev->timeout_read);
+ lua_pushinteger(L, ev->ev->timeout_write);
+ return 2;
+}
+
static luaL_Reg buffer_event_funcs[] = {
{"get_read", buffer_event_get_read},
{"get_write", buffer_event_get_write},
@@ -192,6 +213,8 @@ static luaL_Reg buffer_event_funcs[] = {
{"set_write_watermarks", buffer_event_set_write_watermarks},
{"get_read_watermarks", buffer_event_get_read_watermarks},
{"get_write_watermarks", buffer_event_get_write_watermarks},
+ {"set_timeouts", buffer_event_set_timeouts},
+ {"get_timeouts", buffer_event_get_timeouts},
{NULL, NULL}
};