Commit 75598851 by Orlando Vazquez

fix crashes related to Dispose()'ing of functions we are currently in

parent f04f70c6
......@@ -29,6 +29,7 @@ function getRows() {
db.prepare("SELECT * FROM t1", function (error, st) {
if (error) throw error;
rows = 0;
t0 = new Date();
statement = st;
statement.step(onStep);
});
......
......@@ -258,7 +258,7 @@ protected:
static int EIO_Close(eio_req *req) {
struct close_request *close_req = (struct close_request *)(req->data);
Sqlite3Db* dbo = close_req->dbo;
int rc = req->result = sqlite3_close(dbo->db_);
req->result = sqlite3_close(dbo->db_);
dbo->db_ = NULL;
return 0;
}
......@@ -465,7 +465,6 @@ protected:
static Handle<Value> New(const Arguments& args) {
HandleScope scope;
int I = 0;
REQ_EXT_ARG(0, stmt);
int first_rc = args[1]->IntegerValue();
......@@ -478,8 +477,7 @@ protected:
protected:
Statement(sqlite3_stmt* stmt, int first_rc = -1)
: EventEmitter(), stmt_(stmt), step_req(NULL) {
first_rc_ = first_rc;
: EventEmitter(), step_req(NULL), first_rc_(first_rc), stmt_(stmt) {
}
~Statement() {
......@@ -523,8 +521,6 @@ protected:
HandleScope scope;
struct bind_request *bind_req = (struct bind_request *)(req->data);
Statement *sto = bind_req->sto;
Local<Value> argv[1];
bool err = false;
if (req->result) {
......@@ -794,12 +790,11 @@ protected:
HandleScope scope;
struct step_request *step_req = (struct step_request *)(req->data);
void **data = step_req->column_data;
Local<Value> argv[2];
if (step_req->error_msg) {
argv[0] = Exception::Error(String::New("some error"));
argv[0] = Exception::Error(String::New("Encountered an error while stepping through results"));
}
else {
argv[0] = Local<Value>::New(Undefined());
......@@ -852,11 +847,11 @@ protected:
FatalException(try_catch);
}
step_req->cb.Dispose();
// Disposing of the callback here causes v8 to freak out
// step_req->cb.Dispose();
if (req->result == SQLITE_DONE && step_req->column_count) {
printf("disposing of memory\n");
free((void**)step_req->column_data);
free(step_req->column_data);
step_req->column_data = NULL;
}
......@@ -915,12 +910,11 @@ protected:
switch(type) {
case SQLITE_INTEGER: {
// XXX reuse this space instead of allocating every time
step_req->column_data[i] = (int *) malloc(sizeof(int));
int value = sqlite3_column_int(stmt, i);
if (!step_req->column_data[i]) { printf ("zomg\n"); }
*(int*)(step_req->column_data[i]) = value;
// printf("addr was %p\n", step_req->column_data[i]);
assert(step_req->column_data[i]);
}
break;
......
......@@ -15,14 +15,17 @@ def configure(conf):
conf.check_tool("node_addon")
if not conf.check_cfg(package='sqlite3', args='--cflags --libs', uselib_store='SQLITE3'):
conf.fatal('Missing sqlite3');
# conf.check_cfg(package='profiler', args='--cflags --libs', uselib_store='SQLITE3')
# conf.env.append_value('LIBPATH_PROFILER', '/usr/local/lib')
# conf.env.append_value('LIB_PROFILER', 'profiler')
def build(bld):
obj = bld.new_task_gen("cxx", "shlib", "node_addon")
obj.cxxflags = ["-g", "-D_FILE_OFFSET_BITS=64", "-D_LARGEFILE_SOURCE"]
obj.cxxflags = ["-g", "-D_FILE_OFFSET_BITS=64", "-D_LARGEFILE_SOURCE", "-Wall"]
obj.target = "sqlite3_bindings"
obj.source = "sqlite3_bindings.cc"
#obj.lib = "sqlite3"
obj.uselib ="SQLITE3"
obj.uselib = "SQLITE3 PROFILER"
t = 'sqlite3_bindings.node'
def shutdown():
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment