trigger SIGPIPE...
[metze/samba/wip.git] / source4 / wrepl_server / wrepl_in_connection.c
index dc6beb3f2ad5753c306e7b7ddaf3c5c51f8de998..b219a1797ee75f14f9561b7deebfec3d443eee3a 100644 (file)
@@ -65,7 +65,9 @@ static NTSTATUS wreplsrv_process(struct wreplsrv_in_connection *wrepl_conn,
        }
 
        status = wreplsrv_in_call(call);
-       NT_STATUS_IS_ERR_RETURN(status);
+       if (NT_STATUS_IS_ERR(status)) {
+               return status;
+       }
        if (!NT_STATUS_IS_OK(status)) {
                /* w2k just ignores invalid packets, so we do */
                DEBUG(10,("Received WINS-Replication packet was invalid, we just ignore it\n"));
@@ -106,6 +108,10 @@ static void wreplsrv_accept(struct stream_connection *conn)
        struct tevent_req *subreq;
        int rc;
 
+       smb_msleep(1000);
+               stream_terminate_connection(conn,
+                                           "wrepl_accept: test");
+               return;
        wrepl_conn = talloc_zero(conn, struct wreplsrv_in_connection);
        if (wrepl_conn == NULL) {
                stream_terminate_connection(conn,
@@ -345,24 +351,15 @@ static const struct stream_server_ops wreplsrv_stream_ops = {
 NTSTATUS wreplsrv_in_connection_merge(struct wreplsrv_partner *partner,
                                      uint32_t peer_assoc_ctx,
                                      struct tstream_context **stream,
-                                     struct wreplsrv_in_connection **_wrepl_in)
+                                     struct wreplsrv_in_connection **_wrepl_in,
+                                     void* process_context)
 {
        struct wreplsrv_service *service = partner->service;
        struct wreplsrv_in_connection *wrepl_in;
-       const struct model_ops *model_ops;
        struct stream_connection *conn;
        struct tevent_req *subreq;
        NTSTATUS status;
 
-       /* within the wrepl task we want to be a single process, so
-          ask for the single process model ops and pass these to the
-          stream_setup_socket() call. */
-       model_ops = process_model_startup("single");
-       if (!model_ops) {
-               DEBUG(0,("Can't find 'single' process model_ops"));
-               return NT_STATUS_INTERNAL_ERROR;
-       }
-
        wrepl_in = talloc_zero(partner, struct wreplsrv_in_connection);
        NT_STATUS_HAVE_NO_MEMORY(wrepl_in);
 
@@ -373,11 +370,12 @@ NTSTATUS wreplsrv_in_connection_merge(struct wreplsrv_partner *partner,
 
        status = stream_new_connection_merge(service->task->event_ctx,
                                             service->task->lp_ctx,
-                                            model_ops,
+                                            service->task->model_ops,
                                             &wreplsrv_stream_ops,
                                             service->task->msg_ctx,
                                             wrepl_in,
-                                            &conn);
+                                            &conn,
+                                            process_context);
        NT_STATUS_NOT_OK_RETURN(status);
 
        /*
@@ -423,25 +421,15 @@ NTSTATUS wreplsrv_setup_sockets(struct wreplsrv_service *service, struct loadpar
 {
        NTSTATUS status;
        struct task_server *task = service->task;
-       const struct model_ops *model_ops;
        const char *address;
        uint16_t port = WINS_REPLICATION_PORT;
 
-       /* within the wrepl task we want to be a single process, so
-          ask for the single process model ops and pass these to the
-          stream_setup_socket() call. */
-       model_ops = process_model_startup("single");
-       if (!model_ops) {
-               DEBUG(0,("Can't find 'single' process model_ops"));
-               return NT_STATUS_INTERNAL_ERROR;
-       }
-
        if (lpcfg_interfaces(lp_ctx) && lpcfg_bind_interfaces_only(lp_ctx)) {
                int num_interfaces;
                int i;
                struct interface *ifaces;
 
-               load_interface_list(task, lpcfg_interfaces(lp_ctx), &ifaces);
+               load_interface_list(task, lp_ctx, &ifaces);
 
                num_interfaces = iface_list_count(ifaces);
 
@@ -450,13 +438,18 @@ NTSTATUS wreplsrv_setup_sockets(struct wreplsrv_service *service, struct loadpar
                   socket per interface and bind to only these.
                */
                for(i = 0; i < num_interfaces; i++) {
+                       if (!iface_list_n_is_v4(ifaces, i)) {
+                               continue;
+                       }
                        address = iface_list_n_ip(ifaces, i);
-                       status = stream_setup_socket(task, task->event_ctx,
-                                                    task->lp_ctx, model_ops,
-                                                    &wreplsrv_stream_ops,
-                                                    "ipv4", address, &port, 
-                                                     lpcfg_socket_options(task->lp_ctx),
-                                                    service);
+                       status = stream_setup_socket(
+                                       task, task->event_ctx,
+                                       task->lp_ctx,
+                                       task->model_ops,
+                                       &wreplsrv_stream_ops,
+                                       "ipv4", address, &port,
+                                       lpcfg_socket_options(task->lp_ctx),
+                                       service, task->process_context);
                        if (!NT_STATUS_IS_OK(status)) {
                                DEBUG(0,("stream_setup_socket(address=%s,port=%u) failed - %s\n",
                                         address, port, nt_errstr(status)));
@@ -464,11 +457,13 @@ NTSTATUS wreplsrv_setup_sockets(struct wreplsrv_service *service, struct loadpar
                        }
                }
        } else {
-               address = lpcfg_socket_address(lp_ctx);
-               status = stream_setup_socket(task, task->event_ctx, task->lp_ctx,
-                                            model_ops, &wreplsrv_stream_ops,
-                                            "ipv4", address, &port, lpcfg_socket_options(task->lp_ctx),
-                                            service);
+               address = "0.0.0.0";
+               status = stream_setup_socket(task, task->event_ctx,
+                                            task->lp_ctx, task->model_ops,
+                                            &wreplsrv_stream_ops,
+                                            "ipv4", address, &port,
+                                            lpcfg_socket_options(task->lp_ctx),
+                                            service, task->process_context);
                if (!NT_STATUS_IS_OK(status)) {
                        DEBUG(0,("stream_setup_socket(address=%s,port=%u) failed - %s\n",
                                 address, port, nt_errstr(status)));