int main(int argc, char **argv) { if(argc==1){ printf("Usage: %s <ketama.servers file>\n", *argv); return 1; } ketama_continuum c; serverinfo* serverinfo; ketama_roll( &c, *++argv, serverinfo ); printf( "%s\n", ketama_error() ); int i; for ( i = 0; i < 1000000; i++ ) { char k[10]; sprintf( k, "%d", i ); unsigned int kh = ketama_hashi( k ); mcs* m = ketama_get_server( k, c ); printf( "%u %u %s\n", kh, m->point, m->ip ); } ketama_smoke(c); return 0; }
static int lketama_smoke(lua_State *L){ contdata *data = luaL_checkudata(L, 1, MT_NAME); if(data->cont){ ketama_smoke((ketama_continuum)data->cont); data->cont = NULL; } return 0; }
static void pyketama_Continuum_dealloc(pyketama_Continuum *self) { ketama_smoke(self->cont); free(self->filename); self->ob_type->tp_free((PyObject *)self); }
PY_DEF(pyketama_Continuum_destroy, self, args) { ketama_smoke(((pyketama_Continuum *) self)->cont); return Py_BuildValue("b", 1); }