[SCM] Samba Shared Repository - branch master updated
Volker Lendecke
vlendec at samba.org
Wed Dec 14 11:09:02 MST 2011
The branch, master has been updated
via 1bea57a s3: Fix raw.mux after UNUSED_SHARE_MODE_ENTRY was removed
via c889c8d s3: Slightly simplify the logic in defer_open
via f7e84f2 s3: Remove UNUSED_SHARE_MODE_ENTRY
via 37e7981 s3: Remove a call to procid_self()
via 461766e s3: Remove nmbd_messaging_context()
via c21f6a1 s3: Fix some pointless statics
via 78e629c s3: Remove a call to procid_self()
via 1f0f8aa s3: Remove a call to procid_self()
via 505761b s3: Pass messaging_context to nmbd/process()
via 096ede3 s3: Make nmbd_messaging_context static
via a2d1b3b s3: Centralize nmbd_messaging_context in nmbd.c
via 5c3194c s3: Fix some nonempty blank lines
from 030ccc4 s4-smbtorture: make sure we can successfully run the schannel test against windows.
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 1bea57a6c35ed92f63a822accf15e4ace79ef60c
Author: Volker Lendecke <vl at samba.org>
Date: Wed Dec 14 16:54:07 2011 +0100
s3: Fix raw.mux after UNUSED_SHARE_MODE_ENTRY was removed
See the large comment in notify_deferred_opens for an explanation
Autobuild-User: Volker Lendecke <vlendec at samba.org>
Autobuild-Date: Wed Dec 14 19:08:30 CET 2011 on sn-devel-104
commit c889c8d7055102276bc10ae00c60f7ebc5a293c3
Author: Volker Lendecke <vl at samba.org>
Date: Wed Dec 14 10:43:36 2011 +0100
s3: Slightly simplify the logic in defer_open
Doing 3 &&ed conditions in a single if-statement is easier to understand to me
than continuing out separately.
commit f7e84f2809e2f00f786a2042979c73f29275edec
Author: Volker Lendecke <vl at samba.org>
Date: Wed Dec 14 10:35:56 2011 +0100
s3: Remove UNUSED_SHARE_MODE_ENTRY
commit 37e7981eeaa1c4020a7bc4b90a6808d148d5c2e3
Author: Volker Lendecke <vl at samba.org>
Date: Tue Dec 13 17:11:02 2011 +0100
s3: Remove a call to procid_self()
commit 461766e4974050b9c06d09bc034f6284695876e5
Author: Volker Lendecke <vl at samba.org>
Date: Tue Dec 13 17:10:33 2011 +0100
s3: Remove nmbd_messaging_context()
commit c21f6a1c6869a5086634bb830d6c3689dea539a3
Author: Volker Lendecke <vl at samba.org>
Date: Tue Dec 13 17:07:39 2011 +0100
s3: Fix some pointless statics
commit 78e629c5980a5c60e990bcde75aed31587729f3f
Author: Volker Lendecke <vl at samba.org>
Date: Tue Dec 13 17:03:21 2011 +0100
s3: Remove a call to procid_self()
Pass messaging_context through the SIGHUP handler
commit 1f0f8aaab5628580f9718d207e1c9cad6b9c3309
Author: Volker Lendecke <vl at samba.org>
Date: Tue Dec 13 17:03:21 2011 +0100
s3: Remove a call to procid_self()
Pass messaging_context through the SIGTERM handler
commit 505761b5a3f3e34e3b0e7c8b9b0198c8572f7b9d
Author: Volker Lendecke <vl at samba.org>
Date: Tue Dec 13 16:59:55 2011 +0100
s3: Pass messaging_context to nmbd/process()
commit 096ede362370b7e55a77cedfa40efc2a8a03fc17
Author: Volker Lendecke <vl at samba.org>
Date: Tue Dec 13 16:51:53 2011 +0100
s3: Make nmbd_messaging_context static
commit a2d1b3b144633ed7ce37492874d691fc0244d7aa
Author: Volker Lendecke <vl at samba.org>
Date: Tue Dec 13 16:48:11 2011 +0100
s3: Centralize nmbd_messaging_context in nmbd.c
commit 5c3194cc41c68ce4aacf339225b0b0d3a4f42963
Author: Volker Lendecke <vl at samba.org>
Date: Tue Dec 13 16:21:37 2011 +0100
s3: Fix some nonempty blank lines
-----------------------------------------------------------------------
Summary of changes:
source3/include/smb.h | 4 +-
source3/locking/locking.c | 63 +++++++++--------------------
source3/locking/proto.h | 1 -
source3/nmbd/asyncdns.c | 18 ++++-----
source3/nmbd/nmbd.c | 92 +++++++++++++++++++-----------------------
source3/nmbd/nmbd_packets.c | 4 +-
source3/nmbd/nmbd_proto.h | 7 +--
source3/smbd/close.c | 60 +++++++++++++++++++++++++--
source3/smbd/open.c | 11 ++---
9 files changed, 135 insertions(+), 125 deletions(-)
Changeset truncated at 500 lines:
diff --git a/source3/include/smb.h b/source3/include/smb.h
index 3451123..0724b7c 100644
--- a/source3/include/smb.h
+++ b/source3/include/smb.h
@@ -1070,11 +1070,11 @@ enum acl_compatibility {ACL_COMPAT_AUTO, ACL_COMPAT_WINNT, ACL_COMPAT_WIN2K};
* inform potential level2 holders on
* write. */
#define DEFERRED_OPEN_ENTRY 0x20
-#define UNUSED_SHARE_MODE_ENTRY 0x40
+/* #define UNUSED_SHARE_MODE_ENTRY 0x40 */ /* Not used anymore */
#define FORCE_OPLOCK_BREAK_TO_NONE 0x80
/* None of the following should ever appear in fsp->oplock_request. */
-#define SAMBA_PRIVATE_OPLOCK_MASK (INTERNAL_OPEN_ONLY|DEFERRED_OPEN_ENTRY|UNUSED_SHARE_MODE_ENTRY|FORCE_OPLOCK_BREAK_TO_NONE)
+#define SAMBA_PRIVATE_OPLOCK_MASK (INTERNAL_OPEN_ONLY|DEFERRED_OPEN_ENTRY|FORCE_OPLOCK_BREAK_TO_NONE)
#define EXCLUSIVE_OPLOCK_TYPE(lck) ((lck) & ((unsigned int)EXCLUSIVE_OPLOCK|(unsigned int)BATCH_OPLOCK))
#define BATCH_OPLOCK_TYPE(lck) ((lck) & (unsigned int)BATCH_OPLOCK)
diff --git a/source3/locking/locking.c b/source3/locking/locking.c
index b0f719b..39d3f28 100644
--- a/source3/locking/locking.c
+++ b/source3/locking/locking.c
@@ -495,12 +495,11 @@ static TDB_DATA locking_key(const struct file_id *id, struct file_id *tmp)
char *share_mode_str(TALLOC_CTX *ctx, int num, const struct share_mode_entry *e)
{
- return talloc_asprintf(ctx, "share_mode_entry[%d]: %s "
+ return talloc_asprintf(ctx, "share_mode_entry[%d]: "
"pid = %s, share_access = 0x%x, private_options = 0x%x, "
"access_mask = 0x%x, mid = 0x%llx, type= 0x%x, gen_id = %lu, "
"uid = %u, flags = %u, file_id %s, name_hash = 0x%x",
num,
- e->op_type == UNUSED_SHARE_MODE_ENTRY ? "UNUSED" : "",
procid_str_static(&e->pid),
e->share_access, e->private_options,
e->access_mask, (unsigned long long)e->op_mid,
@@ -562,12 +561,16 @@ static bool parse_share_modes(const TDB_DATA dbuf, struct share_mode_lock *lck)
smb_panic("parse_share_modes: serverids_exist failed");
}
- for (i = 0; i < lck->num_share_modes; i++) {
- struct share_mode_entry *entry_p = &lck->share_modes[i];
+ i = 0;
+ while (i < lck->num_share_modes) {
+ struct share_mode_entry *e = &lck->share_modes[i];
if (!pid_exists[i]) {
- entry_p->op_type = UNUSED_SHARE_MODE_ENTRY;
+ *e = lck->share_modes[lck->num_share_modes-1];
+ lck->num_share_modes -= 1;
lck->modified = True;
+ continue;
}
+ i += 1;
}
TALLOC_FREE(pid_exists);
TALLOC_FREE(pids);
@@ -579,19 +582,13 @@ static TDB_DATA unparse_share_modes(struct share_mode_lock *lck)
{
DATA_BLOB blob;
enum ndr_err_code ndr_err;
- uint32_t i;
if (DEBUGLEVEL >= 10) {
DEBUG(10, ("unparse_share_modes:\n"));
NDR_PRINT_DEBUG(share_mode_lock, lck);
}
- for (i=0; i<lck->num_share_modes; i++) {
- if (!is_unused_share_mode_entry(&lck->share_modes[i])) {
- break;
- }
- }
- if (i == lck->num_share_modes) {
+ if (lck->num_share_modes == 0) {
DEBUG(10, ("No used share mode found\n"));
return make_tdb_data(NULL, 0);
}
@@ -773,6 +770,10 @@ struct share_mode_lock *fetch_share_mode_unlocked(TALLOC_CTX *mem_ctx,
TALLOC_FREE(lck);
return NULL;
}
+ if (data.dptr == NULL) {
+ TALLOC_FREE(lck);
+ return NULL;
+ }
if (!fill_share_mode_lock(lck, id, NULL, NULL, data, NULL)) {
DEBUG(10, ("fetch_share_mode_unlocked: no share_mode record "
@@ -936,14 +937,6 @@ bool is_valid_share_mode_entry(const struct share_mode_entry *e)
{
int num_props = 0;
- if (e->op_type == UNUSED_SHARE_MODE_ENTRY) {
- /* cope with dead entries from the process not
- existing. These should not be considered valid,
- otherwise we end up doing zero timeout sharing
- violation */
- return False;
- }
-
num_props += ((e->op_type == NO_OPLOCK) ? 1 : 0);
num_props += (EXCLUSIVE_OPLOCK_TYPE(e->op_type) ? 1 : 0);
num_props += (LEVEL_II_OPLOCK_TYPE(e->op_type) ? 1 : 0);
@@ -957,11 +950,6 @@ bool is_deferred_open_entry(const struct share_mode_entry *e)
return (e->op_type == DEFERRED_OPEN_ENTRY);
}
-bool is_unused_share_mode_entry(const struct share_mode_entry *e)
-{
- return (e->op_type == UNUSED_SHARE_MODE_ENTRY);
-}
-
/*******************************************************************
Fill a share mode entry.
********************************************************************/
@@ -1006,21 +994,8 @@ static void fill_deferred_open_entry(struct share_mode_entry *e,
static void add_share_mode_entry(struct share_mode_lock *lck,
const struct share_mode_entry *entry)
{
- int i;
-
- for (i=0; i<lck->num_share_modes; i++) {
- struct share_mode_entry *e = &lck->share_modes[i];
- if (is_unused_share_mode_entry(e)) {
- *e = *entry;
- break;
- }
- }
-
- if (i == lck->num_share_modes) {
- /* No unused entry found */
- ADD_TO_ARRAY(lck, struct share_mode_entry, *entry,
- &lck->share_modes, &lck->num_share_modes);
- }
+ ADD_TO_ARRAY(lck, struct share_mode_entry, *entry,
+ &lck->share_modes, &lck->num_share_modes);
lck->modified = True;
}
@@ -1105,8 +1080,8 @@ bool del_share_mode(struct share_mode_lock *lck, files_struct *fsp)
if (e == NULL) {
return False;
}
-
- e->op_type = UNUSED_SHARE_MODE_ENTRY;
+ *e = lck->share_modes[lck->num_share_modes-1];
+ lck->num_share_modes -= 1;
lck->modified = True;
return True;
}
@@ -1123,8 +1098,8 @@ void del_deferred_open_entry(struct share_mode_lock *lck, uint64_t mid,
if (e == NULL) {
return;
}
-
- e->op_type = UNUSED_SHARE_MODE_ENTRY;
+ *e = lck->share_modes[lck->num_share_modes-1];
+ lck->num_share_modes -= 1;
lck->modified = True;
}
diff --git a/source3/locking/proto.h b/source3/locking/proto.h
index 2c01634..d6f1c1b 100644
--- a/source3/locking/proto.h
+++ b/source3/locking/proto.h
@@ -165,7 +165,6 @@ void get_file_infos(struct file_id id,
struct timespec *write_time);
bool is_valid_share_mode_entry(const struct share_mode_entry *e);
bool is_deferred_open_entry(const struct share_mode_entry *e);
-bool is_unused_share_mode_entry(const struct share_mode_entry *e);
void set_share_mode(struct share_mode_lock *lck, files_struct *fsp,
uid_t uid, uint64_t mid, uint16 op_type);
void add_deferred_open(struct share_mode_lock *lck, uint64_t mid,
diff --git a/source3/nmbd/asyncdns.c b/source3/nmbd/asyncdns.c
index 0edec37..a42ad25 100644
--- a/source3/nmbd/asyncdns.c
+++ b/source3/nmbd/asyncdns.c
@@ -2,17 +2,17 @@
Unix SMB/CIFS implementation.
a async DNS handler
Copyright (C) Andrew Tridgell 1997-1998
-
+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
@@ -30,7 +30,7 @@ static struct name_record *add_dns_result(struct nmb_name *question, struct in_a
unstring qname;
pull_ascii_nstring(qname, sizeof(qname), question->name);
-
+
if (!addr.s_addr) {
/* add the fail to WINS cache of names. give it 1 hour in the cache */
DEBUG(3,("add_dns_result: Negative DNS answer for %s\n", qname));
@@ -135,7 +135,7 @@ void kill_async_dns_child(void)
/***************************************************************************
create a child process to handle DNS lookups
****************************************************************************/
-void start_async_dns(void)
+void start_async_dns(struct messaging_context *msg)
{
int fd1[2], fd2[2];
NTSTATUS status;
@@ -166,9 +166,7 @@ void start_async_dns(void)
CatchSignal(SIGHUP, SIG_IGN);
CatchSignal(SIGTERM, sig_term);
- status = reinit_after_fork(nmbd_messaging_context(),
- nmbd_event_context(),
- true);
+ status = reinit_after_fork(msg, nmbd_event_context(), true);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0,("reinit_after_fork() failed\n"));
@@ -205,7 +203,7 @@ static bool write_child(struct packet_struct *p)
/***************************************************************************
check the DNS queue
****************************************************************************/
-void run_dns_queue(void)
+void run_dns_queue(struct messaging_context *msg)
{
struct query_record r;
struct packet_struct *p, *p2;
@@ -218,7 +216,7 @@ void run_dns_queue(void)
if (!process_exists_by_pid(child_pid)) {
close(fd_in);
close(fd_out);
- start_async_dns();
+ start_async_dns(msg);
}
status = read_data(fd_in, (char *)&r, sizeof(r));
diff --git a/source3/nmbd/nmbd.c b/source3/nmbd/nmbd.c
index 7dff92a..5392eb1 100644
--- a/source3/nmbd/nmbd.c
+++ b/source3/nmbd/nmbd.c
@@ -47,21 +47,11 @@ struct event_context *nmbd_event_context(void)
return server_event_context();
}
-struct messaging_context *nmbd_messaging_context(void)
-{
- struct messaging_context *msg_ctx = server_messaging_context();
- if (likely(msg_ctx != NULL)) {
- return msg_ctx;
- }
- smb_panic("Could not init nmbd's messaging context.\n");
- return NULL;
-}
-
/**************************************************************************** **
Handle a SIGTERM in band.
**************************************************************************** */
-static void terminate(void)
+static void terminate(struct messaging_context *msg)
{
DEBUG(0,("Got SIGTERM: going down...\n"));
@@ -78,7 +68,7 @@ static void terminate(void)
kill_async_dns_child();
gencache_stabilize();
- serverid_deregister(procid_self());
+ serverid_deregister(messaging_server_id(msg));
pidfile_unlink();
@@ -92,10 +82,13 @@ static void nmbd_sig_term_handler(struct tevent_context *ev,
void *siginfo,
void *private_data)
{
- terminate();
+ struct messaging_context *msg = talloc_get_type_abort(
+ private_data, struct messaging_context);
+
+ terminate(msg);
}
-static bool nmbd_setup_sig_term_handler(void)
+static bool nmbd_setup_sig_term_handler(struct messaging_context *msg)
{
struct tevent_signal *se;
@@ -103,7 +96,7 @@ static bool nmbd_setup_sig_term_handler(void)
nmbd_event_context(),
SIGTERM, 0,
nmbd_sig_term_handler,
- NULL);
+ msg);
if (!se) {
DEBUG(0,("failed to setup SIGTERM handler"));
return false;
@@ -125,13 +118,15 @@ static void nmbd_sig_hup_handler(struct tevent_context *ev,
void *siginfo,
void *private_data)
{
+ struct messaging_context *msg = talloc_get_type_abort(
+ private_data, struct messaging_context);
+
DEBUG(0,("Got SIGHUP dumping debug info.\n"));
- msg_reload_nmbd_services(nmbd_messaging_context(),
- NULL, MSG_SMB_CONF_UPDATED,
- procid_self(), NULL);
+ msg_reload_nmbd_services(msg, NULL, MSG_SMB_CONF_UPDATED,
+ messaging_server_id(msg), NULL);
}
-static bool nmbd_setup_sig_hup_handler(void)
+static bool nmbd_setup_sig_hup_handler(struct messaging_context *msg)
{
struct tevent_signal *se;
@@ -139,7 +134,7 @@ static bool nmbd_setup_sig_hup_handler(void)
nmbd_event_context(),
SIGHUP, 0,
nmbd_sig_hup_handler,
- NULL);
+ msg);
if (!se) {
DEBUG(0,("failed to setup SIGHUP handler"));
return false;
@@ -158,7 +153,7 @@ static void nmbd_terminate(struct messaging_context *msg,
struct server_id server_id,
DATA_BLOB *data)
{
- terminate();
+ terminate(msg);
}
/**************************************************************************** **
@@ -459,7 +454,7 @@ static void msg_nmbd_send_packet(struct messaging_context *msg,
The main select loop.
**************************************************************************** */
-static void process(void)
+static void process(struct messaging_context *msg)
{
bool run_election;
@@ -480,7 +475,7 @@ static void process(void)
* (nmbd_packets.c)
*/
- if(listen_for_packets(run_election)) {
+ if (listen_for_packets(msg, run_election)) {
TALLOC_FREE(frame);
return;
}
@@ -730,14 +725,15 @@ static bool open_sockets(bool isdaemon, int port)
int main(int argc, const char *argv[])
{
- static bool is_daemon;
- static bool opt_interactive;
- static bool Fork = true;
- static bool no_process_group;
- static bool log_stdout;
+ bool is_daemon;
+ bool opt_interactive;
+ bool Fork = true;
+ bool no_process_group;
+ bool log_stdout;
poptContext pc;
char *p_lmhosts = NULL;
int opt;
+ struct messaging_context *msg;
enum {
OPT_DAEMON = 1000,
OPT_INTERACTIVE,
@@ -859,7 +855,8 @@ static bool open_sockets(bool isdaemon, int port)
exit(1);
}
- if (nmbd_messaging_context() == NULL) {
+ msg = messaging_init(NULL, server_event_context());
+ if (msg == NULL) {
return 1;
}
@@ -897,15 +894,11 @@ static bool open_sockets(bool isdaemon, int port)
setpgid( (pid_t)0, (pid_t)0 );
#endif
- if (nmbd_messaging_context() == NULL) {
- return 1;
- }
-
#ifndef SYNC_DNS
/* Setup the async dns. We do it here so it doesn't have all the other
stuff initialised and thus chewing memory and sockets */
if(lp_we_are_a_wins_server() && lp_dns_proxy()) {
- start_async_dns();
+ start_async_dns(msg);
}
#endif
@@ -915,8 +908,7 @@ static bool open_sockets(bool isdaemon, int port)
pidfile_create("nmbd");
- status = reinit_after_fork(nmbd_messaging_context(),
- nmbd_event_context(),
+ status = reinit_after_fork(msg, nmbd_event_context(),
false);
if (!NT_STATUS_IS_OK(status)) {
@@ -924,14 +916,14 @@ static bool open_sockets(bool isdaemon, int port)
exit(1);
}
- if (!nmbd_setup_sig_term_handler())
+ if (!nmbd_setup_sig_term_handler(msg))
exit(1);
- if (!nmbd_setup_sig_hup_handler())
+ if (!nmbd_setup_sig_hup_handler(msg))
exit(1);
/* get broadcast messages */
- if (!serverid_register(procid_self(),
+ if (!serverid_register(messaging_server_id(msg),
FLAG_MSG_GENERAL |
FLAG_MSG_NMBD |
FLAG_MSG_DBWRAP)) {
@@ -939,19 +931,19 @@ static bool open_sockets(bool isdaemon, int port)
exit(1);
}
- messaging_register(nmbd_messaging_context(), NULL,
- MSG_FORCE_ELECTION, nmbd_message_election);
+ messaging_register(msg, NULL, MSG_FORCE_ELECTION,
+ nmbd_message_election);
#if 0
/* Until winsrepl is done. */
- messaging_register(nmbd_messaging_context(), NULL,
- MSG_WINS_NEW_ENTRY, nmbd_wins_new_entry);
+ messaging_register(msg, NULL, MSG_WINS_NEW_ENTRY,
+ nmbd_wins_new_entry);
#endif
- messaging_register(nmbd_messaging_context(), NULL,
- MSG_SHUTDOWN, nmbd_terminate);
- messaging_register(nmbd_messaging_context(), NULL,
- MSG_SMB_CONF_UPDATED, msg_reload_nmbd_services);
- messaging_register(nmbd_messaging_context(), NULL,
- MSG_SEND_PACKET, msg_nmbd_send_packet);
+ messaging_register(msg, NULL, MSG_SHUTDOWN,
+ nmbd_terminate);
+ messaging_register(msg, NULL, MSG_SMB_CONF_UPDATED,
+ msg_reload_nmbd_services);
+ messaging_register(msg, NULL, MSG_SEND_PACKET,
+ msg_nmbd_send_packet);
TimeInit();
@@ -1012,7 +1004,7 @@ static bool open_sockets(bool isdaemon, int port)
}
TALLOC_FREE(frame);
- process();
+ process(msg);
kill_async_dns_child();
return(0);
diff --git a/source3/nmbd/nmbd_packets.c b/source3/nmbd/nmbd_packets.c
index c7ecfc6..da38dcf 100644
--- a/source3/nmbd/nmbd_packets.c
+++ b/source3/nmbd/nmbd_packets.c
@@ -1864,7 +1864,7 @@ static void free_processed_packet_list(struct processed_packet **pp_processed_pa
return True if the socket is dead
***************************************************************************/
-bool listen_for_packets(bool run_election)
+bool listen_for_packets(struct messaging_context *msg, bool run_election)
{
static struct pollfd *fds = NULL;
static struct socket_attributes *attrs = NULL;
@@ -1948,7 +1948,7 @@ bool listen_for_packets(bool run_election)
#ifndef SYNC_DNS
if ((dns_fd != -1) && (dns_pollidx != -1) &&
(fds[dns_pollidx].revents & (POLLIN|POLLHUP|POLLERR))) {
- run_dns_queue();
+ run_dns_queue(msg);
}
#endif
diff --git a/source3/nmbd/nmbd_proto.h b/source3/nmbd/nmbd_proto.h
--
Samba Shared Repository
More information about the samba-cvs
mailing list