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