Ignore:
Timestamp:
Apr 9, 2010, 3:51:41 PM (15 years ago)
Author:
Silvan Scherrer
Message:

Samba 3.5.x: trunk update to 3.5.2

Location:
trunk/server
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/server

  • trunk/server/source3/smbd/server.c

    r414 r429  
    220220}
    221221
     222/*
     223  at most every smbd:cleanuptime seconds (default 20), we scan the BRL
     224  and locking database for entries to cleanup. As a side effect this
     225  also cleans up dead entries in the connections database (due to the
     226  traversal in message_send_all()
     227
     228  Using a timer for this prevents a flood of traversals when a large
     229  number of clients disconnect at the same time (perhaps due to a
     230  network outage). 
     231*/
     232
     233static void cleanup_timeout_fn(struct event_context *event_ctx,
     234                                struct timed_event *te,
     235                                struct timeval now,
     236                                void *private_data)
     237{
     238        struct timed_event **cleanup_te = (struct timed_event **)private_data;
     239
     240        DEBUG(1,("Cleaning up brl and lock database after unclean shutdown\n"));
     241        message_send_all(smbd_messaging_context(), MSG_SMB_UNLOCK, NULL, 0, NULL);
     242        messaging_send_buf(smbd_messaging_context(), procid_self(),
     243                                MSG_SMB_BRL_VALIDATE, NULL, 0);
     244        /* mark the cleanup as having been done */
     245        (*cleanup_te) = NULL;
     246}
     247
    222248static void remove_child_pid(pid_t pid, bool unclean_shutdown)
    223249{
    224250        struct child_pid *child;
     251        static struct timed_event *cleanup_te;
    225252
    226253        if (unclean_shutdown) {
    227                 /* a child terminated uncleanly so tickle all processes to see
    228                    if they can grab any of the pending locks
    229                 */
    230                 DEBUG(3,(__location__ " Unclean shutdown of pid %u\n", (unsigned int)pid));
    231                 messaging_send_buf(smbd_messaging_context(), procid_self(),
    232                                    MSG_SMB_BRL_VALIDATE, NULL, 0);
    233                 message_send_all(smbd_messaging_context(),
    234                                  MSG_SMB_UNLOCK, NULL, 0, NULL);
     254                /* a child terminated uncleanly so tickle all
     255                   processes to see if they can grab any of the
     256                   pending locks
     257                */
     258                DEBUG(3,(__location__ " Unclean shutdown of pid %u\n",
     259                        (unsigned int)pid));
     260                if (!cleanup_te) {
     261                        /* call the cleanup timer, but not too often */
     262                        int cleanup_time = lp_parm_int(-1, "smbd", "cleanuptime", 20);
     263                        cleanup_te = event_add_timed(smbd_event_context(), NULL,
     264                                                timeval_current_ofs(cleanup_time, 0),
     265                                                cleanup_timeout_fn,
     266                                                &cleanup_te);
     267                        DEBUG(1,("Scheduled cleanup of brl and lock database after unclean shutdown\n"));
     268                }
    235269        }
    236270
     
    10481082        gain_root_group_privilege();
    10491083
    1050         /*
    1051          * Ensure we have CAP_KILL capability set on Linux,
    1052          * where we need this to communicate with threads.
    1053          * This is inherited by new threads, but not by new
    1054          * processes across exec().
    1055          */
    1056         set_effective_capability(KILL_CAPABILITY);
    1057 
    10581084        fault_setup((void (*)(void *))exit_server_fault);
    10591085        dump_core_setup("smbd");
     
    12811307
    12821308        TALLOC_FREE(frame);
     1309        /* make sure we always have a valid stackframe */
     1310        frame = talloc_stackframe();
    12831311
    12841312        smbd_parent_loop(parent);
    12851313
    12861314        exit_server_cleanly(NULL);
     1315        TALLOC_FREE(frame);
    12871316        return(0);
    12881317}
Note: See TracChangeset for help on using the changeset viewer.