Changeset 745 for trunk/server/source4/smbd/process_standard.c
- Timestamp:
- Nov 27, 2012, 4:43:17 PM (13 years ago)
- Location:
- trunk/server
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/server
- Property svn:mergeinfo changed
/vendor/current merged: 581,587,591,594,597,600,615,618,740
- Property svn:mergeinfo changed
-
trunk/server/source4/smbd/process_standard.c
r414 r745 24 24 #include "includes.h" 25 25 #include "lib/events/events.h" 26 #include "../tdb/include/tdb.h"27 26 #include "smbd/process_model.h" 28 27 #include "system/filesys.h" 29 28 #include "cluster/cluster.h" 30 29 #include "param/param.h" 30 #include "ldb_wrap.h" 31 31 32 32 #ifdef HAVE_SETPROCTITLE … … 51 51 called when the process model is selected 52 52 */ 53 static void standard_model_init( struct tevent_context *ev)53 static void standard_model_init(void) 54 54 { 55 55 pipe(child_pipe); … … 81 81 struct socket_context *sock2; 82 82 pid_t pid; 83 struct tevent_context *ev2;84 83 struct socket_address *c, *s; 85 84 … … 107 106 108 107 /* This is now the child code. We need a completely new event_context to work with */ 109 ev2 = s4_event_context_init(NULL); 110 111 /* the service has given us a private pointer that 112 encapsulates the context it needs for this new connection - 113 everything else will be freed */ 114 talloc_steal(ev2, private_data); 115 talloc_steal(private_data, sock2); 108 109 if (tevent_re_initialise(ev) != 0) { 110 smb_panic("Failed to re-initialise tevent after fork"); 111 } 116 112 117 113 /* this will free all the listening sockets and all state that 118 114 is not associated with this new connection */ 119 115 talloc_free(sock); 120 talloc_free(ev);121 116 122 117 /* we don't care if the dup fails, as its only a select() … … 125 120 126 121 /* tdb needs special fork handling */ 127 if (tdb_reopen_all(1) == -1) { 128 DEBUG(0,("standard_accept_connection: tdb_reopen_all failed.\n")); 129 } 130 131 tevent_add_fd(ev2, ev2, child_pipe[0], TEVENT_FD_READ, 122 ldb_wrap_fork_hook(); 123 124 tevent_add_fd(ev, ev, child_pipe[0], TEVENT_FD_READ, 132 125 standard_pipe_handler, NULL); 133 126 close(child_pipe[1]); … … 137 130 138 131 /* setup the process title */ 139 c = socket_get_peer_addr(sock2, ev 2);140 s = socket_get_my_addr(sock2, ev 2);132 c = socket_get_peer_addr(sock2, ev); 133 s = socket_get_my_addr(sock2, ev); 141 134 if (s && c) { 142 135 setproctitle("conn c[%s:%u] s[%s:%u] server_id[%d]", 143 c->addr, c->port, s->addr, s->port, pid);136 c->addr, c->port, s->addr, s->port, (int)pid); 144 137 } 145 138 talloc_free(c); … … 147 140 148 141 /* setup this new connection. Cluster ID is PID based for this process modal */ 149 new_conn(ev 2, lp_ctx, sock2, cluster_id(pid, 0), private_data);142 new_conn(ev, lp_ctx, sock2, cluster_id(pid, 0), private_data); 150 143 151 144 /* we can't return to the top level here, as that event context is gone, 152 145 so we now process events in the new event context until there are no 153 146 more to process */ 154 event_loop_wait(ev 2);155 156 talloc_free(ev 2);147 event_loop_wait(ev); 148 149 talloc_free(ev); 157 150 exit(0); 158 151 } … … 164 157 struct loadparm_context *lp_ctx, 165 158 const char *service_name, 166 void (*new_task)(struct tevent_context *, struct loadparm_context *lp_ctx, struct server_id , void *), 159 void (*new_task)(struct tevent_context *, struct loadparm_context *lp_ctx, struct server_id , void *), 167 160 void *private_data) 168 161 { 169 162 pid_t pid; 170 struct tevent_context *ev2;171 163 172 164 pid = fork(); … … 179 171 pid = getpid(); 180 172 181 /* This is now the child code. We need a completely new event_context to work with */182 ev2 = s4_event_context_init(NULL);183 184 /* the service has given us a private pointer that185 encapsulates the context it needs for this new connection -186 everything else will be freed */187 talloc_steal(ev2, private_data);188 189 173 /* this will free all the listening sockets and all state that 190 174 is not associated with this new connection */ 191 talloc_free(ev);192 193 /* tdb needs special fork handling */194 if (tdb_reopen_all(1) == -1) { 195 DEBUG(0,("standard_accept_connection: tdb_reopen_all failed.\n"));196 }197 198 tevent_add_fd(ev 2, ev2, child_pipe[0], TEVENT_FD_READ,175 if (tevent_re_initialise(ev) != 0) { 176 smb_panic("Failed to re-initialise tevent after fork"); 177 } 178 179 /* ldb/tdb need special fork handling */ 180 ldb_wrap_fork_hook(); 181 182 tevent_add_fd(ev, ev, child_pipe[0], TEVENT_FD_READ, 199 183 standard_pipe_handler, NULL); 200 184 close(child_pipe[1]); … … 203 187 set_need_random_reseed(); 204 188 205 setproctitle("task %s server_id[%d]", service_name, pid);189 setproctitle("task %s server_id[%d]", service_name, (int)pid); 206 190 207 191 /* setup this new task. Cluster ID is PID based for this process modal */ 208 new_task(ev 2, lp_ctx, cluster_id(pid, 0), private_data);192 new_task(ev, lp_ctx, cluster_id(pid, 0), private_data); 209 193 210 194 /* we can't return to the top level here, as that event context is gone, 211 195 so we now process events in the new event context until there are no 212 196 more to process */ 213 event_loop_wait(ev 2);214 215 talloc_free(ev 2);197 event_loop_wait(ev); 198 199 talloc_free(ev); 216 200 exit(0); 217 201 } … … 219 203 220 204 /* called when a task goes down */ 221 _NORETURN_ static void standard_terminate(struct tevent_context *ev, struct loadparm_context *lp_ctx, 205 _NORETURN_ static void standard_terminate(struct tevent_context *ev, struct loadparm_context *lp_ctx, 222 206 const char *reason) 223 207 { 224 208 DEBUG(2,("standard_terminate: reason[%s]\n",reason)); 209 210 talloc_free(ev); 225 211 226 212 /* this reload_charcnv() has the effect of freeing the iconv context memory, 227 213 which makes leak checking easier */ 228 214 reload_charcnv(lp_ctx); 229 230 talloc_free(ev);231 215 232 216 /* terminate this process */
Note:
See TracChangeset
for help on using the changeset viewer.