web_server: Fix initialization.
[ab/samba.git/.git] / source4 / web_server / web_server.c
index 1c7449fb473ed5ecdb270d46a841f41ec3936e56..b2f6f5f4ba22dd2f5d6a7d9be14c0ec842780e46 100644 (file)
 */
 
 #include "includes.h"
-#include "smbd/service_task.h"
-#include "smbd/service_stream.h"
-#include "smbd/service.h"
 #include "web_server/web_server.h"
+#include "../lib/util/dlinklist.h"
+#include "lib/tls/tls.h"
 #include "lib/events/events.h"
-#include "system/filesys.h"
-#include "system/network.h"
 #include "lib/socket/netif.h"
-#include "lib/tls/tls.h"
-#include "../lib/util/dlinklist.h"
 #include "param/param.h"
 
 /* don't allow connections to hang around forever */
@@ -145,7 +140,7 @@ NTSTATUS http_parse_header(struct websrv_context *web, const char *line)
 static void websrv_recv(struct stream_connection *conn, uint16_t flags)
 {
        struct web_server_data *wdata;
-       struct websrv_context *web = talloc_get_type(conn->private
+       struct websrv_context *web = talloc_get_type(conn->private_data,
                                                     struct websrv_context);
        NTSTATUS status;
        uint8_t buf[1024];
@@ -220,7 +215,7 @@ failed:
 */
 static void websrv_send(struct stream_connection *conn, uint16_t flags)
 {
-       struct websrv_context *web = talloc_get_type(conn->private
+       struct websrv_context *web = talloc_get_type(conn->private_data,
                                                     struct websrv_context);
        NTSTATUS status;
        size_t nsent;
@@ -251,7 +246,7 @@ static void websrv_send(struct stream_connection *conn, uint16_t flags)
 */
 static void websrv_accept(struct stream_connection *conn)
 {
-       struct task_server *task = talloc_get_type(conn->private, struct task_server);
+       struct task_server *task = talloc_get_type(conn->private_data, struct task_server);
        struct web_server_data *wdata = talloc_get_type(task->private_data, struct web_server_data);
        struct websrv_context *web;
        struct socket_context *tls_socket;
@@ -261,7 +256,7 @@ static void websrv_accept(struct stream_connection *conn)
 
        web->task = task;
        web->conn = conn;
-       conn->private = web;
+       conn->private_data = web;
        talloc_set_destructor(web, websrv_destructor);
 
        event_add_timed(conn->event.ctx, web, 
@@ -300,60 +295,64 @@ static const struct stream_server_ops web_stream_ops = {
 static void websrv_task_init(struct task_server *task)
 {
        NTSTATUS status;
-       uint16_t port = lp_web_port(task->lp_ctx);
+       uint16_t port = lpcfg_web_port(task->lp_ctx);
        const struct model_ops *model_ops;
        struct web_server_data *wdata;
 
        task_server_set_title(task, "task[websrv]");
 
        /* run the web server as a single process */
-       model_ops = process_model_startup(task->event_ctx, "single");
+       model_ops = process_model_startup("single");
        if (!model_ops) goto failed;
 
-       if (lp_interfaces(task->lp_ctx) && lp_bind_interfaces_only(task->lp_ctx)) {
+       /* startup the Python processor - unfortunately we can't do this
+          per connection as that wouldn't allow for session variables */
+       wdata = talloc_zero(task, struct web_server_data);
+       if (wdata == NULL) goto failed;
+
+       task->private_data = wdata;
+
+       if (lpcfg_interfaces(task->lp_ctx) && lpcfg_bind_interfaces_only(task->lp_ctx)) {
                int num_interfaces;
                int i;
                struct interface *ifaces;
 
-               load_interfaces(NULL, lp_interfaces(task->lp_ctx), &ifaces);
+               load_interfaces(NULL, lpcfg_interfaces(task->lp_ctx), &ifaces);
 
                num_interfaces = iface_count(ifaces);
                for(i = 0; i < num_interfaces; i++) {
                        const char *address = iface_n_ip(ifaces, i);
-                       status = stream_setup_socket(task->event_ctx, 
-                                                    task->lp_ctx, model_ops, 
+                       status = stream_setup_socket(task,
+                                                    task->event_ctx,
+                                                    task->lp_ctx, model_ops,
                                                     &web_stream_ops, 
                                                     "ipv4", address, 
-                                                    &port, lp_socket_options(task->lp_ctx), 
+                                                    &port, lpcfg_socket_options(task->lp_ctx),
                                                     task);
                        if (!NT_STATUS_IS_OK(status)) goto failed;
                }
 
                talloc_free(ifaces);
        } else {
-               status = stream_setup_socket(task->event_ctx, task->lp_ctx,
-                                            model_ops, &web_stream_ops, 
-                                            "ipv4", lp_socket_address(task->lp_ctx), 
-                                            &port, lp_socket_options(task->lp_ctx), task);
+               status = stream_setup_socket(task, task->event_ctx,
+                                            task->lp_ctx, model_ops,
+                                            &web_stream_ops,
+                                            "ipv4", lpcfg_socket_address(task->lp_ctx),
+                                            &port, lpcfg_socket_options(task->lp_ctx),
+                                            task);
                if (!NT_STATUS_IS_OK(status)) goto failed;
        }
 
-       /* startup the esp processor - unfortunately we can't do this
-          per connection as that wouldn't allow for session variables */
-       wdata = talloc_zero(task, struct web_server_data);
-       if (wdata == NULL)goto failed;
-
-       task->private_data = wdata;
-       
        wdata->tls_params = tls_initialise(wdata, task->lp_ctx);
        if (wdata->tls_params == NULL) goto failed;
 
        if (!wsgi_initialize(wdata)) goto failed;
 
+
        return;
 
 failed:
-       task_server_terminate(task, "websrv_task_init: failed to startup web server task");
+       task_server_terminate(task, "websrv_task_init: failed to startup web server task", true);
 }