------------------------------------------------------------ revno: 607 revision-id: [EMAIL PROTECTED] parent: [EMAIL PROTECTED] parent: [EMAIL PROTECTED] committer: Andrew Tridgell <[EMAIL PROTECTED]> branch nick: s3-ctdb-tridge timestamp: Mon 2007-08-20 10:21:54 +1000 message: merge from Ronnie modified: source/smbd/server.c server.c-20070210173807-1wjifrbwaz6xnmgl-1036 ------------------------------------------------------------ revno: 606.1.3 merged: [EMAIL PROTECTED] parent: [EMAIL PROTECTED] committer: Ronnie Sahlberg <[EMAIL PROTECTED]> branch nick: 3_0-ctdb timestamp: Mon 2007-08-20 07:46:32 +1000 message: use the exit status of a terminated child smbd to determine whether we need to revalidate all locks or not ------------------------------------------------------------ revno: 606.1.2 merged: [EMAIL PROTECTED] parent: [EMAIL PROTECTED] committer: Ronnie Sahlberg <[EMAIL PROTECTED]> branch nick: 3_0-ctdb timestamp: Mon 2007-08-20 07:14:11 +1000 message: revert the brwriter tdb changes and try to solve the issue differently ------------------------------------------------------------ revno: 606.1.1 merged: [EMAIL PROTECTED] parent: [EMAIL PROTECTED] committer: root <[EMAIL PROTECTED]> branch nick: 3_0-ctdb timestamp: Fri 2007-08-17 11:40:17 +1000 message: create a new tdb 'brwriters' that stores a record for each process/smbd that has performed read/write operations to the br database. this allows the parent smbd process to know when a child has terminated without doing any byte range locking (and thus we can skip doing any brl revalidation) or when a child has performed brl operations in which case we have to perform the expensive revalidation process. since clients today try both port 139 and 445 simultaneously this means that at least half of all samba daemons will never perform any br locking at all and just by doing this we avoid revalidation in 50% of the cases === modified file 'source/smbd/server.c' --- a/source/smbd/server.c 2007-08-16 04:31:52 +0000 +++ b/source/smbd/server.c 2007-08-19 21:46:32 +0000 @@ -261,15 +261,19 @@ num_children += 1; } -static void remove_child_pid(pid_t pid) +static void remove_child_pid(pid_t pid, BOOL unclean_shutdown) { struct child_pid *child; - /* a child terminated so tickle all processes to see if they can - grab any of the pending locks - */ - message_send_pid(procid_self(), MSG_SMB_BRL_VALIDATE, NULL, 0, False); - message_send_all(MSG_SMB_UNLOCK, NULL, 0, False, NULL); + + if (unclean_shutdown) { + /* a child terminated uncleanly so tickle all processes to see + if they can grab any of the pending locks + */ + message_send_pid(procid_self(), MSG_SMB_BRL_VALIDATE, + NULL, 0, False); + message_send_all(MSG_SMB_UNLOCK, NULL, 0, False, NULL); + } if (lp_max_smbd_processes() == 0) { @@ -387,10 +391,27 @@ if (got_sig_cld) { pid_t pid; + int status; + got_sig_cld = False; - while ((pid = sys_waitpid(-1, NULL, WNOHANG)) > 0) { - remove_child_pid(pid); + while ((pid = sys_waitpid(-1, &status, WNOHANG)) > 0) { + BOOL unclean_shutdown = False; + + /* If the child terminated normally, assume + it was an unclean shutdown unless the + status is 0 + */ + if (WIFEXITED(status)) { + unclean_shutdown = WEXITSTATUS(status); + } + /* If the child terminated due to a signal + we always assume it was unclean. + */ + if (WIFSIGNALED(status)) { + unclean_shutdown = True; + } + remove_child_pid(pid, unclean_shutdown); } }