Changeset 0f81a29f005c4f87e08c22052c27101ab47f8444

Show
Ignore:
Timestamp:
06/25/08 01:58:44 (6 years ago)
Author:
Theo Schlossnagle <jesus@omniti.com>
git-committer:
Theo Schlossnagle <jesus@omniti.com> 1214359124 +0000
git-parent:

[2bdd297562b53dbee111cfefd2101bb9eb99d036]

git-author:
Theo Schlossnagle <jesus@omniti.com> 1214359124 +0000
Message:

seems to address these. closes #36

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • src/modules/lua.c

    r3277121 r0f81a29  
    5353  return NULL; 
    5454} 
     55static void 
     56int_cl_free(void *vcl) { 
     57  free(vcl); 
     58} 
    5559 
    5660static void 
     
    6771  noitL(nldeb, "    remove from eventer system %s\n", 
    6872        removed ? "succeeded" : "failed"); 
     73  if(e->closure) { 
     74    struct nl_generic_cl *cl; 
     75    cl = e->closure; 
     76    if(cl->free) cl->free(cl); 
     77  } 
    6978  eventer_free(e); 
    7079  free(ev); 
     
    160169  check = lua_touserdata(L, lua_upvalueindex(1)); 
    161170  ci = check->closure; 
     171  /* strdup here... but free later */ 
    162172  ci->current.status = strdup(lua_tostring(L, 1)); 
    163173  return 0; 
     
    474484 
    475485  noit_check_set_stats(self, check, &ci->current); 
     486  free(ci->current.status); 
    476487} 
    477488int 
     
    529540                       struct timeval *now) { 
    530541  noit_check_t *check; 
    531   noit_lua_check_info_t *ci = closure; 
     542  struct nl_intcl *int_cl = closure; 
     543  noit_lua_check_info_t *ci = int_cl->ci; 
    532544  check = ci->check; 
    533545  noitL(nldeb, "lua: %p ->check_timeout\n", ci->coro_state); 
     
    548560    check->flags &= ~NP_RUNNING; 
    549561  } 
     562  if(int_cl->free) int_cl->free(int_cl); 
    550563  return 0; 
    551564} 
     
    553566noit_lua_initiate(noit_module_t *self, noit_check_t *check) { 
    554567  LMC_DECL(L, self); 
     568  struct nl_intcl *int_cl; 
    555569  noit_lua_check_info_t *ci; 
    556570  struct timeval p_int, __now; 
     
    574588  e->mask = EVENTER_TIMER; 
    575589  e->callback = noit_lua_check_timeout; 
    576   e->closure = ci; 
     590  /* We wrap this in an alloc so we can blindly free it later */ 
     591  int_cl = calloc(1, sizeof(*int_cl)); 
     592  int_cl->ci = ci; 
     593  int_cl->free = int_cl_free; 
     594  e->closure = int_cl; 
    577595  memcpy(&e->whence, &__now, sizeof(__now)); 
    578596  p_int.tv_sec = check->timeout / 1000; 
     
    582600  eventer_add(e); 
    583601 
    584   noitL(nlerr, "initiate gettop => %d\n", lua_gettop(L)); 
     602  noitL(nldeb, "initiate gettop => %d\n", lua_gettop(L)); 
    585603  ci->lmc = lmc; 
    586604  lua_getglobal(L, "noit_coros"); 
  • src/modules/lua_noit.c

    rc4546c7 r0f81a29  
    2525#endif 
    2626 
    27 struct nl_slcl { 
    28   int send_size; 
    29   struct timeval start; 
    30   char *inbuff; 
    31   int   inbuff_allocd; 
    32   int   inbuff_len; 
    33   size_t read_sofar; 
    34   size_t read_goal; 
    35   const char *read_terminator; 
    36   const char *outbuff; 
    37   size_t write_sofar; 
    38   size_t write_goal; 
    39   eventer_t *eptr; 
    40   lua_State *L; 
    41 }; 
    42  
     27static void 
     28nl_extended_free(void *vcl) { 
     29  struct nl_slcl *cl = vcl; 
     30  if(cl->inbuff) free(cl->inbuff); 
     31  free(cl); 
     32
    4333static void 
    4434inbuff_addlstring(struct nl_slcl *cl, const char *b, int l) { 
     
    455445  p_int = lua_tonumber(L, 1); 
    456446  cl = calloc(1, sizeof(*cl)); 
     447  cl->free = nl_extended_free; 
    457448  cl->L = L; 
    458449  gettimeofday(&cl->start, NULL); 
     
    495486 
    496487  cl = calloc(1, sizeof(*cl)); 
     488  cl->free = nl_extended_free; 
    497489  cl->L = L; 
    498490 
  • src/modules/lua_noit.h

    ra2b666a r0f81a29  
    4040} noit_lua_check_info_t; 
    4141 
     42struct nl_generic_cl { 
     43  void (*free)(void *); 
     44}; 
     45 
     46struct nl_intcl { 
     47  void (*free)(void *); 
     48  noit_lua_check_info_t *ci; 
     49}; 
     50 
     51struct nl_slcl { 
     52  void (*free)(void *); 
     53  int send_size; 
     54  struct timeval start; 
     55  char *inbuff; 
     56  int   inbuff_allocd; 
     57  int   inbuff_len; 
     58  size_t read_sofar; 
     59  size_t read_goal; 
     60  const char *read_terminator; 
     61  const char *outbuff; 
     62  size_t write_sofar; 
     63  size_t write_goal; 
     64  eventer_t *eptr; 
     65  lua_State *L; 
     66}; 
     67 
    4268int luaopen_noit(lua_State *L); 
    4369noit_lua_check_info_t *get_ci(lua_State *L);