]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: update code to handle mongoose v4.1
authorYehuda Sadeh <yehuda@inktank.com>
Thu, 24 Oct 2013 21:15:10 +0000 (14:15 -0700)
committerYehuda Sadeh <yehuda@inktank.com>
Tue, 5 Nov 2013 04:28:14 +0000 (20:28 -0800)
Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
src/rgw/rgw_main.cc
src/rgw/rgw_mongoose.cc
src/rgw/rgw_mongoose.h

index 930eb3914e87dffb0b710f45f4b690d89608b48b..fe615a18df10422ff0da4d458aa043ec736488e6 100644 (file)
@@ -431,18 +431,16 @@ done:
 }
 
 
-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);
 
@@ -738,9 +736,14 @@ int main(int argc, const char **argv)
     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);
   }
 
index 65ce020f93f90ec4f9611ee48a783c8ddec442b1..a941572889cc79baa226ca2b078187ca230a6e30 100644 (file)
@@ -17,15 +17,15 @@ int RGWMongoose::write_data(const char *buf, int len)
     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()
@@ -37,9 +37,16 @@ int RGWMongoose::complete_request()
   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();
@@ -58,7 +65,7 @@ int RGWMongoose::complete_request()
 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;
 
@@ -129,7 +136,7 @@ int RGWMongoose::send_100_continue()
 {
   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()
index 9454d90a0dabbe5332612de560a5e36a59bcdc27..f6a7c923321d58fbec1970a765464d13de1aa75e 100644 (file)
@@ -4,13 +4,12 @@
 #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;
@@ -31,7 +30,7 @@ public:
   int complete_request();
   int send_content_length(uint64_t len);
 
-  RGWMongoose(mg_event *_event);
+  RGWMongoose(mg_connection *_conn);
   void flush();
 };