]>
git.proxmox.com Git - ceph.git/blob - ceph/src/rgw/rgw_fcgi_process.cc
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab ft=cpp
4 #include "common/errno.h"
5 #include "common/Throttle.h"
6 #include "common/WorkQueue.h"
9 #include "rgw_frontend.h"
10 #include "rgw_request.h"
11 #include "rgw_process.h"
12 #include "rgw_loadgen.h"
13 #include "rgw_client_io.h"
14 #include "rgw_client_io_filters.h"
16 #define dout_subsys ceph_subsys_rgw
18 void RGWFCGXProcess::run()
25 conf
->get_val("socket_path", "", &socket_path
);
26 conf
->get_val("socket_port", g_conf()->rgw_port
, &socket_port
);
27 conf
->get_val("socket_host", g_conf()->rgw_host
, &socket_host
);
28 socket_backlog
= g_conf()->rgw_fcgi_socket_backlog
;
30 if (socket_path
.empty() && socket_port
.empty() && socket_host
.empty()) {
31 socket_path
= g_conf()->rgw_socket_path
;
32 if (socket_path
.empty()) {
33 dout(0) << "ERROR: no socket server point defined, cannot "
34 "start fcgi frontend" << dendl
;
39 if (!socket_path
.empty()) {
40 string path_str
= socket_path
;
42 /* this is necessary, as FCGX_OpenSocket might not return an
43 * error, but rather ungracefully exit */
44 int fd
= open(path_str
.c_str(), O_CREAT
, 0644);
47 /* ENXIO is actually expected, we'll get that if we try to open
48 * a unix domain socket */
50 dout(0) << "ERROR: cannot create socket: path=" << path_str
51 << " error=" << cpp_strerror(err
) << dendl
;
58 const char *path
= path_str
.c_str();
59 sock_fd
= FCGX_OpenSocket(path
, socket_backlog
);
61 dout(0) << "ERROR: FCGX_OpenSocket (" << path
<< ") returned "
65 if (chmod(path
, 0777) < 0) {
66 dout(0) << "WARNING: couldn't set permissions on unix domain socket"
69 } else if (!socket_port
.empty()) {
70 string bind
= socket_host
+ ":" + socket_port
;
71 sock_fd
= FCGX_OpenSocket(bind
.c_str(), socket_backlog
);
73 dout(0) << "ERROR: FCGX_OpenSocket (" << bind
.c_str() << ") returned "
81 FCGX_Request fcgx_reqs
[max_connections
];
83 QueueRing
<FCGX_Request
*> qr(max_connections
);
84 for (int i
= 0; i
< max_connections
; i
++) {
85 FCGX_Request
* fcgx
= &fcgx_reqs
[i
];
86 FCGX_InitRequest(fcgx
, sock_fd
, 0);
91 RGWFCGXRequest
* req
= new RGWFCGXRequest(store
->getRados()->get_new_req_id(), &qr
);
92 dout(10) << "allocated request req=" << hex
<< req
<< dec
<< dendl
;
94 int ret
= FCGX_Accept_r(req
->fcgx
);
97 dout(0) << "ERROR: FCGX_Accept_r returned " << ret
<< dendl
;
107 dout(20) << "cleaning up fcgx connections" << dendl
;
109 for (int i
= 0; i
< max_connections
; i
++) {
110 FCGX_Finish_r(&fcgx_reqs
[i
]);
112 } /* RGWFCGXProcess::run */
114 void RGWFCGXProcess::handle_request(RGWRequest
* r
)
116 RGWFCGXRequest
* const req
= static_cast<RGWFCGXRequest
*>(r
);
118 RGWFCGX
fcgxfe(req
->fcgx
);
119 auto real_client_io
= rgw::io::add_reordering(
120 rgw::io::add_buffering(cct
,
121 rgw::io::add_chunking(
123 RGWRestfulIO
client_io(cct
, &real_client_io
);
126 int ret
= process_request(store
, rest
, req
, uri_prefix
,
127 *auth_registry
, &client_io
, olog
,
128 null_yield
, nullptr);
130 /* we don't really care about return code */
131 dout(20) << "process_request() returned " << ret
<< dendl
;
134 FCGX_Finish_r(req
->fcgx
);
137 } /* RGWFCGXProcess::handle_request */