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.
26 #include "smbd/process_model.h"
29 called when the process model is selected
31 static void single_model_init(struct event_context *ev)
36 called when a listening socket becomes readable.
38 static void single_accept_connection(struct event_context *ev,
39 struct socket_context *sock,
40 void (*new_conn)(struct event_context *, struct socket_context *,
45 struct socket_context *sock2;
47 /* accept an incoming connection. */
48 status = socket_accept(sock, &sock2);
49 if (!NT_STATUS_IS_OK(status)) {
50 DEBUG(0,("single_accept_connection: accept: %s\n", nt_errstr(status)));
51 /* this looks strange, but is correct. We need to
52 throttle things until the system clears enough
53 resources to handle this new socket. If we don't
54 then we will spin filling the log and causing more
55 problems. We don't panic as this is probably a
56 temporary resource constraint */
61 talloc_steal(private, sock);
63 new_conn(ev, sock2, socket_get_fd(sock2), private);
67 called to startup a new task
69 static void single_new_task(struct event_context *ev,
70 void (*new_task)(struct event_context *, uint32_t, void *),
73 static uint32_t taskid = 0x10000000;
74 new_task(ev, taskid++, private);
78 /* called when a task goes down */
79 static void single_terminate(struct event_context *ev, const char *reason)
81 DEBUG(2,("single_terminate: reason[%s]\n",reason));
84 /* called to set a title of a task or connection */
85 static void single_set_title(struct event_context *ev, const char *title)
89 static const struct model_ops single_ops = {
91 .model_init = single_model_init,
92 .new_task = single_new_task,
93 .accept_connection = single_accept_connection,
94 .terminate = single_terminate,
95 .set_title = single_set_title,
99 initialise the single process model, registering ourselves with the
100 process model subsystem
102 NTSTATUS process_model_single_init(void)
104 return register_process_model(&single_ops);