The branch, master has been updated via 4ae2789 lib/debug Use vdprintf rather than manually allocate via ad7b551 s4-torture Remove torture/locktest2.c (no longer compiled and unused) via e7eac0e lib/util Remove setup_logging_stdout() from 7e23363 s4-ldb: removed ldb_includes.h
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit 4ae27891f8ac0a56d68b0544e78d6c17ade0c1c9 Author: Andrew Bartlett <abart...@samba.org> Date: Fri Oct 29 15:56:29 2010 +1100 lib/debug Use vdprintf rather than manually allocate This allows the system to use whatever buffers it wants for the string rather than assuming we need to malloc() it. Andrew Bartlett Autobuild-User: Andrew Bartlett <abart...@samba.org> Autobuild-Date: Tue Nov 2 00:18:43 UTC 2010 on sn-devel-104 commit ad7b551edc75ffb7233f5eafdd3680c2c20eef92 Author: Andrew Bartlett <abart...@samba.org> Date: Fri Oct 29 15:11:11 2010 +1100 s4-torture Remove torture/locktest2.c (no longer compiled and unused) This is a left-over of a speculative approach to lock testing that didn't go anywhere. Andrew Bartlett commit e7eac0e391c2d8b79fe0601db2c5d14fbfbb308e Author: Andrew Bartlett <abart...@samba.org> Date: Fri Oct 29 15:00:01 2010 +1100 lib/util Remove setup_logging_stdout() This API is no longer required now that we don't attempt to build ndrdump with the s3 build system, and because the s3 debug system will soon have the same setup_logging() API. Andrew Bartlett ----------------------------------------------------------------------- Summary of changes: lib/util/debug.c | 15 +- lib/util/debug.h | 7 +- librpc/tools/ndrdump.c | 2 +- source4/torture/locktest2.c | 578 ------------------------------------------- 4 files changed, 3 insertions(+), 599 deletions(-) delete mode 100644 source4/torture/locktest2.c Changeset truncated at 500 lines: diff --git a/lib/util/debug.c b/lib/util/debug.c index c8a2214..5760a70 100644 --- a/lib/util/debug.c +++ b/lib/util/debug.c @@ -37,7 +37,6 @@ static int debug_all_class_hack = 1; int *DEBUGLEVEL_CLASS = &debug_all_class_hack; /* For samba 3 */ static bool debug_all_class_isset_hack = true; bool *DEBUGLEVEL_CLASS_ISSET = &debug_all_class_isset_hack; /* For samba 3 */ -XFILE *dbf = NULL; /* For Samba 3*/ /* the registered mutex handlers */ static struct { @@ -119,16 +118,12 @@ _PUBLIC_ void dbghdrclass(int level, int dclass, const char *location, const cha _PUBLIC_ void dbgtext(const char *format, ...) { va_list ap; - char *s = NULL; if (!check_reopen_logs()) return; va_start(ap, format); - vasprintf(&s, format, ap); + vdprintf(state.fd, format, ap); va_end(ap); - - write(state.fd, s, strlen(s)); - free(s); } _PUBLIC_ const char *logfile = NULL; @@ -210,14 +205,6 @@ _PUBLIC_ void setup_logging(const char *prog_name, enum debug_logtype new_logtyp } /** - Just run logging to stdout for this program -*/ -_PUBLIC_ void setup_logging_stdout(void) -{ - setup_logging(NULL, DEBUG_STDOUT); -} - -/** return a string constant containing n tabs no more than 10 tabs are returned */ diff --git a/lib/util/debug.h b/lib/util/debug.h index 0172df8..a62db1a 100644 --- a/lib/util/debug.h +++ b/lib/util/debug.h @@ -79,7 +79,7 @@ extern int DEBUGLEVEL; * for example. This makes it easy to override for debug to stderr on * the command line, as the smb.conf cannot reset it back to * file-based logging */ -enum debug_logtype {DEBUG_STDOUT = 0, DEBUG_FILE = 1, DEBUG_STDERR = 2}; +enum debug_logtype {DEBUG_DEFAULT_STDERR = 0, DEBUG_STDOUT = 1, DEBUG_FILE = 2, DEBUG_STDERR = 3}; /** the backend for debug messages. Note that the DEBUG() macro has already @@ -106,11 +106,6 @@ _PUBLIC_ void debug_schedule_reopen_logs(void); _PUBLIC_ void setup_logging(const char *prog_name, enum debug_logtype new_logtype); /** - Just run logging to stdout for this program -*/ -_PUBLIC_ void setup_logging_stdout(void); - -/** return a string constant containing n tabs no more than 10 tabs are returned */ diff --git a/librpc/tools/ndrdump.c b/librpc/tools/ndrdump.c index b9b4bc7..f0f4eaf 100644 --- a/librpc/tools/ndrdump.c +++ b/librpc/tools/ndrdump.c @@ -180,7 +180,7 @@ static void ndrdump_data(uint8_t *d, uint32_t l, bool force) setlinebuf(stdout); - setup_logging_stdout(); + setup_logging("ndrdump", DEBUG_STDOUT); pc = poptGetContext("ndrdump", argc, argv, long_options, 0); diff --git a/source4/torture/locktest2.c b/source4/torture/locktest2.c deleted file mode 100644 index 7364d6d..0000000 --- a/source4/torture/locktest2.c +++ /dev/null @@ -1,578 +0,0 @@ -/* - Unix SMB/CIFS implementation. - byte range lock tester - with local filesystem support - Copyright (C) Andrew Tridgell 1999 - - 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 "system/passwd.h" -#include "lib/events/events.h" - -static fstring password; -static fstring username; -static int got_pass; -static int numops = 1000; -static bool showall; -static bool analyze; -static bool hide_unlock_fails; -static bool use_oplocks; - -#define FILENAME "\\locktest.dat" -#define LOCKRANGE 100 -#define LOCKBASE 0 - -/* -#define LOCKBASE (0x40000000 - 50) -*/ - -#define READ_PCT 50 -#define LOCK_PCT 25 -#define UNLOCK_PCT 65 -#define RANGE_MULTIPLE 1 - -#define NSERVERS 2 -#define NCONNECTIONS 2 -#define NUMFSTYPES 2 -#define NFILES 2 -#define LOCK_TIMEOUT 0 - -#define FSTYPE_SMB 0 -#define FSTYPE_NFS 1 - -struct record { - char r1, r2; - char conn, f, fstype; - unsigned int start, len; - char needed; -}; - -static struct record *recorded; - -static int try_open(struct smbcli_state *c, char *nfs, int fstype, const char *fname, int flags) -{ - char *path; - int ret; - - switch (fstype) { - case FSTYPE_SMB: - return smbcli_open(c, fname, flags, DENY_NONE); - - case FSTYPE_NFS: - asprintf(&path, "%s%s", nfs, fname); - string_replace(path,'\\', '/'); - ret = open(path, flags, 0666); - SAFE_FREE(Path); - return ret; - } - - return -1; -} - -static bool try_close(struct smbcli_state *c, int fstype, int fd) -{ - switch (fstype) { - case FSTYPE_SMB: - return smbcli_close(c, fd); - - case FSTYPE_NFS: - return close(fd) == 0; - } - - return false; -} - -static bool try_lock(struct smbcli_state *c, int fstype, - int fd, unsigned int start, unsigned int len, - enum brl_type op) -{ - struct flock lock; - - switch (fstype) { - case FSTYPE_SMB: - return smbcli_lock(c, fd, start, len, LOCK_TIMEOUT, op); - - case FSTYPE_NFS: - lock.l_type = (op==READ_LOCK) ? F_RDLCK:F_WRLCK; - lock.l_whence = SEEK_SET; - lock.l_start = start; - lock.l_len = len; - lock.l_pid = getpid(); - return fcntl(fd,F_SETLK,&lock) == 0; - } - - return false; -} - -static bool try_unlock(struct smbcli_state *c, int fstype, - int fd, unsigned int start, unsigned int len) -{ - struct flock lock; - - switch (fstype) { - case FSTYPE_SMB: - return smbcli_unlock(c, fd, start, len); - - case FSTYPE_NFS: - lock.l_type = F_UNLCK; - lock.l_whence = SEEK_SET; - lock.l_start = start; - lock.l_len = len; - lock.l_pid = getpid(); - return fcntl(fd,F_SETLK,&lock) == 0; - } - - return false; -} - -/***************************************************** -return a connection to a server -*******************************************************/ -static struct smbcli_state *connect_one(TALLOC_CTX *mem_ctx, - char *share, const char **ports, - struct smb_options *options, - struct smb_options *session_options, - struct gensec_settings *gensec_settings, - struct tevent_context *ev) -{ - struct smbcli_state *c; - char *server_n; - char *server; - char *myname; - static int count; - NTSTATUS nt_status; - - server = talloc_strdup(mem_ctx, share+2); - share = strchr_m(server,'\\'); - if (!share) return NULL; - *share = 0; - share++; - - server_n = server; - - if (!got_pass) { - char *pass = getpass("Password: "); - if (pass) { - password = talloc_strdup(mem_ctx, pass); - } - } - - myname = talloc_asprintf(mem_ctx, "lock-%u-%u", getpid(), count++); - - nt_status = smbcli_full_connection(NULL, - &c, myname, server_n, ports, share, NULL, - username, lpcfg_workgroup(), password, ev, - options, session_options, gensec_settings); - if (!NT_STATUS_IS_OK(nt_status)) { - DEBUG(0, ("smbcli_full_connection failed with error %s\n", nt_errstr(nt_status))); - return NULL; - } - - c->use_oplocks = use_oplocks; - - return c; -} - - -static void reconnect(TALLOC_CTX *mem_ctx, - struct smbcli_state *cli[NSERVERS][NCONNECTIONS], - char *nfs[NSERVERS], - int fnum[NSERVERS][NUMFSTYPES][NCONNECTIONS][NFILES], - const char **ports, - struct smbcli_options *options, - struct smbcli_session_options *session_options, - struct gensec_settings *gensec_settings, - struct tevent_context *ev, - char *share1, char *share2) -{ - int server, conn, f, fstype; - char *share[2]; - share[0] = share1; - share[1] = share2; - - fstype = FSTYPE_SMB; - - for (server=0;server<NSERVERS;server++) - for (conn=0;conn<NCONNECTIONS;conn++) { - if (cli[server][conn]) { - for (f=0;f<NFILES;f++) { - smbcli_close(cli[server][conn], fnum[server][fstype][conn][f]); - } - smbcli_ulogoff(cli[server][conn]); - talloc_free(cli[server][conn]); - } - cli[server][conn] = connect_one(mem_ctx, share[server], ports, options, session_options, gensec_settings, ev); - if (!cli[server][conn]) { - DEBUG(0,("Failed to connect to %s\n", share[server])); - exit(1); - } - } -} - - - -static bool test_one(struct smbcli_state *cli[NSERVERS][NCONNECTIONS], - char *nfs[NSERVERS], - int fnum[NSERVERS][NUMFSTYPES][NCONNECTIONS][NFILES], - struct record *rec) -{ - unsigned int conn = rec->conn; - unsigned int f = rec->f; - unsigned int fstype = rec->fstype; - unsigned int start = rec->start; - unsigned int len = rec->len; - unsigned int r1 = rec->r1; - unsigned int r2 = rec->r2; - enum brl_type op; - int server; - bool ret[NSERVERS]; - - if (r1 < READ_PCT) { - op = READ_LOCK; - } else { - op = WRITE_LOCK; - } - - if (r2 < LOCK_PCT) { - /* set a lock */ - for (server=0;server<NSERVERS;server++) { - ret[server] = try_lock(cli[server][conn], fstype, - fnum[server][fstype][conn][f], - start, len, op); - } - if (showall || ret[0] != ret[1]) { - printf("lock conn=%u fstype=%u f=%u range=%u:%u(%u) op=%s -> %u:%u\n", - conn, fstype, f, - start, start+len-1, len, - op==READ_LOCK?"READ_LOCK":"WRITE_LOCK", - ret[0], ret[1]); - } - if (ret[0] != ret[1]) return false; - } else if (r2 < LOCK_PCT+UNLOCK_PCT) { - /* unset a lock */ - for (server=0;server<NSERVERS;server++) { - ret[server] = try_unlock(cli[server][conn], fstype, - fnum[server][fstype][conn][f], - start, len); - } - if (showall || (!hide_unlock_fails && (ret[0] != ret[1]))) { - printf("unlock conn=%u fstype=%u f=%u range=%u:%u(%u) -> %u:%u\n", - conn, fstype, f, - start, start+len-1, len, - ret[0], ret[1]); - } - if (!hide_unlock_fails && ret[0] != ret[1]) return false; - } else { - /* reopen the file */ - for (server=0;server<NSERVERS;server++) { - try_close(cli[server][conn], fstype, fnum[server][fstype][conn][f]); - fnum[server][fstype][conn][f] = try_open(cli[server][conn], nfs[server], fstype, FILENAME, - O_RDWR|O_CREAT); - if (fnum[server][fstype][conn][f] == -1) { - printf("failed to reopen on share1\n"); - return false; - } - } - if (showall) { - printf("reopen conn=%u fstype=%u f=%u\n", - conn, fstype, f); - } - } - return true; -} - -static void close_files(struct smbcli_state *cli[NSERVERS][NCONNECTIONS], - char *nfs[NSERVERS], - int fnum[NSERVERS][NUMFSTYPES][NCONNECTIONS][NFILES]) -{ - int server, conn, f, fstype; - - for (server=0;server<NSERVERS;server++) - for (fstype=0;fstype<NUMFSTYPES;fstype++) - for (conn=0;conn<NCONNECTIONS;conn++) - for (f=0;f<NFILES;f++) { - if (fnum[server][fstype][conn][f] != -1) { - try_close(cli[server][conn], fstype, fnum[server][fstype][conn][f]); - fnum[server][fstype][conn][f] = -1; - } - } - for (server=0;server<NSERVERS;server++) { - smbcli_unlink(cli[server][0], FILENAME); - } -} - -static void open_files(struct smbcli_state *cli[NSERVERS][NCONNECTIONS], - char *nfs[NSERVERS], - int fnum[NSERVERS][NUMFSTYPES][NCONNECTIONS][NFILES]) -{ - int server, fstype, conn, f; - - for (server=0;server<NSERVERS;server++) - for (fstype=0;fstype<NUMFSTYPES;fstype++) - for (conn=0;conn<NCONNECTIONS;conn++) - for (f=0;f<NFILES;f++) { - fnum[server][fstype][conn][f] = try_open(cli[server][conn], nfs[server], fstype, FILENAME, - O_RDWR|O_CREAT); - if (fnum[server][fstype][conn][f] == -1) { - fprintf(stderr,"Failed to open fnum[%u][%u][%u][%u]\n", - server, fstype, conn, f); - exit(1); - } - } -} - - -static int retest(struct smbcli_state *cli[NSERVERS][NCONNECTIONS], - char *nfs[NSERVERS], - int fnum[NSERVERS][NUMFSTYPES][NCONNECTIONS][NFILES], - int n) -{ - int i; - printf("Testing %u ...\n", n); - for (i=0; i<n; i++) { - if (i && i % 100 == 0) { - printf("%u\n", i); - } - - if (recorded[i].needed && - !test_one(cli, nfs, fnum, &recorded[i])) return i; - } - return n; -} - - -/* each server has two connections open to it. Each connection has two file - descriptors open on the file - 8 file descriptors in total - - we then do random locking ops in tamdem on the 4 fnums from each - server and ensure that the results match - */ -static void test_locks(TALLOC_CTX *mem_ctx, char *share1, char *share2, - char *nfspath1, char *nfspath2, - const char **ports, - struct smbcli_options *options, - struct smbcli_session_options *session_options, - struct gensec_settings *gensec_settings, - struct tevent_context *ev) -{ - struct smbcli_state *cli[NSERVERS][NCONNECTIONS]; - char *nfs[NSERVERS]; - int fnum[NSERVERS][NUMFSTYPES][NCONNECTIONS][NFILES]; - int n, i, n1; - - nfs[0] = nfspath1; - nfs[1] = nfspath2; - - ZERO_STRUCT(fnum); - ZERO_STRUCT(cli); - - recorded = malloc_array_p(struct record, numops); - - for (n=0; n<numops; n++) { - recorded[n].conn = random() % NCONNECTIONS; - recorded[n].fstype = random() % NUMFSTYPES; - recorded[n].f = random() % NFILES; - recorded[n].start = LOCKBASE + ((unsigned int)random() % (LOCKRANGE-1)); - recorded[n].len = 1 + - random() % (LOCKRANGE-(recorded[n].start-LOCKBASE)); - recorded[n].start *= RANGE_MULTIPLE; - recorded[n].len *= RANGE_MULTIPLE; - recorded[n].r1 = random() % 100; - recorded[n].r2 = random() % 100; - recorded[n].needed = true; - } - - reconnect(mem_ctx, cli, nfs, fnum, ports, options, session_options, gensec_settings, ev, share1, share2); - open_files(cli, nfs, fnum); - n = retest(cli, nfs, fnum, numops); - - if (n == numops || !analyze) return; - n++; - - while (1) { - n1 = n; - - close_files(cli, nfs, fnum); - reconnect(mem_ctx, cli, nfs, fnum, ports, options, session_options, ev, share1, share2); - open_files(cli, nfs, fnum); - - for (i=0;i<n-1;i++) { -- Samba Shared Repository