Skip to content

Commit

Permalink
Merge pull request #2706 from dilyanpalauzov/master-good_bye_cyrus_db…
Browse files Browse the repository at this point in the history
…_sync

Good bye cyrusdb_sync
  • Loading branch information
ksmurchison authored Sep 16, 2024
2 parents f6b964d + b25a4f5 commit fecb8fc
Show file tree
Hide file tree
Showing 19 changed files with 19 additions and 62 deletions.
4 changes: 2 additions & 2 deletions cunit/annotate.testc
Original file line number Diff line number Diff line change
Expand Up @@ -2205,10 +2205,10 @@ static int set_up(void)
isadmin = 0;
auth_state = auth_newstate(userid);

quotadb_init(0);
quotadb_init();
quotadb_open(NULL);

mboxlist_init(0);
mboxlist_init();
mboxlist_open(NULL);

struct mboxlock *namespacelock = mboxname_usernamespacelock(MBOXNAME1_INT);
Expand Down
2 changes: 1 addition & 1 deletion cunit/quota.testc
Original file line number Diff line number Diff line change
Expand Up @@ -1034,7 +1034,7 @@ static int set_up(void)
cyrusdb_init();
config_quota_db = "skiplist";

quotadb_init(0);
quotadb_init();
quotadb_open(NULL);

return 0;
Expand Down
10 changes: 0 additions & 10 deletions imap/ctl_cyrusdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -394,17 +394,7 @@ int main(int argc, char *argv[])
break;

case CHECKPOINT:
r2 = cyrusdb_sync(*dblist[i].configptr);
if (r2) {
syslog(LOG_ERR, "DBERROR: sync %s: %s", dirname,
cyrusdb_strerror(r2));
fprintf(stderr,
"ctl_cyrusdb: unable to sync environment\n");
}

/* ARCHIVE */
r2 = 0;

