summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2010-07-04 20:40:46 +0200
committerVolker Lendecke <vl@samba.org>2010-07-04 21:49:03 +0200
commitb0c83d50f9f609848c19180b6b032e73a1d504cb (patch)
treed1f07798d72e22e3b89a8c5d521844c5550b6017
parent8cf1cd2d5c0469f170b0f81dda94a53ce8575af9 (diff)
downloadsamba-b0c83d50f9f609848c19180b6b032e73a1d504cb.tar.gz
samba-b0c83d50f9f609848c19180b6b032e73a1d504cb.tar.bz2
samba-b0c83d50f9f609848c19180b6b032e73a1d504cb.zip
s3: Replace register_message_flags() with serverid_register_msg_flags()
message_send_all is now done by walking the serverid.tdb, not the connections.tdb anymore. Günther, Simo, please check!
-rw-r--r--source3/include/proto.h1
-rw-r--r--source3/include/serverid.h6
-rw-r--r--source3/lib/serverid.c52
-rw-r--r--source3/rpc_server/srv_spoolss_nt.c8
-rw-r--r--source3/smbd/connection.c44
5 files changed, 64 insertions, 47 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 30a432521f..5f332ef53e 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -5358,7 +5358,6 @@ bool yield_connection(connection_struct *conn, const char *name);
int count_current_connections( const char *sharename, bool clear );
bool claim_connection(connection_struct *conn, const char *name,
uint32 msg_flags);
-bool register_message_flags(bool doreg, uint32 msg_flags);
/* The following definitions come from smbd/dfree.c */
diff --git a/source3/include/serverid.h b/source3/include/serverid.h
index db2ce5ab87..3fcb5548d6 100644
--- a/source3/include/serverid.h
+++ b/source3/include/serverid.h
@@ -33,6 +33,12 @@ bool serverid_register(const struct server_id id, uint32_t msg_flags);
bool serverid_deregister(const struct server_id id);
/*
+ * (De)register additional message flags
+ */
+bool serverid_register_msg_flags(const struct server_id id, bool do_reg,
+ uint32_t msg_flags);
+
+/*
* Check existence of a server id
*/
bool serverid_exists(const struct server_id *id);
diff --git a/source3/lib/serverid.c b/source3/lib/serverid.c
index f92c8cfd58..f774170784 100644
--- a/source3/lib/serverid.c
+++ b/source3/lib/serverid.c
@@ -117,6 +117,58 @@ done:
return ret;
}
+bool serverid_register_msg_flags(const struct server_id id, bool do_reg,
+ uint32_t msg_flags)
+{
+ struct db_context *db;
+ struct serverid_key key;
+ struct serverid_data *data;
+ struct db_record *rec;
+ TDB_DATA tdbkey, tdbdata;
+ NTSTATUS status;
+ bool ret = false;
+
+ db = serverid_db();
+ if (db == NULL) {
+ return false;
+ }
+
+ serverid_fill_key(&id, &key);
+ tdbkey = make_tdb_data((uint8_t *)&key, sizeof(key));
+
+ rec = db->fetch_locked(db, talloc_tos(), tdbkey);
+ if (rec == NULL) {
+ DEBUG(1, ("Could not fetch_lock serverid.tdb record\n"));
+ return false;
+ }
+
+ if (rec->value.dsize != sizeof(struct serverid_data)) {
+ DEBUG(1, ("serverid record has unexpected size %d "
+ "(wanted %d)\n", (int)rec->value.dsize,
+ sizeof(struct serverid_data)));
+ goto done;
+ }
+
+ data = (struct serverid_data *)rec->value.dptr;
+
+ if (do_reg) {
+ data->msg_flags |= msg_flags;
+ } else {
+ data->msg_flags &= ~msg_flags;
+ }
+
+ status = rec->store(rec, tdbdata, 0);
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(1, ("Storing serverid.tdb record failed: %s\n",
+ nt_errstr(status)));
+ goto done;
+ }
+ ret = true;
+done:
+ TALLOC_FREE(rec);
+ return ret;
+}
+
bool serverid_deregister(struct server_id id)
{
struct db_context *db;
diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c
index c844027382..dae9f376d9 100644
--- a/source3/rpc_server/srv_spoolss_nt.c
+++ b/source3/rpc_server/srv_spoolss_nt.c
@@ -185,7 +185,9 @@ static void srv_spoolss_replycloseprinter(int snum, struct policy_handle *handle
/* Tell the connections db we're no longer interested in
* printer notify messages. */
- register_message_flags(false, FLAG_MSG_PRINT_NOTIFY);
+ serverid_register_msg_flags(
+ procid_self(),
+ false, FLAG_MSG_PRINT_NOTIFY);
}
smb_connections--;
@@ -2355,7 +2357,9 @@ static bool srv_spoolss_replyopenprinter(int snum, const char *printer,
receive_notify2_message_list);
/* Tell the connections db we're now interested in printer
* notify messages. */
- register_message_flags(true, FLAG_MSG_PRINT_NOTIFY);
+ serverid_register_msg_flags(
+ procid_self(),
+ true, FLAG_MSG_PRINT_NOTIFY);
}
/*
diff --git a/source3/smbd/connection.c b/source3/smbd/connection.c
index e2b01d0579..fe1fcdbdb8 100644
--- a/source3/smbd/connection.c
+++ b/source3/smbd/connection.c
@@ -170,47 +170,3 @@ bool claim_connection(connection_struct *conn, const char *name,
return True;
}
-
-bool register_message_flags(bool doreg, uint32 msg_flags)
-{
- struct db_record *rec;
- struct connections_data *pcrec;
- NTSTATUS status;
-
- DEBUG(10,("register_message_flags: %s flags 0x%x\n",
- doreg ? "adding" : "removing",
- (unsigned int)msg_flags ));
-
- if (!(rec = connections_fetch_entry(NULL, NULL, ""))) {
- DEBUG(0, ("connections_fetch_entry failed\n"));
- return False;
- }
-
- if (rec->value.dsize != sizeof(struct connections_data)) {
- DEBUG(0,("register_message_flags: Got wrong record size\n"));
- TALLOC_FREE(rec);
- return False;
- }
-
- pcrec = (struct connections_data *)rec->value.dptr;
- if (doreg)
- pcrec->bcast_msg_flags |= msg_flags;
- else
- pcrec->bcast_msg_flags &= ~msg_flags;
-
- status = rec->store(rec, rec->value, TDB_REPLACE);
-
- if (!NT_STATUS_IS_OK(status)) {
- DEBUG(0,("register_message_flags: tdb_store failed: %s.\n",
- nt_errstr(status)));
- TALLOC_FREE(rec);
- return False;
- }
-
- DEBUG(10,("register_message_flags: new flags 0x%x\n",
- (unsigned int)pcrec->bcast_msg_flags ));
-
- TALLOC_FREE(rec);
-
- return True;
-}