summaryrefslogtreecommitdiffstats
path: root/source/smbd
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2004-10-29 07:29:26 +0000
committerAndrew Tridgell <tridge@samba.org>2004-10-29 07:29:26 +0000
commite9e2a7e7fa497dfd523ec806e6ef2f514235b047 (patch)
treed893f50e901824826b94b5816246790ddbb06c92 /source/smbd
parentd2a2da252bf9480504ac37451de6e69319d27538 (diff)
downloadsamba-e9e2a7e7fa497dfd523ec806e6ef2f514235b047.tar.gz
samba-e9e2a7e7fa497dfd523ec806e6ef2f514235b047.tar.xz
samba-e9e2a7e7fa497dfd523ec806e6ef2f514235b047.zip
r3357: removed the need to use TDB_CLEAR_IF_FIRST in Samba4.
We found a few months ago that TDB_CLEAR_IF_FIRST is extremely inefficient for large numbers of connections, due to a fundamental limitation in the way posix byte range locking is implemented. Rather than the nasty workaround we had for Samba3, we now have a single "cleanup tmp files" function that runs when smbd starts. That deletes the tmp tdbs, so TDB_CLEAR_IF_FIRST is not needed at all.
Diffstat (limited to 'source/smbd')
-rw-r--r--source/smbd/rewrite.c16
-rw-r--r--source/smbd/service.c30
2 files changed, 34 insertions, 12 deletions
diff --git a/source/smbd/rewrite.c b/source/smbd/rewrite.c
index 035532a01f0..ff311c6680d 100644
--- a/source/smbd/rewrite.c
+++ b/source/smbd/rewrite.c
@@ -19,18 +19,12 @@ BOOL share_access_check(struct smbsrv_request *req, struct smbsrv_tcon *tcon, in
{ return True; }
/*
- * initialize an smb process
+ * initialize an smb process. Guaranteed to be called only once per
+ * smbd instance (so it can assume it is starting from scratch, and
+ * delete temporary files etc)
*/
void smbd_process_init(void)
{
- TALLOC_CTX *mem_ctx;
-
- mem_ctx = talloc_init("smbd_process_init talloc");
- if (!mem_ctx) {
- DEBUG(0,("smbd_process_init: ERROR: No memory\n"));
- exit(1);
- }
-
/* possibly reload the services file. */
reload_services(NULL, True);
@@ -39,9 +33,7 @@ void smbd_process_init(void)
DEBUG(2,("Changed root to %s\n", lp_rootdir()));
}
- /* Start old-style secrets subsystem */
-
- talloc_destroy(mem_ctx);
+ service_cleanup_tmp_files();
}
void init_subsystems(void)
diff --git a/source/smbd/service.c b/source/smbd/service.c
index ca5f5e75316..33c0d5fcbdf 100644
--- a/source/smbd/service.c
+++ b/source/smbd/service.c
@@ -349,3 +349,33 @@ void service_close_listening_sockets(struct server_context *srv_ctx)
}
}
}
+
+
+/*
+ cleanup temporary files. This is the new alternative to
+ TDB_CLEAR_IF_FIRST. Unfortunately TDB_CLEAR_IF_FIRST is not
+ efficient on unix systems due to the lack of scaling of the byte
+ range locking system. So instead of putting the burden on tdb to
+ cleanup tmp files, this function deletes them. You need to expand
+ the list here as appropriate.
+*/
+void service_cleanup_tmp_files(void)
+{
+ const char *list[] = {
+ "openfiles.tdb",
+ "brlock.tdb",
+ "unexpected.tdb"};
+ int i;
+ for (i=0;i<ARRAY_SIZE(list);i++) {
+ char *path = lock_path(NULL, list[i]);
+ int ret;
+ ret = unlink(path);
+ if (ret == -1 &&
+ errno != ENOENT &&
+ errno != ENOTDIR) {
+ DEBUG(0,("Failed to cleanup '%s'\n", path));
+ smb_panic("unable to cleanup temporary files\n");
+ }
+ talloc_free(path);
+ }
+}