NeoMutt  2021-02-05-666-ge300cd
Teaching an old dog new tricks
DOXYGEN

Close a Store connection. More...

+ Collaboration diagram for close():

Functions

static void store_bdb_close (void **ptr)
 Implements StoreOps::close() -. More...
 
static void store_gdbm_close (void **ptr)
 Implements StoreOps::close() -. More...
 
static void store_kyotocabinet_close (void **ptr)
 Implements StoreOps::close() -. More...
 
static void store_lmdb_close (void **ptr)
 Implements StoreOps::close() -. More...
 
static void store_qdbm_close (void **ptr)
 Implements StoreOps::close() -. More...
 
static void store_rocksdb_close (void **ptr)
 Implements StoreOps::close() -. More...
 
static void store_tokyocabinet_close (void **ptr)
 Implements StoreOps::close() -. More...
 
static void store_tdb_close (void **ptr)
 Implements StoreOps::close() -. More...
 

Detailed Description

Close a Store connection.

Parameters
[in,out]ptrStore retrieved via open()

Function Documentation

◆ store_bdb_close()

static void store_bdb_close ( void **  ptr)
static

Implements StoreOps::close() -.

Definition at line 228 of file bdb.c.

229 {
230  if (!ptr || !*ptr)
231  return;
232 
233  struct StoreDbCtx *db = *ptr;
234 
235  db->db->close(db->db, 0);
236  db->env->close(db->env, 0);
237  mutt_file_unlock(db->fd);
238  close(db->fd);
239  unlink(mutt_buffer_string(&db->lockfile));
241  FREE(ptr);
242 }
Berkeley DB context.
Definition: bdb.c:48
DB * db
Definition: bdb.c:51
int mutt_file_unlock(int fd)
Unlock a file previously locked by mutt_file_lock()
Definition: file.c:1226
static const char * mutt_buffer_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Definition: buffer.h:77
void mutt_buffer_dealloc(struct Buffer *buf)
Release the memory allocated by a buffer.
Definition: buffer.c:294
struct Buffer lockfile
Definition: bdb.c:53
#define FREE(x)
Definition: memory.h:40
int fd
Definition: bdb.c:52
DB_ENV * env
Definition: bdb.c:50
+ Here is the call graph for this function:

◆ store_gdbm_close()

static void store_gdbm_close ( void **  ptr)
static

Implements StoreOps::close() -.

Definition at line 129 of file gdbm.c.

130 {
131  if (!ptr || !*ptr)
132  return;
133 
134  GDBM_FILE db = *ptr;
135  gdbm_close(db);
136  *ptr = NULL;
137 }
DB * db
Definition: bdb.c:51

◆ store_kyotocabinet_close()

static void store_kyotocabinet_close ( void **  ptr)
static

Implements StoreOps::close() -.

Definition at line 130 of file kc.c.

131 {
132  if (!ptr || !*ptr)
133  return;
134 
135  KCDB *db = *ptr;
136  if (!kcdbclose(db))
137  {
138  int ecode = kcdbecode(db);
139  mutt_debug(LL_DEBUG2, "kcdbclose failed: %s (ecode %d)\n", kcdbemsg(db), ecode);
140  }
141  kcdbdel(db);
142  *ptr = NULL;
143 }
DB * db
Definition: bdb.c:51
Log at debug level 2.
Definition: logging.h:41
#define mutt_debug(LEVEL,...)
Definition: logging.h:85

◆ store_lmdb_close()

static void store_lmdb_close ( void **  ptr)
static

Implements StoreOps::close() -.

Definition at line 293 of file lmdb.c.

294 {
295  if (!ptr || !*ptr)
296  return;
297 
298  struct StoreLmdbCtx *db = *ptr;
299 
300  if (db->txn)
301  {
302  if (db->txn_mode == TXN_WRITE)
303  mdb_txn_commit(db->txn);
304  else
305  mdb_txn_abort(db->txn);
306 
308  db->txn = NULL;
309  }
310 
311  mdb_env_close(db->env);
312  FREE(ptr);
313 }
enum MdbTxnMode txn_mode
Definition: lmdb.c:61
MDB_env * env
Definition: lmdb.c:58
MDB_txn * txn
Definition: lmdb.c:59
LMDB context.
Definition: lmdb.c:56
Write transaction in progress.
Definition: lmdb.c:50
MDB_dbi db
Definition: lmdb.c:60
Transaction is uninitialised.
Definition: lmdb.c:48
#define FREE(x)
Definition: memory.h:40

◆ store_qdbm_close()

static void store_qdbm_close ( void **  ptr)
static

Implements StoreOps::close() -.

Definition at line 108 of file qdbm.c.

109 {
110  if (!ptr || !*ptr)
111  return;
112 
113  VILLA *db = *ptr;
114  vlclose(db);
115  *ptr = NULL;
116 }
MDB_dbi db
Definition: lmdb.c:60

◆ store_rocksdb_close()

static void store_rocksdb_close ( void **  ptr)
static

Implements StoreOps::close() -.

Definition at line 164 of file rocksdb.c.

165 {
166  if (!ptr || !*ptr)
167  return;
168 
169  struct RocksDbCtx *ctx = *ptr;
170 
171  /* close database and free resources */
172  rocksdb_close(ctx->db);
173  rocksdb_options_destroy(ctx->options);
174  rocksdb_readoptions_destroy(ctx->read_options);
175  rocksdb_writeoptions_destroy(ctx->write_options);
176 
177  FREE(ptr);
178  *ptr = NULL;
179 }
rocksdb_options_t * options
Definition: rocksdb.c:42
rocksdb_t * db
Definition: rocksdb.c:41
rocksdb_readoptions_t * read_options
Definition: rocksdb.c:43
rocksdb_writeoptions_t * write_options
Definition: rocksdb.c:44
Berkeley DB context.
Definition: rocksdb.c:39
#define FREE(x)
Definition: memory.h:40

◆ store_tokyocabinet_close()

static void store_tokyocabinet_close ( void **  ptr)
static

Implements StoreOps::close() -.

Definition at line 122 of file tc.c.

123 {
124  if (!ptr || !*ptr)
125  return;
126 
127  TCBDB *db = *ptr;
128  if (!tcbdbclose(db))
129  {
130  int ecode = tcbdbecode(db);
131  mutt_debug(LL_DEBUG2, "tcbdbclose failed: %s (ecode %d)\n", tcbdberrmsg(ecode), ecode);
132  }
133  tcbdbdel(db);
134  *ptr = NULL;
135 }
rocksdb_t * db
Definition: rocksdb.c:41
Log at debug level 2.
Definition: logging.h:41
#define mutt_debug(LEVEL,...)
Definition: logging.h:85

◆ store_tdb_close()

static void store_tdb_close ( void **  ptr)
static

Implements StoreOps::close() -.

Definition at line 123 of file tdb.c.

124 {
125  if (!ptr || !*ptr)
126  return;
127 
128  TDB_CONTEXT *db = *ptr;
129  tdb_close(db);
130  *ptr = NULL;
131 }
rocksdb_t * db
Definition: rocksdb.c:41