2 Unix SMB/CIFS implementation.
3 process model: standard (1 process per client connection)
4 Copyright (C) Andrew Tridgell 1992-2003
5 Copyright (C) James J Myers 2003 <myersjj@samba.org>
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 called when the process model is selected
27 static void model_startup(void)
32 called when a listening socket becomes readable
34 static void accept_connection(struct event_context *ev, struct fd_event *fde, time_t t, uint16 flags)
38 socklen_t in_addrlen = sizeof(addr);
40 struct model_ops *model_ops = fde->private;
42 accepted_fd = accept(fde->fd,&addr,&in_addrlen);
43 if (accepted_fd == -1) {
44 DEBUG(0,("accept_connection_standard: accept: %s\n",
52 /* parent or error code ... */
55 /* go back to the event loop */
61 /* close all the listening sockets */
62 event_remove_fd_all_handler(ev, accept_connection);
64 /* tdb needs special fork handling */
65 if (tdb_reopen_all() == -1) {
66 DEBUG(0,("accept_connection_standard: tdb_reopen_all failed.\n"));
72 /* initialize new process */
75 init_smbsession(ev, model_ops, accepted_fd);
77 /* return to the event loop */
80 /* called when a SMB connection goes down */
81 static void terminate_connection(struct server_context *server, const char *reason)
83 server_terminate(server);
84 /* terminate this process */
88 static int get_id(struct request_context *req)
90 return (int)req->smb->pid;
94 initialise the standard process model, registering ourselves with the model subsystem
96 void process_model_standard_init(void)
102 /* fill in all the operations */
103 ops.model_startup = model_startup;
104 ops.accept_connection = accept_connection;
105 ops.terminate_connection = terminate_connection;
108 /* register ourselves with the process model subsystem. We register under the name 'standard'. */
109 register_process_model("standard", &ops);