Skip to content

Commit 6d6ac34

Browse files
committed
Revert "mbop: add sync_mailbox operation of midb to mbop"
This reverts commit c01e4bc. When midb is not running, it delays the execution of gromox-mbop. References: GXH-192
1 parent d0af839 commit 6d6ac34

File tree

8 files changed

+5
-124
lines changed

8 files changed

+5
-124
lines changed

Makefile.am

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ gromox_mbck_SOURCES = tools/mbck.cpp
199199
gromox_mbck_LDADD = ${libHX_LIBS} ${fmt_LIBS} ${sqlite_LIBS} libgromox_common.la
200200
gromox_mbop_SOURCES = tools/genimport.cpp tools/genimport.hpp tools/mbop.hpp tools/mbop.cpp
201201
EXTRA_DIST += tools/mbop_delmsg.cpp tools/mbop_emptyfld.cpp tools/mbop_foreach.cpp tools/mbop_freebusy.cpp tools/mbop_locale.cpp tools/mbop_main.cpp tools/mbop_purge.cpp tools/staticnpmap.cpp
202-
gromox_mbop_LDADD = ${libHX_LIBS} ${mysql_LIBS} libgromox_common.la libgromox_exrpc.la libgromox_mapi.la libgxs_mysql_adaptor.la libgxs_midb_agent.la
202+
gromox_mbop_LDADD = ${libHX_LIBS} ${mysql_LIBS} libgromox_common.la libgromox_exrpc.la libgromox_mapi.la libgxs_mysql_adaptor.la
203203
gromox_mbsize_SOURCES = tools/mbsize.cpp
204204
gromox_mbsize_LDADD = ${sqlite_LIBS} libgromox_common.la
205205
gromox_mkmidb_SOURCES = tools/mkmidb.cpp tools/mkshared.cpp tools/mkshared.hpp

doc/changelog.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ Enhancements:
3939
* dscli: try all oxdisco URLs until one succeeds
4040
* exmdb: support repeated import of permission data (e.g. from kdb2mt)
4141
* ews: create calendar item after accepting a MR with MacMail
42-
* mbop: new `sync-midb` subcommand to prebuild midb caches ahead of the first IMAP login
4342

4443
Fixes:
4544

