blob: e801972ea801f368f5aae29b40e9401987984690 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab ft=cpp
#include "common/Thread.h"
#include "include/compat.h"
#include "common/errno.h"
#include "rgw_common.h"
#include "rgw_kmip_client.h"
#include <atomic>
#define dout_context g_ceph_context
#define dout_subsys ceph_subsys_rgw
RGWKMIPManager *rgw_kmip_manager;
int
RGWKMIPTransceiver::wait(optional_yield y)
{
if (done)
return ret;
std::unique_lock l{lock};
if (!done)
cond.wait(l);
if (ret) {
lderr(cct) << "kmip process failed, " << ret << dendl;
}
return ret;
}
int
RGWKMIPTransceiver::send()
{
int r = rgw_kmip_manager->add_request(this);
if (r < 0) {
lderr(cct) << "kmip send failed, " << r << dendl;
}
return r;
}
int
RGWKMIPTransceiver::process(optional_yield y)
{
int r = send();
if (r < 0)
return r;
return wait(y);
}
RGWKMIPTransceiver::~RGWKMIPTransceiver()
{
int i;
if (out)
free(out);
out = nullptr;
if (outlist->strings) {
for (i = 0; i < outlist->string_count; ++i) {
free(outlist->strings[i]);
}
free(outlist->strings);
outlist->strings = 0;
}
if (outkey->data) {
::ceph::crypto::zeroize_for_security(outkey->data, outkey->keylen);
free(outkey->data);
outkey->data = 0;
}
}
void
rgw_kmip_client_init(RGWKMIPManager &m)
{
rgw_kmip_manager = &m;
rgw_kmip_manager->start();
}
void
rgw_kmip_client_cleanup()
{
rgw_kmip_manager->stop();
delete rgw_kmip_manager;
}
|