| 270 | #define getdata(vfs) (*((cephsqlite_appdata*)((vfs)->pAppData))) |
| 271 | |
| 272 | static int Lock(sqlite3_file *file, int ilock) |
| 273 | { |
| 274 | auto f = (cephsqlite_file*)file; |
| 275 | auto start = ceph::coarse_mono_clock::now(); |
| 276 | df(5) << std::hex << ilock << dendl; |
| 277 | |
| 278 | auto& lock = f->lock; |
| 279 | ceph_assert(!f->io.rs->is_locked() || lock > SQLITE_LOCK_NONE); |
| 280 | ceph_assert(lock <= ilock); |
| 281 | if (!f->io.rs->is_locked() && ilock > SQLITE_LOCK_NONE) { |
| 282 | if (int rc = f->io.rs->lock(0); rc < 0) { |
| 283 | df(5) << "failed: " << rc << dendl; |
| 284 | if (rc == -EBLOCKLISTED) { |
| 285 | getdata(f->vfs).maybe_reconnect(f->io.cluster); |
| 286 | } |
| 287 | return SQLITE_IOERR; |
| 288 | } |
| 289 | } |
| 290 | |
| 291 | lock = ilock; |
| 292 | auto end = ceph::coarse_mono_clock::now(); |
| 293 | getdata(f->vfs).logger->tinc(P_OPF_LOCK, end-start); |
| 294 | return SQLITE_OK; |
| 295 | } |
| 296 | |
| 297 | static int Unlock(sqlite3_file *file, int ilock) |
| 298 | { |
nothing calls this directly
no test coverage detected