if (!rotated) {
/* rotate the backup directories -- ONE time only */
char *file;
Expand Down
8 changes: 4 additions & 4 deletions imap/ctl_mboxlist.c
Original file line number Diff line number Diff line change
Expand Up @@ -1370,7 +1370,7 @@ int main(int argc, char *argv[])
switch (op) {
case M_POPULATE:
syslog(LOG_NOTICE, "%spopulating mupdate", warn_only ? "test " : "");
mboxlist_init(0);
mboxlist_init();
mboxlist_open(mboxdb_fname);

do_pop_mupdate();
Expand All @@ -1382,7 +1382,7 @@ int main(int argc, char *argv[])
break;

case DUMP:
mboxlist_init(0);
mboxlist_init();
mboxlist_open(mboxdb_fname);

do_dump(partition, dopurge, dointermediary);
Expand All @@ -1393,7 +1393,7 @@ int main(int argc, char *argv[])
break;

case UNDUMP:
mboxlist_init(0);
mboxlist_init();
mboxlist_open(mboxdb_fname);

if (undump_legacy) {
Expand All @@ -1408,7 +1408,7 @@ int main(int argc, char *argv[])
break;

case VERIFY:
mboxlist_init(0);
mboxlist_init();
mboxlist_open(mboxdb_fname);

do_verify();
Expand Down
2 changes: 1 addition & 1 deletion imap/cyr_deny.c
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ int main(int argc, char **argv)

cyrus_init(alt_config, "cyr_deny", 0, 0);

denydb_init(0);
denydb_init();

r = denydb_open(/*create*/(mode == DENY));
if (r) {
Expand Down
9 changes: 3 additions & 6 deletions imap/mboxlist.c
Original file line number Diff line number Diff line change
Expand Up @@ -4881,19 +4881,16 @@ static void done_cb(void*rock __attribute__((unused)))
static void init_internal()
{
if (!mboxlist_initialized) {
mboxlist_init(0);
mboxlist_init();
}
if (!mboxlist_dbopen) {
mboxlist_open(NULL);
}
}

/* must be called after cyrus_init */
EXPORTED void mboxlist_init(int myflags)
EXPORTED void mboxlist_init(void)
{
if (myflags & MBOXLIST_SYNC) {
cyrusdb_sync(DB);
}
cyrus_modules_add(done_cb, NULL);
mboxlist_initialized = 1;
}
Expand All @@ -4918,7 +4915,7 @@ EXPORTED void mboxlist_open(const char *fname)
fname = tofree;
}

mboxlist_init(0);
mboxlist_init();

flags = CYRUSDB_CREATE;

Expand Down
3 changes: 1 addition & 2 deletions imap/mboxlist.h
Original file line number Diff line number Diff line change
Expand Up @@ -416,8 +416,7 @@ void mboxlist_open(const char *name);
void mboxlist_close(void);

/* initialize database structures */
#define MBOXLIST_SYNC 0x02
void mboxlist_init(int flags);
void mboxlist_init(void);

/* done with database stuff */
void mboxlist_done(void);
Expand Down
2 changes: 1 addition & 1 deletion imap/quota.c
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ int main(int argc,char **argv)
* Lock mailbox list to prevent mailbox creation/deletion
* during work
*/
mboxlist_init(0);
mboxlist_init();
mboxlist_open(NULL);

quota_changelock();
Expand Down
3 changes: 1 addition & 2 deletions imap/quota.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,7 @@ extern int quotadb_foreach(const char *prefix, size_t prefixlen,
void quotadb_close(void);

/* initialize database structures */
#define QUOTADB_SYNC 0x02
void quotadb_init(int flags);
void quotadb_init(void);

/* done with database stuff */
void quotadb_done(void);
Expand Down
7 changes: 2 additions & 5 deletions imap/quota_db.c
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,7 @@ static void done_cb(void*rock __attribute__((unused)))

static void init_internal() {
if (!quota_initialized) {
quotadb_init(0);
quotadb_init();
quota_initialized = 1;
}
if (!quota_dbopen) {
Expand All @@ -701,11 +701,8 @@ static void init_internal() {
}

/* must be called after cyrus_init */
EXPORTED void quotadb_init(int myflags)
EXPORTED void quotadb_init(void)
{
if (myflags & QUOTADB_SYNC) {
cyrusdb_sync(QDB);
}
cyrus_modules_add(done_cb, NULL);
}

Expand Down
3 changes: 1 addition & 2 deletions imap/userdeny.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ int denydb_open(int create);
void denydb_close(void);

/* initialize database structures */
#define DENYDB_SYNC 0x02
void denydb_init(int flags);
void denydb_init(void);

/* done with database stuff */
void denydb_done(void);
Expand Down
7 changes: 2 additions & 5 deletions imap/userdeny_db.c
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ static void done_cb(void*rock __attribute__((unused)))
static void init_internal()
{
if (!denydb_initialized) {
denydb_init(0);
denydb_init();
cyrus_modules_add(done_cb, NULL);
}
if (!denydb) {
Expand All @@ -357,11 +357,8 @@ static void init_internal()
}

/* must be called after cyrus_init */
EXPORTED void denydb_init(int myflags)
EXPORTED void denydb_init(void)
{
if (myflags & DENYDB_SYNC) {
cyrusdb_sync(DENYDB);
}
denydb_initialized = 1;
}

Expand Down
11 changes: 0 additions & 11 deletions lib/cyrusdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -628,12 +628,6 @@ EXPORTED const char *cyrusdb_detect(const char *fname)
return NULL;
}

EXPORTED int cyrusdb_sync(const char *backend)
{
struct cyrusdb_backend *db = cyrusdb_fromname(backend);
return db->sync();
}

EXPORTED int cyrusdb_unlink(const char *backend, const char *fname, int flags)
{
struct cyrusdb_backend *db = cyrusdb_fromname(backend);
Expand Down Expand Up @@ -680,11 +674,6 @@ HIDDEN int cyrusdb_generic_done(void)
return 0;
}

HIDDEN int cyrusdb_generic_sync(void)
{
return 0;
}

HIDDEN int cyrusdb_generic_archive(const strarray_t *fnames,
const char *dirname)
{
Expand Down
5 changes: 0 additions & 5 deletions lib/cyrusdb.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,6 @@ struct cyrusdb_backend {
* to reset state */
int (*done)(void);

/* checkpoints this database environment */
int (*sync)(void);

/* archives this database environment, and specified databases
* into the specified directory */
int (*archive)(const strarray_t *fnames, const char *dirname);
Expand Down Expand Up @@ -304,7 +301,6 @@ extern int cyrusdb_compar(struct db *db,

/* somewhat special case, because they don't take a DB */

extern int cyrusdb_sync(const char *backend);
extern cyrusdb_archiver *cyrusdb_getarchiver(const char *backend);

extern int cyrusdb_canfetchnext(const char *backend);
Expand All @@ -314,7 +310,6 @@ extern strarray_t *cyrusdb_backends(void);
/* generic implementations */
int cyrusdb_generic_init(const char *dbdir, int myflags);
int cyrusdb_generic_done(void);
int cyrusdb_generic_sync(void);
int cyrusdb_generic_archive(const strarray_t *fnames, const char *dirname);
int cyrusdb_generic_noarchive(const strarray_t *fnames, const char *dirname);
int cyrusdb_generic_unlink(const char *fname, int flags);
Expand Down
1 change: 0 additions & 1 deletion lib/cyrusdb_flat.c
Original file line number Diff line number Diff line change
Expand Up @@ -847,7 +847,6 @@ EXPORTED struct cyrusdb_backend cyrusdb_flat =

&cyrusdb_generic_init,
&cyrusdb_generic_done,
&cyrusdb_generic_sync,
&cyrusdb_generic_archive,
&cyrusdb_generic_unlink,

Expand Down
1 change: 0 additions & 1 deletion lib/cyrusdb_quotalegacy.c
Original file line number Diff line number Diff line change
Expand Up @@ -907,7 +907,6 @@ HIDDEN struct cyrusdb_backend cyrusdb_quotalegacy =

&cyrusdb_generic_init,
&cyrusdb_generic_done,
&cyrusdb_generic_sync,
&cyrusdb_generic_noarchive,
&cyrusdb_generic_unlink,

Expand Down
1 change: 0 additions & 1 deletion lib/cyrusdb_skiplist.c
Original file line number Diff line number Diff line change
Expand Up @@ -2478,7 +2478,6 @@ EXPORTED struct cyrusdb_backend cyrusdb_skiplist =

&myinit,
&cyrusdb_generic_done,
&cyrusdb_generic_sync,
&cyrusdb_generic_archive,
&cyrusdb_generic_unlink,

Expand Down
1 change: 0 additions & 1 deletion lib/cyrusdb_sql.c
Original file line number Diff line number Diff line change
Expand Up @@ -925,7 +925,6 @@ HIDDEN struct cyrusdb_backend cyrusdb_sql =

&init,
&done,
&cyrusdb_generic_sync,
&cyrusdb_generic_noarchive,
NULL,

Expand Down
1 change: 0 additions & 1 deletion lib/cyrusdb_twoskip.c
Original file line number Diff line number Diff line change
Expand Up @@ -2605,7 +2605,6 @@ HIDDEN struct cyrusdb_backend cyrusdb_twoskip =

&cyrusdb_generic_init,
&cyrusdb_generic_done,
&cyrusdb_generic_sync,
&cyrusdb_generic_archive,
&cyrusdb_generic_unlink,

Expand Down

0 comments on commit fecb8fc

Please sign in to comment.