2 Unix SMB/CIFS implementation.
4 process model: process (1 process handles all client connections)
6 Copyright (C) Andrew Tridgell 2003
7 Copyright (C) James J Myers 2003 <myersjj@samba.org>
8 Copyright (C) Stefan (metze) Metzmacher 2004
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27 #include "dlinklist.h"
28 #include "smb_server/smb_server.h"
32 called when the process model is selected
34 static void single_model_init(struct event_context *ev)
39 called when a listening socket becomes readable.
41 static void single_accept_connection(struct event_context *ev,
42 struct socket_context *sock,
43 void (*new_conn)(struct event_context *, struct socket_context *,
48 struct socket_context *sock2;
50 /* accept an incoming connection. */
51 status = socket_accept(sock, &sock2);
52 if (!NT_STATUS_IS_OK(status)) {
53 DEBUG(0,("accept_connection_single: accept: %s\n", nt_errstr(status)));
57 talloc_steal(private, sock);
59 new_conn(ev, sock2, socket_get_fd(sock), private);
63 called to startup a new task
65 static void single_new_task(struct event_context *ev,
66 void (*new_task)(struct event_context *, uint32_t, void *),
69 static uint32_t taskid = 0x10000000;
70 new_task(ev, taskid++, private);
74 /* called when a task goes down */
75 static void single_terminate(struct event_context *ev, const char *reason)
79 static const struct model_ops single_ops = {
81 .model_init = single_model_init,
82 .new_task = single_new_task,
83 .accept_connection = single_accept_connection,
84 .terminate = single_terminate,
88 initialise the single process model, registering ourselves with the
89 process model subsystem
91 NTSTATUS process_model_single_init(void)
93 return register_process_model(&single_ops);