Skip to content

Commit

Permalink
dbfile: avoid concurrent operations for in-memory databases
Browse files Browse the repository at this point in the history
Signed-off-by: Alexandre Bruyelles <[email protected]>
  • Loading branch information
JackSlateur committed Nov 17, 2023
1 parent 23a9c3b commit d6cca3d
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions dbfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -1500,31 +1500,44 @@ int dbfile_describe_file(struct dbhandle *db, uint64_t inum, uint64_t subvolid,
int ret;
_cleanup_(sqlite3_reset_stmt) sqlite3_stmt *stmt = db->stmts.select_file_changes;

/* in-memory databases has no wal support,
* so we must do the lock by ourselves
*/
if (!options.hashfile)
dbfile_lock();

ret = sqlite3_bind_int64(stmt, 1, inum);
if (ret) {
perror_sqlite(ret, "binding values");
return ret;
goto out;
}

ret = sqlite3_bind_int64(stmt, 2, subvolid);
if (ret) {
perror_sqlite(ret, "binding values");
return ret;
goto out;
}

ret = sqlite3_step(stmt);
if (ret == SQLITE_DONE)
return 0;
if (ret == SQLITE_DONE) {
ret = 0;
goto out;
}

if (ret != SQLITE_ROW) {
perror_sqlite(ret, "fetching a file");
return ret;
goto out;
}

*mtime = sqlite3_column_int64(stmt, 0);
*size = sqlite3_column_int64(stmt, 1);

return 0;
ret = 0;

out:
if (!options.hashfile)
dbfile_unlock();
return ret;
}

int dbfile_load_same_files(struct results_tree *res, unsigned int seq)
Expand Down

0 comments on commit d6cca3d

Please sign in to comment.