Update #2843. --- cpukit/libnetworking/lib/syslog.c | 30 ++++++------------------------ 1 file changed, 6 insertions(+), 24 deletions(-)
diff --git a/cpukit/libnetworking/lib/syslog.c b/cpukit/libnetworking/lib/syslog.c index 066d7ab0e4..8f0cbc8885 100644 --- a/cpukit/libnetworking/lib/syslog.c +++ b/cpukit/libnetworking/lib/syslog.c @@ -7,6 +7,7 @@ #endif #include <rtems.h> +#include <rtems/thread.h> #include <stdio.h> #include <stdarg.h> #include <errno.h> @@ -24,7 +25,8 @@ static int LogFacility = LOG_USER; static int LogMask = 0xff; static int LogFd = -1; -static rtems_id LogSemaphore; +static rtems_recursive_mutex LogSemaphore = + RTEMS_RECURSIVE_MUTEX_INITIALIZER("syslog"); extern struct in_addr rtems_bsdnet_log_host_address; #define SYSLOG_PORT 514 @@ -89,8 +91,7 @@ vsyslog (int pri, const char *fmt, va_list ap) */ sent = 0; if ((rtems_bsdnet_log_host_address.s_addr != INADDR_ANY) - && (LogFd >= 0) - && (rtems_semaphore_obtain (LogSemaphore, RTEMS_WAIT, RTEMS_NO_TIMEOUT) == RTEMS_SUCCESSFUL)) { + && (LogFd >= 0)) { /* * Set the destination address/port */ @@ -100,12 +101,13 @@ vsyslog (int pri, const char *fmt, va_list ap) farAddress.sin_addr = rtems_bsdnet_log_host_address; memset (farAddress.sin_zero, '\0', sizeof farAddress.sin_zero); + rtems_recursive_mutex_lock (&LogSemaphore); /* * Send the message */ if (sendto (LogFd, cbuf, cnt, 0, (struct sockaddr *)&farAddress, sizeof farAddress) >= 0) sent = 1; - rtems_semaphore_release (LogSemaphore); + rtems_recursive_mutex_unlock (&LogSemaphore); } if (!sent && (LogStatus & LOG_CONS) && !(LogStatus & LOG_PERROR)) printf ("%s\n", msgp); @@ -114,7 +116,6 @@ vsyslog (int pri, const char *fmt, va_list ap) void openlog (const char *ident, int logstat, int logfac) { - rtems_status_code sc; struct sockaddr_in myAddress; if (ident != NULL) @@ -144,24 +145,6 @@ openlog (const char *ident, int logstat, int logfac) printf ("Can't bind syslog socket: %d\n", errno); return; } - - /* - * Create the mutex - */ - sc = rtems_semaphore_create (rtems_build_name('s', 'L', 'o', 'g'), - 1, - RTEMS_PRIORITY | - RTEMS_BINARY_SEMAPHORE | - RTEMS_INHERIT_PRIORITY | - RTEMS_NO_PRIORITY_CEILING | - RTEMS_LOCAL, - 0, - &LogSemaphore); - if (sc != RTEMS_SUCCESSFUL) { - printf ("Can't create syslog semaphore: %d\n", sc); - close (LogFd); - LogFd = -1; - } } void @@ -170,7 +153,6 @@ closelog(void) if (LogFd >= 0) { close (LogFd); LogFd = -1; - rtems_semaphore_delete (LogSemaphore); } } -- 2.12.3 _______________________________________________ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel