Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / ceph / src / rgw / rgw_request.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
3
4 #ifndef RGW_REQUEST_H
5 #define RGW_REQUEST_H
6
7 #include "rgw_common.h"
8 #include "rgw_rados.h"
9 #include "rgw_acl.h"
10 #include "rgw_user.h"
11 #include "rgw_op.h"
12 #if defined(WITH_RADOSGW_FCGI_FRONTEND)
13 #include "rgw_fcgi.h"
14 #endif
15
16 #include "common/QueueRing.h"
17
18 #include <atomic>
19
20 struct RGWRequest
21 {
22   uint64_t id;
23   struct req_state *s;
24   string req_str;
25   RGWOp *op;
26   utime_t ts;
27
28   explicit RGWRequest(uint64_t id) : id(id), s(NULL), op(NULL) {}
29
30   virtual ~RGWRequest() {}
31
32   void init_state(req_state *_s) {
33     s = _s;
34   }
35
36   void log_format(struct req_state *s, const char *fmt, ...);
37   void log_init();
38   void log(struct req_state *s, const char *msg);
39 }; /* RGWRequest */
40
41 #if defined(WITH_RADOSGW_FCGI_FRONTEND)
42 struct RGWFCGXRequest : public RGWRequest {
43   FCGX_Request *fcgx;
44   QueueRing<FCGX_Request *> *qr;
45
46   RGWFCGXRequest(uint64_t req_id, QueueRing<FCGX_Request *> *_qr)
47           : RGWRequest(req_id), qr(_qr) {
48     qr->dequeue(&fcgx);
49   }
50
51   ~RGWFCGXRequest() override {
52     FCGX_Finish_r(fcgx);
53     qr->enqueue(fcgx);
54   }
55 };
56 #endif
57
58 struct RGWLoadGenRequest : public RGWRequest {
59         string method;
60         string resource;
61         int content_length;
62         std::atomic<bool>* fail_flag = nullptr;
63
64 RGWLoadGenRequest(uint64_t req_id, const string& _m, const  string& _r, int _cl,
65                 std::atomic<bool> *ff)
66         : RGWRequest(req_id), method(_m), resource(_r), content_length(_cl),
67                 fail_flag(ff) {}
68 };
69
70 #endif /* RGW_REQUEST_H */