diff options
author | Andrew Bartlett <abartlet@samba.org> | 2010-11-01 20:55:04 +1100 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2010-11-02 04:36:04 +0000 |
commit | b1099a5b560db0145534ed6484eee27c7d93528a (patch) | |
tree | bd775f2d2fe46eb61b0d4306c9f4736f6996c189 /source3/libsmb | |
parent | e16c9904c60bd7531ada1acd2396e56ee1213dea (diff) | |
download | samba-b1099a5b560db0145534ed6484eee27c7d93528a.tar.gz samba-b1099a5b560db0145534ed6484eee27c7d93528a.tar.xz samba-b1099a5b560db0145534ed6484eee27c7d93528a.zip |
s3-libsmbclient Add comments to describe the behaviour of DEBUG()
This isn't quite what you would expect from this interface, but actually
avoids some really nasty situations if you ever have more than one
libsmbclient context in a process.
In the real world, if you have asked for DEBUG() to stderr in one part
of the code, you will want it globally, even in a different thread
(which in the past would have rest everything to stdout again, at
least while starting up).
Andrew Bartlett
Diffstat (limited to 'source3/libsmb')
-rw-r--r-- | source3/libsmb/libsmb_context.c | 8 | ||||
-rw-r--r-- | source3/libsmb/libsmb_setget.c | 12 |
2 files changed, 15 insertions, 5 deletions
diff --git a/source3/libsmb/libsmb_context.c b/source3/libsmb/libsmb_context.c index 8e76387346a..22e0a047172 100644 --- a/source3/libsmb/libsmb_context.c +++ b/source3/libsmb/libsmb_context.c @@ -557,9 +557,11 @@ smbc_init_context(SMBCCTX *context) if (context->internal->debug_stderr) { /* - * Hmmm... Do we want a unique dbf per-thread? For now, we'll just - * leave it up to the user. If any one context spefies debug to - * stderr then all will be. + * We do not have a unique per-thread debug state? For + * now, we'll just leave it up to the user. If any one + * context spefies debug to stderr then all will be (and + * will stay that way, as it is unsafe to flip back if + * stdout is in use for other things) */ setup_logging("libsmbclient", DEBUG_STDERR); } diff --git a/source3/libsmb/libsmb_setget.c b/source3/libsmb/libsmb_setget.c index f2f5aec6c46..0d260d7cf29 100644 --- a/source3/libsmb/libsmb_setget.c +++ b/source3/libsmb/libsmb_setget.c @@ -120,10 +120,18 @@ smbc_setTimeout(SMBCCTX *c, int timeout) smbc_bool smbc_getOptionDebugToStderr(SMBCCTX *c) { - return c->internal->debug_stderr; + /* Because this is a global concept, it is better to check + * what is really set, rather than what we wanted set + * (particularly as you cannot go back to stdout). */ + return debug_get_output_is_stderr(); } -/** Set whether to log to standard error instead of standard output */ +/** Set whether to log to standard error instead of standard output. + * This option is 'sticky' - once set to true, it cannot be set to + * false again, as it is global to the process, as once we have been + * told that it is not safe to safe to write to stdout, we shouldn't + * go back as we don't know it was this context that set it that way. + */ void smbc_setOptionDebugToStderr(SMBCCTX *c, smbc_bool b) { |