Changeset acf04f0e1c96bcc37c1fac182d8738bd180c8e06
- Timestamp:
- 09/14/09 02:02:26
(4 years ago)
- Author:
- Theo Schlossnagle <jesus@omniti.com>
- git-committer:
- Theo Schlossnagle <jesus@omniti.com> 1252893746 +0000
- git-parent:
[0ce85ca31350dbe1b11c67a2188075ea21bfc058]
- git-author:
- Theo Schlossnagle <jesus@omniti.com> 1252893746 +0000
- Message:
make the lua eventer_t wrap stuff act as methods
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r88a7178 |
racf04f0 |
|
| 92 | 92 | final_status, out = 0, "" |
|---|
| 93 | 93 | repeat |
|---|
| 94 | | local str = e.read("\r\n") |
|---|
| | 94 | local str = e:read("\r\n") |
|---|
| 95 | 95 | local status, c, message = string.match(str, "^(%d+)([-%s])(.+)$") |
|---|
| 96 | 96 | if not status then |
|---|
| … | … | |
| 108 | 108 | |
|---|
| 109 | 109 | local function write_cmd(e, cmd) |
|---|
| 110 | | e.write(cmd); |
|---|
| 111 | | e.write("\r\n"); |
|---|
| | 110 | e:write(cmd); |
|---|
| | 111 | e:write("\r\n"); |
|---|
| 112 | 112 | end |
|---|
| 113 | 113 | |
|---|
| … | … | |
| 136 | 136 | function initiate(module, check) |
|---|
| 137 | 137 | local e = noit.socket() |
|---|
| 138 | | local rv, err = e.connect(check.target, check.config.port or 25) |
|---|
| | 138 | local rv, err = e:connect(check.target, check.config.port or 25) |
|---|
| 139 | 139 | check.unavailable() |
|---|
| 140 | 140 | |
|---|
| r88a7178 |
racf04f0 |
|
| 81 | 81 | function initiate(module, check) |
|---|
| 82 | 82 | local e = noit.socket() |
|---|
| 83 | | local rv, err = e.connect(check.target, check.config.port or 8081) |
|---|
| | 83 | local rv, err = e:connect(check.target, check.config.port or 8081) |
|---|
| 84 | 84 | |
|---|
| 85 | | e.write("stats\r\n") |
|---|
| 86 | | str = e.read("\n") |
|---|
| | 85 | e:write("stats\r\n") |
|---|
| | 86 | str = e:read("\n") |
|---|
| 87 | 87 | |
|---|
| 88 | 88 | if rv ~= 0 or not str then |
|---|
| … | … | |
| 103 | 103 | end |
|---|
| 104 | 104 | |
|---|
| 105 | | local rawstats = e.read(len) |
|---|
| | 105 | local rawstats = e:read(len) |
|---|
| 106 | 106 | local i = 0 |
|---|
| 107 | 107 | for v, k in string.gmatch(rawstats, "%s*(%d+)%s+([^\r\n]+)") do |
|---|
| r49a6c7b |
racf04f0 |
|
| 126 | 126 | |
|---|
| 127 | 127 | eptr = lua_touserdata(L, lua_upvalueindex(1)); |
|---|
| | 128 | if(eptr != lua_touserdata(L, 1)) |
|---|
| | 129 | luaL_error(L, "must be called as method"); |
|---|
| 128 | 130 | e = *eptr; |
|---|
| 129 | | target = lua_tostring(L, 1); |
|---|
| 130 | | port = lua_tointeger(L, 2); |
|---|
| | 131 | target = lua_tostring(L, 2); |
|---|
| | 132 | port = lua_tointeger(L, 3); |
|---|
| 131 | 133 | |
|---|
| 132 | 134 | family = AF_INET; |
|---|
| … | … | |
| 205 | 207 | |
|---|
| 206 | 208 | eptr = lua_touserdata(L, lua_upvalueindex(1)); |
|---|
| | 209 | if(eptr != lua_touserdata(L, 1)) |
|---|
| | 210 | luaL_error(L, "must be called as method"); |
|---|
| 207 | 211 | e = *eptr; |
|---|
| 208 | | ca = lua_tostring(L, 1); |
|---|
| 209 | | ciphers = lua_tostring(L, 2); |
|---|
| 210 | | cert = lua_tostring(L, 3); |
|---|
| 211 | | key = lua_tostring(L, 4); |
|---|
| | 212 | ca = lua_tostring(L, 2); |
|---|
| | 213 | ciphers = lua_tostring(L, 3); |
|---|
| | 214 | cert = lua_tostring(L, 4); |
|---|
| | 215 | key = lua_tostring(L, 5); |
|---|
| 212 | 216 | |
|---|
| 213 | 217 | sslctx = eventer_ssl_ctx_new(SSL_CLIENT, cert, key, ca, ciphers); |
|---|
| … | … | |
| 317 | 321 | |
|---|
| 318 | 322 | eptr = lua_touserdata(L, lua_upvalueindex(1)); |
|---|
| | 323 | if(eptr != lua_touserdata(L, 1)) |
|---|
| | 324 | luaL_error(L, "must be called as method"); |
|---|
| 319 | 325 | e = *eptr; |
|---|
| 320 | 326 | cl = e->closure; |
|---|
| … | … | |
| 322 | 328 | cl->read_terminator = NULL; |
|---|
| 323 | 329 | |
|---|
| 324 | | if(lua_isnumber(L, 1)) { |
|---|
| 325 | | cl->read_goal = lua_tointeger(L, 1); |
|---|
| | 330 | if(lua_isnumber(L, 2)) { |
|---|
| | 331 | cl->read_goal = lua_tointeger(L, 2); |
|---|
| 326 | 332 | if(cl->read_goal <= cl->read_sofar) { |
|---|
| 327 | 333 | int base; |
|---|
| … | … | |
| 339 | 345 | } |
|---|
| 340 | 346 | else { |
|---|
| 341 | | cl->read_terminator = lua_tostring(L, 1); |
|---|
| | 347 | cl->read_terminator = lua_tostring(L, 2); |
|---|
| 342 | 348 | if(cl->read_sofar) { |
|---|
| 343 | 349 | const char *cp; |
|---|
| … | … | |
| 423 | 429 | |
|---|
| 424 | 430 | eptr = lua_touserdata(L, lua_upvalueindex(1)); |
|---|
| | 431 | if(eptr != lua_touserdata(L, 1)) |
|---|
| | 432 | luaL_error(L, "must be called as method"); |
|---|
| 425 | 433 | e = *eptr; |
|---|
| 426 | 434 | cl = e->closure; |
|---|
| 427 | 435 | cl->write_sofar = 0; |
|---|
| 428 | | cl->outbuff = lua_tolstring(L, 1, &cl->write_goal); |
|---|
| | 436 | cl->outbuff = lua_tolstring(L, 2, &cl->write_goal); |
|---|
| 429 | 437 | |
|---|
| 430 | 438 | while((rv = e->opset->write(e->fd, |
|---|