}
-static int mongoose_callback(struct mg_event *event) {
- RGWProcessEnv *pe = (RGWProcessEnv *)event->user_data;
+static int mongoose_callback(struct mg_connection *conn) {
+ struct mg_request_info *req_info = mg_get_request_info(conn);
+ RGWProcessEnv *pe = (RGWProcessEnv *)req_info->user_data;
RGWRados *store = pe->store;
RGWREST *rest = pe->rest;
OpsLogSocket *olog = pe->olog;
- if (event->type != MG_REQUEST_BEGIN)
- return 0;
-
RGWRequest *req = new RGWRequest;
int ret;
- RGWMongoose client_io(event);
+ RGWMongoose client_io(conn);
client_io.init(g_ceph_context);
char port_buf[32];
snprintf(port_buf, sizeof(port_buf), "%d", (int)g_conf->rgw_standalone_server_port);
- const char *options[] = {"listening_ports", port_buf, "enable_keep_alive", "yes", NULL};
+ char thread_pool_buf[32];
+ snprintf(thread_pool_buf, sizeof(thread_pool_buf), "%d", (int)g_conf->rgw_thread_pool_size);
+ const char *options[] = {"listening_ports", port_buf, "enable_keep_alive", "yes", "num_threads", thread_pool_buf, NULL};
- ctx = mg_start((const char **)&options, &mongoose_callback, &pe);
+ struct mg_callbacks cb;
+ memset((void *)&cb, 0, sizeof(cb));
+ cb.begin_request = mongoose_callback;
+ ctx = mg_start(&cb, &pe, (const char **)&options);
assert(ctx);
}
data.append(buf, len);
return 0;
}
- return mg_write(event->conn, buf, len);
+ return mg_write(conn, buf, len);
}
-RGWMongoose::RGWMongoose(mg_event *_event) : event(_event), header_done(false), sent_header(false), has_content_length(false) {
+RGWMongoose::RGWMongoose(mg_connection *_conn) : conn(_conn), header_done(false), sent_header(false), has_content_length(false) {
}
int RGWMongoose::read_data(char *buf, int len)
{
- return mg_read(event->conn, buf, len);
+ return mg_read(conn, buf, len);
}
void RGWMongoose::flush()
if (!sent_header) {
if (!has_content_length) {
header_done = false; /* let's go back to writing the header */
- int r = send_content_length(data.length());
- if (r < 0)
- return r;
+
+ if (0 && data.length() == 0) {
+ has_content_length = true;
+ print("Transfer-Enconding: %s\n", "chunked");
+ data.append("0\r\n\r\n", sizeof("0\r\n\r\n")-1);
+ } else {
+ int r = send_content_length(data.length());
+ if (r < 0)
+ return r;
+ }
}
complete_header();
void RGWMongoose::init_env(CephContext *cct)
{
env.init(cct);
- struct mg_request_info *info = event->request_info;
+ struct mg_request_info *info = mg_get_request_info(conn);
if (!info)
return;
{
char buf[] = "HTTP/1.1 100 CONTINUE\r\n\r\n";
- return mg_write(event->conn, buf, sizeof(buf) - 1);
+ return mg_write(conn, buf, sizeof(buf) - 1);
}
int RGWMongoose::complete_header()
#include "rgw_client_io.h"
-struct mg_event;
struct mg_connection;
class RGWMongoose : public RGWClientIO
{
- mg_event *event;
+ mg_connection *conn;
bufferlist header_data;
bufferlist data;
int complete_request();
int send_content_length(uint64_t len);
- RGWMongoose(mg_event *_event);
+ RGWMongoose(mg_connection *_conn);
void flush();
};