doc/gromox-mbop.8

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,6 @@ set\-photo: read user image from stdin and save to store
6969
set\-websettings, set\-websettings\-persistent, set\-websettings\-recipients:
7070
read new grommunio-web settings from stdin and save to store
7171
.IP \(bu 4
72-
sync\-midb: trigger a midb synchronization run
73-
.IP \(bu 4
7472
thaw: unfreeze a mailbox
7573
.IP \(bu 4
7674
unload: issue the "unload_store" RPC for a mailbox
@@ -325,21 +323,6 @@ Reads various grommunio-web settings from the store and dumps it to stdout.
325323
Causes the respective mailbox to be opened by the server. (Any request to the
326324
information storage server causes the respective mailbox to be opened; and ping
327325
is technically just a no-op request type.)
328-
.SH sync\-midb
329-
.SS Synopsis
330-
\fBsync-midb\fP [\fB\-f\fP \fIfolder_spec\fP]
331-
.SS Description
332-
Sends a request to midb for opening the mailbox and updating the midb-specific
333-
folder indices, as well as potentially building RFC5322 representations for
334-
newly-appeared messages. (Once the mailbox is open in midb, it uses
335-
asynchronous notifications to stay up to date.) Due to implementation details
336-
of the midb connector, requests will time out after 60 second, even if sync
337-
procedure inside the midb daemon keeps running in the background.
338-
.SS Options
339-
.TP
340-
\fB\-f\fP \fIfolder_spec\fP
341-
Forcibly rerun the sync routine for a single specific folder. See section
342-
"Folder specification". In addition, the special keyword "all" is recognized.
343326
.SH purge\-datafiles
344327
The "purge\-datafiles" RPC makes exmdb_provider remove attachment and content
345328
files from disk that are no longer referenced by any message.

exch/midb/mail_engine.cpp

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3550,20 +3550,12 @@ static int me_xunld(int argc, char **argv, int sockd)
35503550
* Request:
35513551
* X-RSYM <store-dir>
35523552
* Response:
3553-
* TRUE 0: synchro failure
3554-
* TRUE 1: was loaded before (tracking changes live), now is synchronized
3555-
* TRUE 2: was unloaded before (not tracking), now is synchronized
3553+
* TRUE <0|1|2>
35563554
*/
35573555
static int me_xrsym(int argc, char **argv, int sockd)
35583556
{
35593557
auto idb = me_peek_idb(argv[1]);
35603558
if (idb == nullptr) {
3561-
/*
3562-
* There is a time between me_peek_idb and me_get_idb that
3563-
* another thread may have invoked me_get_idb and already
3564-
* triggered an initial sync. Therefore, we are passing `true`
3565-
* here to force resync in any case.
3566-
*/
35673559
me_get_idb(argv[1], true);
35683560
return cmd_write(sockd, "TRUE 2\r\n");
35693561
} else if (!me_sync_mailbox(idb.get(), true)) {

include/gromox/midb_agent.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ extern GX_EXPORT int summary_folder(const char *path, const std::string &folder,
4646
extern GX_EXPORT int make_folder(const char *path, const std::string &folder, int *perrno);
4747
extern GX_EXPORT int remove_folder(const char *path, const std::string &folder, int *perrno);
4848
extern GX_EXPORT int ping_mailbox(const char *path, int *perrno);
49-
extern GX_EXPORT int sync_mailbox(const char *path, uint64_t folder_id, int *err);
5049
extern GX_EXPORT int rename_folder(const char *path, const std::string &src_name, const std::string &dst_name, int *perrno);
5150
extern GX_EXPORT int subscribe_folder(const char *path, const std::string &folder, int *perrno);
5251
extern GX_EXPORT int unsubscribe_folder(const char *path, const std::string &folder, int *perrno);

mra/midb_agent.cpp

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -745,33 +745,6 @@ int ping_mailbox(const char *path, int *perrno)
745745
return MIDB_RDWR_ERROR;
746746
}
747747

748-
int sync_mailbox(const char *path, uint64_t folder_id, int *err)
749-
{
750-
auto conn = get_connection(path);
751-
if (conn == nullptr)
752-
return MIDB_NO_SERVER;
753-
char buf[1024];
754-
int len;
755-
if (folder_id == 0)
756-
len = gx_snprintf(buf, std::size(buf), "X-RSYM %s\r\n", path);
757-
else
758-
len = gx_snprintf(buf, std::size(buf), "X-RSYF %s %llu\r\n",
759-
path, static_cast<unsigned long long>(folder_id));
760-
auto ret = rw_command(conn->sockd, buf, len, std::size(buf));
761-
if (ret != 0)
762-
return ret;
763-
if (strncmp(buf, "TRUE", 4) == 0) {
764-
conn.reset();
765-
return MIDB_RESULT_OK;
766-
} else if (strncmp(buf, "FALSE ", 6) == 0) {
767-
conn.reset();
768-
if (err != nullptr)
769-
*err = strtol(&buf[6], nullptr, 0);
770-
return MIDB_RESULT_ERROR;
771-
}
772-
return MIDB_RDWR_ERROR;
773-
}
774-
775748
int rename_folder(const char *path, const std::string &src_name,
776749
const std::string &dst_name, int *perrno)
777750
{

tools/mbop.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ namespace foreach_wrap { extern int main(int, char **); }
2121
namespace getfreebusy { extern int main(int, char **); }
2222
namespace purgesoftdel { extern int main(int, char **); }
2323
namespace set_locale { extern int main(int, char **); }
24-
namespace sync_midb { extern int main(int, char **); }
2524

2625
namespace global {
2726

tools/mbop_main.cpp

Lines changed: 3 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
#include <gromox/exmdb_rpc.hpp>
1818
#include <gromox/freebusy.hpp>
1919
#include <gromox/mapidefs.h>
20-
#include <gromox/midb_agent.hpp>
2120
#include <gromox/mysql_adaptor.hpp>
2221
#include <gromox/process.hpp>
2322
#include <gromox/svc_loader.hpp>
@@ -212,65 +211,6 @@ static int freeze_main(int argc, char **argv)
212211

213212
}
214213

215-
namespace sync_midb {
216-
217-
static const char *g_folder_spec;
218-
static constexpr HXoption g_options_table[] = {
219-
{{}, 'f', HXTYPE_STRP, &g_folder_spec, {}, {}, {}, "Forcibly rescan this folder", "SPEC"},
220-
MBOP_AUTOHELP,
221-
HXOPT_TABLEEND,
222-
};
223-
224-
int main(int argc, char **argv)
225-
{
226-
HXopt6_auto_result argp;
227-
228-
if (HX_getopt6(g_options_table, argc, argv, nullptr,
229-
HXOPT_USAGEONERR) != HXOPT_ERR_SUCCESS || g_exit_after_optparse)
230-
return EXIT_PARAM;
231-
232-
int err = 0, ret;
233-
if (g_folder_spec == nullptr) {
234-
ret = midb_agent::ping_mailbox(g_storedir, &err);
235-
} else if (strcasecmp(g_folder_spec, "all") == 0) {
236-
ret = midb_agent::sync_mailbox(g_storedir, 0, &err);
237-
} else {
238-
eid_t eid = gi_lookup_eid_by_name(g_storedir, g_folder_spec);
239-
if (eid == 0) {
240-
mbop_fprintf(stderr, "Not recognized/found: \"%s\"\n", g_folder_spec);
241-
return EXIT_FAILURE;
242-
}
243-
ret = midb_agent::sync_mailbox(g_storedir, eid.gcv(), &err);
244-
}
245-
switch (ret) {
246-
case MIDB_RESULT_OK:
247-
if (global::g_verbose_mode)
248-
printf("midb sync triggered\n");
249-
return EXIT_SUCCESS;
250-
case MIDB_RESULT_ERROR:
251-
mbop_fprintf(stderr, "midb sync failed: backend returned %d\n", err);
252-
break;
253-
case MIDB_NO_SERVER:
254-
mbop_fprintf(stderr, "midb sync failed: midb backend unavailable\n");
255-
break;
256-
case MIDB_RDWR_ERROR:
257-
mbop_fprintf(stderr, "midb sync failed: protocol error while talking to midb\n");
258-
break;
259-
case MIDB_LOCAL_ENOMEM:
260-
mbop_fprintf(stderr, "midb sync failed: local memory exhausted\n");
261-
break;
262-
case MIDB_TOO_MANY_RESULTS:
263-
mbop_fprintf(stderr, "midb sync failed: backend returned too much data\n");
264-
break;
265-
default:
266-
mbop_fprintf(stderr, "midb sync failed: unexpected midb agent status %d\n", ret);
267-
break;
268-
}
269-
return EXIT_FAILURE;
270-
}
271-
272-
}
273-
274214
static errno_t resolvename(const GUID &guid, const char *name, bool create,
275215
uint16_t *out)
276216
{
@@ -486,10 +426,8 @@ static int single_user_wrap(int argc, char **argv)
486426
return ret;
487427
}
488428

489-
static constexpr generic_module g_dfl_svc_plugins[] = {
490-
{"libgxs_mysql_adaptor.so", SVC_mysql_adaptor},
491-
{"libgxs_midb_agent.so", SVC_midb_agent},
492-
};
429+
static constexpr generic_module g_dfl_svc_plugins[] =
430+
{{"libgxs_mysql_adaptor.so", SVC_mysql_adaptor}};
493431

494432
int main(int argc, char **argv)
495433
{
@@ -509,7 +447,7 @@ int main(int argc, char **argv)
509447
argv = result.uarg;
510448
if (argc == 0)
511449
return global::help();
512-
service_init({nullptr, g_dfl_svc_plugins, 2});
450+
service_init({nullptr, g_dfl_svc_plugins, 1});
513451
auto cl_1 = HX::make_scope_exit(service_stop);
514452
if (service_run_early() != 0 || service_run() != 0) {
515453
fprintf(stderr, "service_run: failed\n");
@@ -597,8 +535,6 @@ int cmd_parser(int argc, char **argv)
597535
return set_locale::main(argc, argv);
598536
else if (strcmp(argv[0], "get-freebusy") == 0 || strcmp(argv[0], "gfb") == 0)
599537
return getfreebusy::main(argc, argv);
600-
else if (strcmp(argv[0], "sync-midb") == 0)
601-
return sync_midb::main(argc, argv);
602538

603539
if (strcmp(argv[0], "clear-profile") == 0) {
604540
auto ret = delstoreprop(argc, argv, PSETID_Gromox, "zcore_profsect", PT_BINARY);

0 commit comments

Comments
 (0)