[SCM] Samba Shared Repository - branch master updated

Jeremy Allison jra at samba.org
Wed Jun 21 05:31:02 UTC 2017


The branch, master has been updated
       via  a2436b6 messaging: Deliver messages only once
       via  46a1ae5 dbwrap: Remove unused dbwrap_file
       via  fe1d17a dbwrap: Remove unused dbwrap_cache
       via  ac656f3 lib: Fix typos
       via  e0aec28 ctdb: Fix typos
       via  a7504f5 tevent: Simplify create_immediate
       via  ce9e92c lib: Give messages_ctdbd.c its own header
       via  c8f05f9 messaging: Use size_t for array sizes
      from  f393edd selftest: Give tmux a bit of time to establish

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit a2436b67e5dd47d955a3bea2b83e0693b627ab96
Author: Volker Lendecke <vl at samba.org>
Date:   Sat Jun 17 08:48:16 2017 +0200

    messaging: Deliver messages only once
    
    This survived an autobuild, so no subsystem strictly needs this anymore. In
    particular the notify subsystem has been rewritten.
    
    Why this patch? It removes some complexity from core code, and it reduces the
    potential memory overconsumption: Right now I'm working on a g_lock_ping_pong
    test. This test does a lot of messaging_filtered_read_send calls in a tight
    loop on a nested event context. With the current code we let the
    messaging_filtered_read code consume the message that arrives, but it also
    posts it for consumption by the main event context attached to the messaging
    context with its "classic" callback. This test never comes back to the main
    event context, so it accumulates more and more self-posted messages. That's
    just unnecessary, given that due to the successful autobuild nothing but the
    read1 test makes use of the "multicasting" of messages.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    
    Autobuild-User(master): Jeremy Allison <jra at samba.org>
    Autobuild-Date(master): Wed Jun 21 07:30:39 CEST 2017 on sn-devel-144

commit 46a1ae5d71dd5266d87a3563ca8e800912138327
Author: Volker Lendecke <vl at samba.org>
Date:   Fri May 26 18:48:32 2017 +0200

    dbwrap: Remove unused dbwrap_file
    
    This has stopped working ages ago. The idea is clear, but if someone
    wants to revive it, I think it needs a completely fresh start.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit fe1d17a48f53b10b3bea6b84685dbb3f282e086f
Author: Volker Lendecke <vl at samba.org>
Date:   Fri May 26 18:47:23 2017 +0200

    dbwrap: Remove unused dbwrap_cache
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit ac656f3ddd70053260ddc2d191d1a386841d7270
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Jun 8 12:20:15 2017 +0200

    lib: Fix typos
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit e0aec28d6fcf45dd983d00f8cfbb12d49f7d3eba
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Jun 8 11:44:36 2017 +0200

    ctdb: Fix typos
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit a7504f555eff101a10ded653ceac98d8294c1659
Author: Volker Lendecke <vl at samba.org>
Date:   Sat Jun 17 21:26:27 2017 +0200

    tevent: Simplify create_immediate
    
    Not much change, just 9 lines less of code.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit ce9e92c114ef296e34017c067ed064388864309c
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Jun 1 19:25:48 2017 +0200

    lib: Give messages_ctdbd.c its own header
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit c8f05f97361998b32ec452b7dbadf5f80aa52a09
Author: Volker Lendecke <vl at samba.org>
Date:   Sat Jun 17 09:46:43 2017 +0200

    messaging: Use size_t for array sizes
    
    We use talloc_realloc, that takes size_t.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

-----------------------------------------------------------------------

