-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
exmdb_client: discard connections when EOF is detected
After an unsuccessful RPC (and the response delivered to the client), the exmdb server may close the connection. The closing however is only noticed by the client at the next call, where it is erroneously interpreted as that second RPC failing. Whenever the client draws a connection from the connpool, evaluate whether the file descriptor is still usable, else ditch it.
- Loading branch information
Showing
5 changed files
with
74 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// SPDX-License-Identifier: AGPL-3.0-or-later | ||
// SPDX-FileCopyrightText: 2024 grommunio GmbH | ||
// This file is part of Gromox. | ||
#include <cstdint> | ||
#include <cstdlib> | ||
#include <gromox/exmdb_client.hpp> | ||
#include <gromox/exmdb_rpc.hpp> | ||
#include <gromox/paths.h> | ||
#include <gromox/util.hpp> | ||
|
||
using namespace gromox; | ||
namespace exmdb_client = exmdb_client_remote; | ||
|
||
int main(int argc, char **argv) | ||
{ | ||
exmdb_client_init(1, 0); | ||
if (exmdb_client_run(PKGSYSCONFDIR) != 0) | ||
return EXIT_FAILURE; | ||
|
||
static constexpr STORE_ENTRYID other_store = {0, 0, 0, 0, {}, 0, deconst(""), deconst("")}; | ||
const char *g_storedir = argc == 1 ? "/" : argv[1]; | ||
char *newdir = nullptr; | ||
unsigned int user_id = 0, domain_id = 0; | ||
|
||
printf("req 1\n"); | ||
if (!exmdb_client::store_eid_to_user(g_storedir, &other_store, &newdir, | ||
&user_id, &domain_id)) | ||
mlog(LV_DEBUG, "store_eid_to_user failed as expected"); | ||
else | ||
mlog(LV_ERR, "store_eid_to_user unexpectedly succeeded"); | ||
// Connection should have died by now | ||
printf("req 2\n"); | ||
|
||
static constexpr uint32_t tags[] = {PR_STORE_RECORD_KEY}; | ||
static constexpr PROPTAG_ARRAY ptags[] = {std::size(tags), deconst(tags)}; | ||
TPROPVAL_ARRAY props{}; | ||
exmdb_client::get_store_properties(g_storedir, CP_UTF8, ptags, &props); | ||
return 0; | ||
} |