Set a busy timeout when opening the connection.
This commit is contained in:
@@ -253,6 +253,8 @@ do_open(ErlNifEnv *env, esqlite_connection *db, const ERL_NIF_TERM arg)
|
|||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sqlite3_busy_timeout(db->db, 2000);
|
||||||
|
|
||||||
return make_atom(env, "ok");
|
return make_atom(env, "ok");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -336,9 +338,13 @@ bind_cell(ErlNifEnv *env, const ERL_NIF_TERM cell, sqlite3_stmt *stmt, unsigned
|
|||||||
if(arity != 2)
|
if(arity != 2)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
/* length 2! */
|
||||||
if(enif_get_atom(env, tuple[0], the_atom, sizeof(the_atom), ERL_NIF_LATIN1)) {
|
if(enif_get_atom(env, tuple[0], the_atom, sizeof(the_atom), ERL_NIF_LATIN1)) {
|
||||||
|
/* its a blob... */
|
||||||
if(0 == strncmp("blob", the_atom, strlen("blob"))) {
|
if(0 == strncmp("blob", the_atom, strlen("blob"))) {
|
||||||
|
/* with a iolist as argument */
|
||||||
if(enif_inspect_iolist_as_binary(env, tuple[1], &the_blob)) {
|
if(enif_inspect_iolist_as_binary(env, tuple[1], &the_blob)) {
|
||||||
|
/* kaboom... get the blob */
|
||||||
return sqlite3_bind_blob(stmt, i, the_blob.data, the_blob.size, SQLITE_TRANSIENT);
|
return sqlite3_bind_blob(stmt, i, the_blob.data, the_blob.size, SQLITE_TRANSIENT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user