sched_file_channel(): Comments say that we need to lock the scheduler, but we do not.

This commit is contained in:
Gregory Nutt 2016-06-21 16:39:28 -06:00
parent 0150991503
commit cb55c06153

View File

@ -40,6 +40,7 @@
#include <nuttx/config.h> #include <nuttx/config.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sched.h>
#include <fcntl.h> #include <fcntl.h>
#include <nuttx/syslog/syslog.h> #include <nuttx/syslog/syslog.h>
@ -143,14 +144,15 @@ int syslog_file_channel(FAR const char *devpath)
* after the default channel has been selected. * after the default channel has been selected.
* *
* We disable pre-emption only so that we are not suspended and a lot of * We disable pre-emption only so that we are not suspended and a lot of
* important debug output is lost. * important debug output is lost while we futz with the channels.
*/ */
sched_lock();
saved_channel = g_syslog_channel; saved_channel = g_syslog_channel;
ret = syslog_channel(&g_default_syslog_channel); ret = syslog_channel(&g_default_syslog_channel);
if (ret < 0) if (ret < 0)
{ {
return ret; goto errout_with_lock;
} }
/* Uninitialize any driver interface that may have been in place */ /* Uninitialize any driver interface that may have been in place */
@ -163,7 +165,7 @@ int syslog_file_channel(FAR const char *devpath)
*/ */
(void)syslog_channel(saved_channel); (void)syslog_channel(saved_channel);
return ret; goto errout_with_lock;
} }
/* Then initialize the file interface */ /* Then initialize the file interface */
@ -171,16 +173,22 @@ int syslog_file_channel(FAR const char *devpath)
ret = syslog_dev_initialize(devpath, OPEN_FLAGS, OPEN_MODE); ret = syslog_dev_initialize(devpath, OPEN_FLAGS, OPEN_MODE);
if (ret < 0) if (ret < 0)
{ {
/* We should still be able to back-up an re-initialized everything */ /* We should still be able to back-up and re-initialized everything */
(void)syslog_initialize(SYSLOG_INIT_EARLY); (void)syslog_initialize(SYSLOG_INIT_EARLY);
(void)syslog_initialize(SYSLOG_INIT_LATE); (void)syslog_initialize(SYSLOG_INIT_LATE);
return ret; goto errout_with_lock;
} }
/* Use the file as the SYSLOG channel */ /* Use the file as the SYSLOG channel. If this fails we are pretty much
* screwed.
*/
return syslog_channel(&g_syslog_file_channel); ret = syslog_channel(&g_syslog_file_channel);
errout_with_lock:
sched_unlock();
return ret;
} }
#endif /* CONFIG_SYSLOG_FILE */ #endif /* CONFIG_SYSLOG_FILE */