Ignore:
Timestamp:
Nov 27, 2012, 4:43:17 PM (13 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: updated trunk to 3.6.0

Location:
trunk/server
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/server

  • trunk/server/source4/smbd/process_standard.c

    r414 r745  
    2424#include "includes.h"
    2525#include "lib/events/events.h"
    26 #include "../tdb/include/tdb.h"
    2726#include "smbd/process_model.h"
    2827#include "system/filesys.h"
    2928#include "cluster/cluster.h"
    3029#include "param/param.h"
     30#include "ldb_wrap.h"
    3131
    3232#ifdef HAVE_SETPROCTITLE
     
    5151  called when the process model is selected
    5252*/
    53 static void standard_model_init(struct tevent_context *ev)
     53static void standard_model_init(void)
    5454{
    5555        pipe(child_pipe);
     
    8181        struct socket_context *sock2;
    8282        pid_t pid;
    83         struct tevent_context *ev2;
    8483        struct socket_address *c, *s;
    8584
     
    107106
    108107        /* 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        }
    116112
    117113        /* this will free all the listening sockets and all state that
    118114           is not associated with this new connection */
    119115        talloc_free(sock);
    120         talloc_free(ev);
    121116
    122117        /* we don't care if the dup fails, as its only a select()
     
    125120                       
    126121        /* 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,
    132125                      standard_pipe_handler, NULL);
    133126        close(child_pipe[1]);
     
    137130
    138131        /* setup the process title */
    139         c = socket_get_peer_addr(sock2, ev2);
    140         s = socket_get_my_addr(sock2, ev2);
     132        c = socket_get_peer_addr(sock2, ev);
     133        s = socket_get_my_addr(sock2, ev);
    141134        if (s && c) {
    142135                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);
    144137        }
    145138        talloc_free(c);
     
    147140
    148141        /* setup this new connection.  Cluster ID is PID based for this process modal */
    149         new_conn(ev2, lp_ctx, sock2, cluster_id(pid, 0), private_data);
     142        new_conn(ev, lp_ctx, sock2, cluster_id(pid, 0), private_data);
    150143
    151144        /* we can't return to the top level here, as that event context is gone,
    152145           so we now process events in the new event context until there are no
    153146           more to process */     
    154         event_loop_wait(ev2);
    155 
    156         talloc_free(ev2);
     147        event_loop_wait(ev);
     148
     149        talloc_free(ev);
    157150        exit(0);
    158151}
     
    164157                              struct loadparm_context *lp_ctx,
    165158                              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 *),
    167160                              void *private_data)
    168161{
    169162        pid_t pid;
    170         struct tevent_context *ev2;
    171163
    172164        pid = fork();
     
    179171        pid = getpid();
    180172
    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 that
    185            encapsulates the context it needs for this new connection -
    186            everything else will be freed */
    187         talloc_steal(ev2, private_data);
    188 
    189173        /* this will free all the listening sockets and all state that
    190174           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(ev2, 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,
    199183                      standard_pipe_handler, NULL);
    200184        close(child_pipe[1]);
     
    203187        set_need_random_reseed();
    204188
    205         setproctitle("task %s server_id[%d]", service_name, pid);
     189        setproctitle("task %s server_id[%d]", service_name, (int)pid);
    206190
    207191        /* setup this new task.  Cluster ID is PID based for this process modal */
    208         new_task(ev2, lp_ctx, cluster_id(pid, 0), private_data);
     192        new_task(ev, lp_ctx, cluster_id(pid, 0), private_data);
    209193
    210194        /* we can't return to the top level here, as that event context is gone,
    211195           so we now process events in the new event context until there are no
    212196           more to process */     
    213         event_loop_wait(ev2);
    214 
    215         talloc_free(ev2);
     197        event_loop_wait(ev);
     198
     199        talloc_free(ev);
    216200        exit(0);
    217201}
     
    219203
    220204/* 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,
    222206                                          const char *reason)
    223207{
    224208        DEBUG(2,("standard_terminate: reason[%s]\n",reason));
     209
     210        talloc_free(ev);
    225211
    226212        /* this reload_charcnv() has the effect of freeing the iconv context memory,
    227213           which makes leak checking easier */
    228214        reload_charcnv(lp_ctx);
    229 
    230         talloc_free(ev);
    231215
    232216        /* terminate this process */
Note: See TracChangeset for help on using the changeset viewer.