Summary of changes:
 ctdb/client/client.h                               |   4 +-
 lib/dbwrap/dbwrap_cache.c                          | 227 -----------
 lib/dbwrap/dbwrap_cache.h                          |  28 --
 lib/dbwrap/dbwrap_file.c                           | 423 ---------------------
 lib/dbwrap/dbwrap_file.h                           |  33 --
 lib/dbwrap/wscript_build                           |   2 +-
 lib/tevent/tevent.c                                |  11 +-
 source3/include/messages.h                         |   8 -
 source3/lib/ctdb_dummy.c                           |   1 +
 source3/lib/ctdbd_conn.c                           |   2 +-
 source3/lib/dbwrap/dbwrap_ctdb.c                   |   2 +-
 source3/lib/dbwrap/dbwrap_open.c                   |   1 +
 source3/lib/messages.c                             |  41 +-
 source3/lib/messages_ctdbd.c                       |   1 +
 .../lib/{server_id_watch.h => messages_ctdbd.h}    |  24 +-
 source3/lib/serverid.c                             |   1 +
 source3/smbd/notifyd/notifyd.h                     |   1 +
 source3/smbd/notifyd/notifydd.c                    |   1 +
 source3/smbd/process.c                             |   1 +
 source3/smbd/server.c                              |   1 +
 source3/torture/test_dbwrap_ctdb.c                 |   1 +
 source3/torture/test_messaging_read.c              |   6 +-
 22 files changed, 50 insertions(+), 770 deletions(-)
 delete mode 100644 lib/dbwrap/dbwrap_cache.c
 delete mode 100644 lib/dbwrap/dbwrap_cache.h
 delete mode 100644 lib/dbwrap/dbwrap_file.c
 delete mode 100644 lib/dbwrap/dbwrap_file.h
 copy source3/lib/{server_id_watch.h => messages_ctdbd.h} (61%)


Changeset truncated at 500 lines:

