Changeset 53ed0eb9ad7db78b71f93fc1b741047f5ac9f5b5

Show
Ignore:
Timestamp:
06/06/08 16:03:14 (7 years ago)
Author:
Theo Schlossnagle <jesus@omniti.com>
git-committer:
Theo Schlossnagle <jesus@omniti.com> 1212768194 +0000
git-parent:

[a516f75aea473212a110aeb4c254bb904b92539a]

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

unreference the coros before we cleanup -- they were being freed, refs #28

Files:

Legend:

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

    ra887376 r53ed0eb  
    5555  int mask; 
    5656  eventer_t *value = ev; 
    57   eventer_t e = *value; 
     57  eventer_t removed, e = *value; 
    5858  noitL(nldeb, "lua check cleanup: dropping (%p)->fd (%d)\n", e, e->fd); 
    59   if(e->fd >= 0) e->opset->close(e->fd, &mask, e); 
    60   if(e->mask && eventer_remove(e)) eventer_free(e); 
    61   else if(!e->mask) eventer_free(e); 
     59  if(e->mask & (EVENTER_READ|EVENTER_WRITE|EVENTER_EXCEPTION)) { 
     60    noitL(nldeb, "    closing down fd %d\n", e->fd); 
     61    e->opset->close(e->fd, &mask, e); 
     62  } 
     63  removed = eventer_remove(e); 
     64  noitL(nldeb, "    remove from eventer system %s\n", 
     65        removed ? "succeeded" : "failed"); 
     66  eventer_free(e); 
    6267  free(ev); 
    6368} 
     
    489494       * to wake up the coro... 
    490495       */ 
     496      lua_gc(ci->lmc->lua_state, LUA_GCCOLLECT, 0); 
    491497      goto done; 
    492498    default: /* Errors */ 
     
    505511      break; 
    506512  } 
    507   noit_lua_log_results(ci->self, ci->check); 
    508   noit_lua_module_cleanup(ci->self, ci->check); 
    509   check->flags &= ~NP_RUNNING; 
    510  
    511513  lua_getglobal(ci->lmc->lua_state, "noit_coros"); 
    512514  luaL_unref(ci->lmc->lua_state, -1, ci->coro_state_ref); 
    513515  lua_pop(ci->lmc->lua_state, 1); 
     516  lua_gc(ci->lmc->lua_state, LUA_GCCOLLECT, 0); 
     517 
     518  noit_lua_log_results(ci->self, ci->check); 
     519  noit_lua_module_cleanup(ci->self, ci->check); 
     520  ci = NULL; /* we freed it... explode if someone uses it before we return */ 
     521  check->flags &= ~NP_RUNNING; 
    514522 
    515523 done: 
    516   lua_gc(ci->lmc->lua_state, LUA_GCCOLLECT, 0); 
    517524  return result; 
    518525}