Fix reference count to connection when a prepared statement is made

This commit is contained in:
Maas-Maarten Zeeman
2017-02-26 14:55:47 +01:00
parent f6d0f8b3e9
commit 3f1ef40b90
3 changed files with 35 additions and 17 deletions

View File

@@ -242,7 +242,7 @@ destruct_esqlite_statement(ErlNifEnv *env, void *arg)
stmt->statement = NULL;
}
enif_release_resource(stmt->connection);
stmt->connection = NULL;
}
static ERL_NIF_TERM
@@ -681,7 +681,7 @@ esqlite_connection_run(void *arg)
command_destroy(cmd);
}
return NULL;
}
@@ -869,11 +869,6 @@ esqlite_prepare(ErlNifEnv *env, int argc, const ERL_NIF_TERM argv[])
if(!cmd)
return make_error_tuple(env, "command_create_failed");
/* Keep a reference to the connection to prevent it from being taken down
* while the prepare statement is waiting on the queue.
*/
enif_keep_resource(conn);
cmd->type = cmd_prepare;
cmd->ref = enif_make_copy(cmd->env, argv[1]);
cmd->pid = pid;