diff --git a/ctdb/client/client.h b/ctdb/client/client.h
index b7b657c..5e3b5c6 100644
--- a/ctdb/client/client.h
+++ b/ctdb/client/client.h
@@ -119,7 +119,7 @@ uint32_t ctdb_client_pnn(struct ctdb_client_context *client);
 /**
  * @brief Client event loop waiting for a flag
  *
- * This can used to wait for asynchronous comptuations to complete.
+ * This can used to wait for asynchronous computations to complete.
  * When this function is called, it will run tevent event loop and wait
  * till the done flag is set to true.  This function will block and will
  * not return as long as the done flag is false.
@@ -151,7 +151,7 @@ int ctdb_client_wait_timeout(struct tevent_context *ev, bool *done,
 /**
  * @brief Async computation start to wait till recovery is completed
  *
- * CTDB deamon does not perform many operations while in recovery (specially
+ * CTDB daemon does not perform many operations while in recovery (especially
  * database operations).  This computation allows to wait till ctdb daemon has
  * finished recovery.
  *
diff --git a/lib/dbwrap/dbwrap_cache.c b/lib/dbwrap/dbwrap_cache.c
deleted file mode 100644
index e4cee55..0000000
--- a/lib/dbwrap/dbwrap_cache.c
+++ /dev/null
@@ -1,227 +0,0 @@
-/*
-   Unix SMB/CIFS implementation.
-   Cache db contents for parse_record based on seqnum
-   Copyright (C) Volker Lendecke 2012
-
-   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/>.
-*/
-
-#include "replace.h"
-#include "lib/param/loadparm.h"
-#include "lib/dbwrap/dbwrap_cache.h"
-#include "lib/dbwrap/dbwrap_private.h"
-#include "lib/dbwrap/dbwrap_rbt.h"
-#include "lib/util/talloc_stack.h"
-
-struct db_cache_ctx {
-	int seqnum;
-	struct db_context *backing;
-	struct db_context *positive;
-	struct db_context *negative;
-};
-
-static bool dbwrap_cache_validate(struct db_cache_ctx *ctx)
-{
-	int backing_seqnum;
-
-	backing_seqnum = dbwrap_get_seqnum(ctx->backing);
-	if (backing_seqnum == ctx->seqnum) {
-		return true;
-	}
-
-	TALLOC_FREE(ctx->positive);
-	ctx->positive = db_open_rbt(ctx);
-	if (ctx->positive == NULL) {
-		return false;
-	}
-
-	TALLOC_FREE(ctx->negative);
-	ctx->negative = db_open_rbt(ctx);
-	if (ctx->negative == NULL) {
-		return false;
-	}
-
-	ctx->seqnum = backing_seqnum;
-	return true;
-}
-
-static NTSTATUS dbwrap_cache_parse_record(
-	struct db_context *db, TDB_DATA key,
-	void (*parser)(TDB_DATA key, TDB_DATA data, void *private_data),
-	void *private_data)
-{
-	struct db_cache_ctx *ctx = talloc_get_type_abort(
-		db->private_data, struct db_cache_ctx);
-	TDB_DATA value;
-	NTSTATUS status;
-
-	if (!dbwrap_cache_validate(ctx)) {
-		return NT_STATUS_NO_MEMORY;
-	}
-
-	if (dbwrap_exists(ctx->negative, key)) {
-		return NT_STATUS_NOT_FOUND;
-	}
-	status = dbwrap_parse_record(ctx->positive, key, parser, private_data);
-	if (NT_STATUS_IS_OK(status)) {
-		return status;
-	}
-
-	status = dbwrap_fetch(ctx->backing, talloc_tos(), key, &value);
-
-	if (NT_STATUS_IS_OK(status)) {
-		dbwrap_store(ctx->positive, key, value, 0);
-		parser(key, value, private_data);
-		TALLOC_FREE(value.dptr);
-		return NT_STATUS_OK;
-	}
-
-	if (NT_STATUS_EQUAL(status, NT_STATUS_NOT_FOUND)) {
-		char c = '\0';
-		value.dptr = (uint8_t *)&c;
-		value.dsize = sizeof(c);
-		dbwrap_store(ctx->negative, key, value, 0);
-		return NT_STATUS_NOT_FOUND;
-	}
-	return status;
-}
-
-static struct db_record *dbwrap_cache_fetch_locked(
-	struct db_context *db, TALLOC_CTX *mem_ctx, TDB_DATA key)
-{
-	struct db_cache_ctx *ctx = talloc_get_type_abort(
-		db->private_data, struct db_cache_ctx);
-	return dbwrap_fetch_locked(ctx->backing, mem_ctx, key);
-}
-
-static int dbwrap_cache_traverse(struct db_context *db,
-				 int (*f)(struct db_record *rec,
-					  void *private_data),
-				 void *private_data)
-{
-	struct db_cache_ctx *ctx = talloc_get_type_abort(
-		db->private_data, struct db_cache_ctx);
-	NTSTATUS status;
-	int ret;
-	status = dbwrap_traverse(ctx->backing, f, private_data, &ret);
-	if (!NT_STATUS_IS_OK(status)) {
-		return -1;
-	}
-	return ret;
-}
-
-static int dbwrap_cache_traverse_read(struct db_context *db,
-				      int (*f)(struct db_record *rec,
-					       void *private_data),
-				      void *private_data)
-{
-	struct db_cache_ctx *ctx = talloc_get_type_abort(
-		db->private_data, struct db_cache_ctx);
-	NTSTATUS status;
-	int ret;
-	status = dbwrap_traverse_read(ctx->backing, f, private_data, &ret);
-	if (!NT_STATUS_IS_OK(status)) {
-		return -1;
-	}
-	return ret;
-}
-
-static int dbwrap_cache_get_seqnum(struct db_context *db)
-{
-	struct db_cache_ctx *ctx = talloc_get_type_abort(
-		db->private_data, struct db_cache_ctx);
-	return dbwrap_get_seqnum(ctx->backing);
-}
-
-static int dbwrap_cache_transaction_start(struct db_context *db)
-{
-	struct db_cache_ctx *ctx = talloc_get_type_abort(
-		db->private_data, struct db_cache_ctx);
-	return dbwrap_transaction_start(ctx->backing);
-}
-
-static int dbwrap_cache_transaction_commit(struct db_context *db)
-{
-	struct db_cache_ctx *ctx = talloc_get_type_abort(
-		db->private_data, struct db_cache_ctx);
-	return dbwrap_transaction_commit(ctx->backing);
-}
-
-static int dbwrap_cache_transaction_cancel(struct db_context *db)
-{
-	struct db_cache_ctx *ctx = talloc_get_type_abort(
-		db->private_data, struct db_cache_ctx);
-	return dbwrap_transaction_cancel(ctx->backing);
-}
-
-static int dbwrap_cache_exists(struct db_context *db, TDB_DATA key)
-{
-	struct db_cache_ctx *ctx = talloc_get_type_abort(
-		db->private_data, struct db_cache_ctx);
-
-	if (ctx->positive && dbwrap_exists(ctx->positive, key)) {
-		return true;
-	}
-	if (ctx->negative && dbwrap_exists(ctx->negative, key)) {
-		return false;
-	}
-	return dbwrap_exists(ctx->backing, key);
-}
-
-static size_t dbwrap_cache_id(struct db_context *db, uint8_t *id,
-			      size_t idlen)
-{
-	struct db_cache_ctx *ctx = talloc_get_type_abort(
-		db->private_data, struct db_cache_ctx);
-
-	return dbwrap_db_id(ctx->backing, id, idlen);
-}
-
-struct db_context *db_open_cache(TALLOC_CTX *mem_ctx,
-				 struct db_context *backing)
-{
-	struct db_context *db;
-	struct db_cache_ctx *ctx;
-
-	db = talloc_zero(mem_ctx, struct db_context);
-	if (db == NULL) {
-		return NULL;
-	}
-	ctx = talloc_zero(db, struct db_cache_ctx);
-	if (ctx == NULL) {
-		TALLOC_FREE(db);
-		return NULL;
-	}
-
-	ctx->seqnum = -1;
-	ctx->backing = talloc_move(ctx, &backing);
-	db->private_data = ctx;
-	if (!dbwrap_cache_validate(ctx)) {
-		TALLOC_FREE(db);
-		return NULL;
-	}
-
-	db->fetch_locked = dbwrap_cache_fetch_locked;
-	db->traverse = dbwrap_cache_traverse;
-	db->traverse_read = dbwrap_cache_traverse_read;
-	db->get_seqnum = dbwrap_cache_get_seqnum;
-	db->transaction_start = dbwrap_cache_transaction_start;
-	db->transaction_commit = dbwrap_cache_transaction_commit;
-	db->transaction_cancel = dbwrap_cache_transaction_cancel;
-	db->parse_record = dbwrap_cache_parse_record;
-	db->exists = dbwrap_cache_exists;
-	db->id = dbwrap_cache_id;
-	db->name = dbwrap_name(ctx->backing);
-	return db;
-}
diff --git a/lib/dbwrap/dbwrap_cache.h b/lib/dbwrap/dbwrap_cache.h
deleted file mode 100644
index e69d58e..0000000
--- a/lib/dbwrap/dbwrap_cache.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
-   Unix SMB/CIFS implementation.
-   Database interface wrapper around ctdbd
-   Copyright (C) Volker Lendecke 2012
-
-   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/>.
-*/
-
-#ifndef __DBWRAP_CACHE_H__
-#define __DBWRAP_CACHE_H__
-
-#include "dbwrap.h"
-
-struct db_context *db_open_cache(TALLOC_CTX *mem_ctx,
-				 struct db_context *backing);
-
-#endif /* __DBWRAP_CACHE_H__ */
diff --git a/lib/dbwrap/dbwrap_file.c b/lib/dbwrap/dbwrap_file.c
deleted file mode 100644
index 46e62c8..0000000
--- a/lib/dbwrap/dbwrap_file.c
+++ /dev/null
@@ -1,423 +0,0 @@
-/*
-   Unix SMB/CIFS implementation.
-   Database interface using a file per record
-   Copyright (C) Volker Lendecke 2005
-
-   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/>.
-*/
-
-#include "includes.h"
-#include "dbwrap/dbwrap.h"
-#include "dbwrap/dbwrap_file.h"
-#include "dbwrap/dbwrap_private.h"
-#include "lib/tdb_wrap/tdb_wrap.h"
-
-struct db_file_ctx {
-	const char *dirname;
-
-	/* We only support one locked record at a time -- everything else
-	 * would lead to a potential deadlock anyway! */
-	struct db_record *locked_record;
-};
-
-struct db_locked_file {
-	int fd;
-	uint8_t hash;
-	const char *name;
-	const char *path;
-	struct db_file_ctx *parent;
-};
-
-/* Copy from statcache.c... */
-
-static uint32_t fsh(const uint8_t *p, int len)
-{
-        uint32_t n = 0;
-	int i;
-        for (i=0; i<len; i++) {
-                n = ((n << 5) + n) ^ (uint32_t)(p[i]);
-        }
-        return n;
-}
-
-static int db_locked_file_destr(struct db_locked_file *data)
-{
-	if (data->parent != NULL) {
-		data->parent->locked_record = NULL;
-	}
-
-	if (close(data->fd) != 0) {
-		DEBUG(3, ("close failed: %s\n", strerror(errno)));
-		return -1;
-	}
-
-	return 0;
-}
-
-static NTSTATUS db_file_store(struct db_record *rec, TDB_DATA data, int flag);
-static NTSTATUS db_file_delete(struct db_record *rec);
-
-static struct db_record *db_file_fetch_locked(struct db_context *db,
-					      TALLOC_CTX *mem_ctx,
-					      TDB_DATA key)
-{
-	struct db_file_ctx *ctx = talloc_get_type_abort(db->private_data,
-							struct db_file_ctx);
-	struct db_record *result;
-	struct db_locked_file *file;
-	struct flock fl;
-	SMB_STRUCT_STAT statbuf;
-	int ret;
-
-	SMB_ASSERT(ctx->locked_record == NULL);
-
- again:
-	if (!(result = talloc(mem_ctx, struct db_record))) {
-		DEBUG(0, ("talloc failed\n"));
-		return NULL;
-	}
-
-	if (!(file = talloc(result, struct db_locked_file))) {
-		DEBUG(0, ("talloc failed\n"));
-		TALLOC_FREE(result);
-		return NULL;
-	}
-
-	result->private_data = file;
-	result->store = db_file_store;
-	result->delete_rec = db_file_delete;
-
-	result->key.dsize = key.dsize;
-	result->key.dptr = (uint8_t *)talloc_memdup(result, key.dptr,
-						    key.dsize);
-	if (result->key.dptr == NULL) {
-		DEBUG(0, ("talloc failed\n"));
-		TALLOC_FREE(result);
-		return NULL;
-	}
-
-	/* Cut to 8 bits */
-	file->hash = fsh(key.dptr, key.dsize);
-	file->name = hex_encode_talloc(file, (unsigned char *)key.dptr, key.dsize);
-	if (file->name == NULL) {
-		DEBUG(0, ("hex_encode failed\n"));
-		TALLOC_FREE(result);
-		return NULL;
-	}
-
-	file->path = talloc_asprintf(file, "%s/%2.2X/%s", ctx->dirname,
-				     file->hash, file->name);
-	if (file->path == NULL) {
-		DEBUG(0, ("talloc_asprintf failed\n"));
-		TALLOC_FREE(result);
-		return NULL;
-	}
-
-	become_root();
-	file->fd = open(file->path, O_RDWR|O_CREAT, 0644);
-	unbecome_root();
-
-	if (file->fd < 0) {
-		DEBUG(3, ("Could not open/create %s: %s\n",
-			  file->path, strerror(errno)));
-		TALLOC_FREE(result);
-		return NULL;
-	}
-
-	talloc_set_destructor(file, db_locked_file_destr);
-
-	fl.l_type = F_WRLCK;
-	fl.l_whence = SEEK_SET;
-	fl.l_start = 0;
-	fl.l_len = 1;
-	fl.l_pid = 0;
-
-	do {
-		ret = fcntl(file->fd, F_SETLKW, &fl);
-	} while ((ret == -1) && (errno == EINTR));
-
-	if (ret == -1) {
-		DEBUG(3, ("Could not get lock on %s: %s\n",
-			  file->path, strerror(errno)));
-		TALLOC_FREE(result);
-		return NULL;
-	}
-
-	if (sys_fstat(file->fd, &statbuf, false) != 0) {
-		DEBUG(3, ("Could not fstat %s: %s\n",
-			  file->path, strerror(errno)));
-		TALLOC_FREE(result);
-		return NULL;
-	}
-
-	if (statbuf.st_ex_nlink == 0) {
-		/* Someone has deleted it under the lock, retry */
-		TALLOC_FREE(result);
-		goto again;
-	}
-
-	result->value.dsize = 0;
-	result->value.dptr = NULL;
-
-	if (statbuf.st_ex_size != 0) {
-		ssize_t read_bytes;
-
-		result->value.dsize = statbuf.st_ex_size;
-		result->value.dptr = talloc_array(result, uint8_t,
-						  statbuf.st_ex_size);
-		if (result->value.dptr == NULL) {
-			DEBUG(1, ("talloc failed\n"));
-			TALLOC_FREE(result);
-			return NULL;
-		}
-
-		read_bytes = read_data(file->fd, (char *)result->value.dptr,
-				       result->value.dsize);
-		if (read_bytes != result->value.dsize) {
-			DEBUG(3, ("read_data failed: %s\n", strerror(errno)));
-			TALLOC_FREE(result);
-			return NULL;
-		}
-	}
-
-	ctx->locked_record = result;
-	file->parent = (struct db_file_ctx *)talloc_reference(file, ctx);
-
-	return result;
-}
-
-static NTSTATUS db_file_store_root(int fd, TDB_DATA data)
-{
-	if (lseek(fd, 0, SEEK_SET) != 0) {
-		DEBUG(0, ("lseek failed: %s\n", strerror(errno)));
-		return map_nt_error_from_unix(errno);
-	}


-- 
Samba Shared Repository



More information about the samba-cvs mailing list