You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by "rm5248 (via GitHub)" <gi...@apache.org> on 2023/02/04 15:27:08 UTC

[GitHub] [logging-log4cxx] rm5248 commented on a diff in pull request #190: Prevent priority inversions when logging from multiple threads

rm5248 commented on code in PR #190:
URL: https://github.com/apache/logging-log4cxx/pull/190#discussion_r1096549718


##########
src/main/include/log4cxx/private/mutex.h:
##########
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef LOG4CXX_PRIV_MUTEX_HDR_
+#define LOG4CXX_PRIV_MUTEX_HDR_
+#include <mutex>
+#include <log4cxx/helpers/loglog.h>
+#include <log4cxx/helpers/stringhelper.h>
+#if !defined(LOG4CXX)
+	#define LOG4CXX 1
+#endif
+#include <log4cxx/private/log4cxx_private.h>
+
+namespace log4cxx
+{
+
+using AppenderMutexType = std::mutex;
+using AppenderScopeGuard = std::lock_guard<AppenderMutexType>;
+using AppenderScopedLock = std::unique_lock<AppenderMutexType>;
+
+// Change mutex attributes to avoid priority inversion problems
+template <class M>
+	void
+EnablePriorityInheritance(M& m, helpers::Pool& p)

Review Comment:
   It looks like this doesn't do anything at the moment.  From the documentation that I've been reading, it seems that you can only set the mutexattr when creating the mutex in the first place(`pthread_mutex_init`).



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org