Changeset acf04f0e1c96bcc37c1fac182d8738bd180c8e06

Show
Ignore:
Timestamp:
09/14/09 02:02:26 (5 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
  • src/modules-lua/noit/module/smtp.lua

    r88a7178 racf04f0  
    9292  final_status, out = 0, "" 
    9393  repeat 
    94     local str = e.read("\r\n") 
     94    local str = e:read("\r\n") 
    9595    local status, c, message = string.match(str, "^(%d+)([-%s])(.+)$") 
    9696    if not status then 
     
    108108 
    109109local function write_cmd(e, cmd) 
    110   e.write(cmd); 
    111   e.write("\r\n"); 
     110  e:write(cmd); 
     111  e:write("\r\n"); 
    112112end 
    113113 
     
    136136function initiate(module, check) 
    137137  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) 
    139139  check.unavailable() 
    140140 
  • src/modules-lua/noit/module/varnish.lua

    r88a7178 racf04f0  
    8181function initiate(module, check) 
    8282  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) 
    8484 
    85   e.write("stats\r\n") 
    86   str = e.read("\n") 
     85  e:write("stats\r\n") 
     86  str = e:read("\n") 
    8787 
    8888  if rv ~= 0 or not str then 
     
    103103  end 
    104104 
    105   local rawstats = e.read(len) 
     105  local rawstats = e:read(len) 
    106106  local i = 0 
    107107  for v, k in string.gmatch(rawstats, "%s*(%d+)%s+([^\r\n]+)") do 
  • src/modules/lua_noit.c

    r49a6c7b racf04f0  
    126126 
    127127  eptr = lua_touserdata(L, lua_upvalueindex(1)); 
     128  if(eptr != lua_touserdata(L, 1)) 
     129    luaL_error(L, "must be called as method"); 
    128130  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); 
    131133 
    132134  family = AF_INET; 
     
    205207 
    206208  eptr = lua_touserdata(L, lua_upvalueindex(1)); 
     209  if(eptr != lua_touserdata(L, 1)) 
     210    luaL_error(L, "must be called as method"); 
    207211  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); 
    212216 
    213217  sslctx = eventer_ssl_ctx_new(SSL_CLIENT, cert, key, ca, ciphers); 
     
    317321 
    318322  eptr = lua_touserdata(L, lua_upvalueindex(1)); 
     323  if(eptr != lua_touserdata(L, 1)) 
     324    luaL_error(L, "must be called as method"); 
    319325  e = *eptr; 
    320326  cl = e->closure; 
     
    322328  cl->read_terminator = NULL; 
    323329 
    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); 
    326332    if(cl->read_goal <= cl->read_sofar) { 
    327333      int base; 
     
    339345  } 
    340346  else { 
    341     cl->read_terminator = lua_tostring(L, 1); 
     347    cl->read_terminator = lua_tostring(L, 2); 
    342348    if(cl->read_sofar) { 
    343349      const char *cp; 
     
    423429 
    424430  eptr = lua_touserdata(L, lua_upvalueindex(1)); 
     431  if(eptr != lua_touserdata(L, 1)) 
     432    luaL_error(L, "must be called as method"); 
    425433  e = *eptr; 
    426434  cl = e->closure; 
    427435  cl->write_sofar = 0; 
    428   cl->outbuff = lua_tolstring(L, 1, &cl->write_goal); 
     436  cl->outbuff = lua_tolstring(L, 2, &cl->write_goal); 
    429437 
    430438  while((rv = e->opset->write(e->fd,