Skip to content

Commit d4c28c9

Browse files
committed
nsp: delete session_check directive
Sending SIGHUP to the process is meant to reload the GAL. This is done by destroying all ab_base objects on SIGHUP, and recreating ab_base on next use of the AB provider. Each new ab_base object has a GUID of its own, to detect such GAL changes. An NSP client that has connected earlier, recording the GUID of the time, falls prey to seeing a new GUID after SIGHUP, and rejecting all NSP requests. The change of GUID should, with current judgment, not be treated as an error condition. Instead, an NSP session should keep a reference to the earlier ab_base. Considering that minids are stable in Gromox due to being constructed from strictly monotonically increasing SQL user/domain ids makes keeping around old ab_base objects unnecessary. Subsequently, deleting the session_check is the logical choice.
1 parent 789667f commit d4c28c9

File tree

6 files changed

+18
-14
lines changed

6 files changed

+18
-14
lines changed

doc/changelog.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ Enhancements:
1111

1212
Fixes:
1313

14+
* nsp: remove meaningless session_check directive;
15+
no longer erroneously reject requests after daemon received SIGHUP
1416
* oxcical: avoid setting out-of-spec MAPI recurnum for FREQ=MONTHLY,BYDAY=
1517
recurrences
1618
* oxcical: fix wrong BYMONTH calculation for MONTHNTH recurrences being

doc/exchange_nsp.4gx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@ Dump more data.
2424
.br
2525
Default: \fI0\fP
2626
.TP
27-
\fBsession_check\fP
28-
Default: \fIfalse\fP
29-
.TP
3027
\fBx500_org_name\fP
3128
Default: (unspecified)
3229
.SH Notes

exch/nsp/main.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ static constexpr cfg_directive nsp_cfg_defaults[] = {
2929
{"cache_interval", "5min", CFG_TIME, "1s", "1d"},
3030
{"hash_table_size", "3000", CFG_SIZE, "1"},
3131
{"nsp_trace", "0"},
32-
{"session_check", "1", CFG_BOOL},
3332
{"x500_org_name", "Gromox default"},
3433
CFG_TABLE_END,
3534
};
@@ -83,9 +82,6 @@ BOOL PROC_exchange_nsp(enum plugin_op reason, const struct dlfuncs &ppdata)
8382
HX_unit_seconds(temp_buff, std::size(temp_buff), cache_interval, 0);
8483
mlog(LV_INFO, "nsp: address book tree item"
8584
" cache interval is %s", temp_buff);
86-
b_check = pfile->get_ll("session_check");
87-
if (b_check)
88-
mlog(LV_INFO, "nsp: bind session will be checked");
8985
ab_tree::AB.init(org_name, cache_interval);
9086

9187
query_service2("exmdb_client_get_named_propids", get_named_propids);
@@ -137,7 +133,7 @@ BOOL PROC_exchange_nsp(enum plugin_op reason, const struct dlfuncs &ppdata)
137133
mlog(LV_ERR, "nsp: failed to run address book tree");
138134
return FALSE;
139135
}
140-
nsp_interface_init(b_check);
136+
nsp_interface_init();
141137
return TRUE;
142138
}
143139
case PLUGIN_FREE:

exch/nsp/nsp_interface.cpp

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ enum {
5959
};
6060

6161
unsigned int g_nsp_trace;
62-
static bool g_session_check;
6362
static gromox::archive abkt_archive;
6463

6564
static void nsp_trace(const char *func, bool is_exit, const STAT *s,
@@ -565,9 +564,8 @@ static ec_error_t nsp_interface_fetch_row(const ab_tree::ab_node &node,
565564
return ecSuccess;
566565
}
567566

568-
void nsp_interface_init(bool b_check)
567+
void nsp_interface_init()
569568
{
570-
g_session_check = b_check;
571569
static constexpr char pk[] = PKGDATADIR "/abkt.pak";
572570
auto err = abkt_archive.open(pk);
573571
if (err != 0)
@@ -686,7 +684,12 @@ static void nsp_interface_position_in_table(const STAT *pstat,
686684

687685
static inline bool session_check(const NSPI_HANDLE &h, const ab_tree::ab_base &base)
688686
{
689-
return g_session_check && base.guid() == h.guid;
687+
/*
688+
* Gromox minid assignment is stable across reloads;
689+
* at present, there is no need for action when GUIDs are different.
690+
*/
691+
//return do_session_checking && base.guid() == h.guid;
692+
return true;
690693
}
691694

692695
ec_error_t nsp_interface_update_stat(NSPI_HANDLE handle, uint32_t reserved,
@@ -699,7 +702,10 @@ ec_error_t nsp_interface_update_stat(NSPI_HANDLE handle, uint32_t reserved,
699702
auto pbase = ab_tree::AB.get(handle.guid);
700703
if (pbase == nullptr || !session_check(handle, *pbase))
701704
return ecError;
702-
705+
/*
706+
* pbase->guid can be different from handle.guid, but for now that is not
707+
* an actionable condition, as minids are stable across AB reloads.
708+
*/
703709
uint32_t init_row = 0, total = 0;
704710
ab_tree::ab_node node{};
705711
if (0 == pstat->container_id) {
@@ -944,6 +950,8 @@ ec_error_t nsp_interface_seek_entries(NSPI_HANDLE handle, uint32_t reserved,
944950
} else if (pproptags->cvalues > 100) {
945951
return ecTableTooBig;
946952
}
953+
if (handle.handle_type != HANDLE_EXCHANGE_NSP)
954+
return ecError;
947955
auto pbase = ab_tree::AB.get(handle.guid);
948956
if (pbase == nullptr || !session_check(handle, *pbase))
949957
return ecError;

exch/nsp/nsp_interface.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
#include "nsp_types.hpp"
66

7-
extern void nsp_interface_init(bool b_check);
7+
extern void nsp_interface_init();
88
extern ec_error_t nsp_interface_bind(uint64_t hrpc, uint32_t flags, const STAT *, FLATUID *server_guid, NSPI_HANDLE *);
99
extern ec_error_t nsp_interface_unbind(NSPI_HANDLE *, uint32_t);
1010
extern ec_error_t nsp_interface_update_stat(NSPI_HANDLE, uint32_t, STAT *, int32_t *delta);

lib/ab_tree.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <gromox/proc_common.h>
1212
#include <gromox/usercvt.hpp>
1313
#include <gromox/util.hpp>
14+
#include <gromox/process.hpp>
1415

1516
namespace gromox::ab_tree
1617
{

0 commit comments

Comments
 (0)