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>
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)
33 called when a listening socket becomes readable
35 static void accept_connection(struct event_context *ev, struct fd_event *fde, time_t t, uint16_t flags)
39 socklen_t in_addrlen = sizeof(addr);
40 struct model_ops *model_ops = fde->private;
42 /* accept an incoming connection. */
43 accepted_fd = accept(fde->fd,&addr,&in_addrlen);
44 if (accepted_fd == -1) {
45 DEBUG(0,("accept_connection_single: accept: %s\n",
50 /* create a smb server context and add it to out event
52 init_smbsession(ev, model_ops, accepted_fd, smbd_read_handler);
54 /* return to event handling */
59 called when a rpc listening socket becomes readable
61 static void accept_rpc_connection(struct event_context *ev, struct fd_event *fde, time_t t, uint16_t flags)
65 socklen_t in_addrlen = sizeof(addr);
67 /* accept an incoming connection. */
68 accepted_fd = accept(fde->fd,&addr,&in_addrlen);
69 if (accepted_fd == -1) {
70 DEBUG(0,("accept_connection_single: accept: %s\n",
75 init_rpc_session(ev, fde->private, accepted_fd);
78 /* called when a SMB connection goes down */
79 static void terminate_connection(struct server_context *server, const char *reason)
81 server_terminate(server);
84 /* called when a rpc connection goes down */
85 static void terminate_rpc_connection(void *r, const char *reason)
87 rpc_server_terminate(r);
90 static int get_id(struct request_context *req)
92 return (int)req->smb->pid;
95 static void single_exit_server(struct server_context *smb, const char *reason)
97 DEBUG(1,("single_exit_server: reason[%s]\n",reason));
101 initialise the single process model, registering ourselves with the process model subsystem
103 NTSTATUS process_model_single_init(void)
106 struct model_ops ops;
110 /* fill in our name */
113 /* fill in all the operations */
114 ops.model_startup = model_startup;
115 ops.accept_connection = accept_connection;
116 ops.accept_rpc_connection = accept_rpc_connection;
117 ops.terminate_connection = terminate_connection;
118 ops.terminate_rpc_connection = terminate_rpc_connection;
119 ops.exit_server = single_exit_server;
122 /* register ourselves with the PROCESS_MODEL subsystem. */
123 ret = register_backend("process_model", &ops);
124 if (!NT_STATUS_IS_OK(ret)) {
125 DEBUG(0,("Failed to register process_model 'single'!\n"));