r6226: A couple of small typos ...
[Samba/gebeck_regimport.git] / source4 / smbd / process_single.c
blob8d26481a951c827fc494bdb9ea917f5a1deb112f
1 /*
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.
25 #include "includes.h"
26 #include "lib/events/events.h"
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 *,
44 uint32_t , void *),
45 void *private)
47 NTSTATUS status;
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)));
54 return;
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 *),
67 void *private)
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)
77 DEBUG(2,("single_terminate: reason[%s]\n",reason));
80 static const struct model_ops single_ops = {
81 .name = "single",
82 .model_init = single_model_init,
83 .new_task = single_new_task,
84 .accept_connection = single_accept_connection,
85 .terminate = single_terminate,
89 initialise the single process model, registering ourselves with the
90 process model subsystem
92 NTSTATUS process_model_single_init(void)
94 return register_process_model(&single_ops);