2 Unix SMB/CIFS implementation.
3 process model: process (1 process handles all client connections)
4 Copyright (C) Andrew Tridgell 2003
5 Copyright (C) James J Myers 2003 <myersjj@samba.org>
6 Copyright (C) Stefan (metze) Metzmacher 2004
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 #include "dlinklist.h"
26 #include "smb_server/smb_server.h"
27 #include "process_model.h"
31 called when the process model is selected
33 static void single_start_server(void)
39 called when a listening socket becomes readable
41 static void single_accept_connection(struct event_context *ev, struct fd_event *srv_fde,
42 struct timeval t, uint16_t flags)
45 struct socket_context *sock;
46 struct server_socket *server_socket = srv_fde->private;
47 struct server_connection *conn;
49 /* accept an incoming connection. */
50 status = socket_accept(server_socket->socket, &sock);
51 if (!NT_STATUS_IS_OK(status)) {
52 DEBUG(0,("accept_connection_single: accept: %s\n",
57 conn = server_setup_connection(ev, server_socket, sock, t, socket_get_fd(sock));
59 DEBUG(0,("server_setup_connection failed\n"));
63 talloc_steal(conn, sock);
65 DLIST_ADD(server_socket->connection_list,conn);
67 /* return to event handling */
73 /* called when a SMB connection goes down */
74 static void single_terminate_connection(struct server_connection *conn, const char *reason)
76 DEBUG(2,("single_terminate_connection: reason[%s]\n",reason));
83 static int single_get_id(struct smbsrv_request *req)
85 return (int)req->smb_conn->pid;
88 static void single_exit_server(struct server_context *srv_ctx, const char *reason)
90 DEBUG(1,("single_exit_server: reason[%s]\n",reason));
94 initialise the single process model, registering ourselves with the process model subsystem
96 NTSTATUS process_model_single_init(void)
103 /* fill in our name */
106 /* fill in all the operations */
107 ops.model_startup = single_start_server;
108 ops.accept_connection = single_accept_connection;
109 ops.terminate_connection = single_terminate_connection;
110 ops.exit_server = single_exit_server;
111 ops.get_id = single_get_id;
113 /* register ourselves with the PROCESS_MODEL subsystem. */
114 ret = register_backend("process_model", &ops);
115 if (!NT_STATUS_IS_OK(ret)) {
116 DEBUG(0,("Failed to register process_model 'single'!\n"));