View Issue Details

IDProjectCategoryView StatusLast Update
0002786OpenFOAMPatchpublic2017-12-10 11:12
ReporterwyldckatAssigned Tohenry 
PrioritylowSeverityminorReproducibilityN/A
Status resolvedResolutionfixed 
Product Version5.x 
Fixed in Version5.x 
Summary0002786: POSIX.C: minor textual inconsistencies on the threading functions near the end
DescriptionWhile going through the thread management functions in the file 'src/OSspecific/POSIX/POSIX.C' (had to re-implement them on MSWindows), I stumbled upon a typo in the 'joinThread' function, which was referring to 'freeThread' in the debug and error messages, likely due to a quick copy-paste-adapt during development.

Later on I noticed that using 'FUNCTION_NAME' is the default convention in all of the other functions on this file, whereas these thread functions were the only ones not abiding to this convention.

Therefore, please find in attachment the following files, which patches these two issues, where either file will work for patching this in both OpenFOAM 5.x and dev:

  - proposition_v1.patch - patch file that shows the changes.
  - proposition_v1.tar.gz - provides the file 'src/OSspecific/POSIX/POSIX.C' with the patch applied.
TagsNo tags attached.

Activities

wyldckat

2017-12-09 19:14

updater  

proposition_v1.patch (3,333 bytes)
diff --git a/src/OSspecific/POSIX/POSIX.C b/src/OSspecific/POSIX/POSIX.C
index da911a2..33ecaad 100644
--- a/src/OSspecific/POSIX/POSIX.C
+++ b/src/OSspecific/POSIX/POSIX.C
@@ -1387,7 +1387,7 @@ Foam::label Foam::allocateThread()
         {
             if (POSIX::debug)
             {
-                Pout<< "allocateThread : reusing index:" << i << endl;
+                Pout<< FUNCTION_NAME << " : reusing index:" << i << endl;
             }
             // Reuse entry
             threads_[i].reset(new pthread_t());
@@ -1398,7 +1398,7 @@ Foam::label Foam::allocateThread()
     label index = threads_.size();
     if (POSIX::debug)
     {
-        Pout<< "allocateThread : new index:" << index << endl;
+        Pout<< FUNCTION_NAME << " : new index:" << index << endl;
     }
     threads_.append(autoPtr<pthread_t>(new pthread_t()));
 
@@ -1415,7 +1415,7 @@ void Foam::createThread
 {
     if (POSIX::debug)
     {
-        Pout<< "createThread : index:" << index << endl;
+        Pout<< FUNCTION_NAME << " : index:" << index << endl;
     }
     if (pthread_create(&threads_[index](), nullptr, start_routine, arg))
     {
@@ -1429,11 +1429,11 @@ void Foam::joinThread(const label index)
 {
     if (POSIX::debug)
     {
-        Pout<< "freeThread : join:" << index << endl;
+        Pout<< FUNCTION_NAME << " : index:" << index << endl;
     }
     if (pthread_join(threads_[index](), nullptr))
     {
-        FatalErrorInFunction << "Failed freeing thread " << index
+        FatalErrorInFunction << "Failed joining thread " << index
             << exit(FatalError);
     }
 }
@@ -1443,7 +1443,7 @@ void Foam::freeThread(const label index)
 {
     if (POSIX::debug)
     {
-        Pout<< "freeThread : index:" << index << endl;
+        Pout<< FUNCTION_NAME << " : index:" << index << endl;
     }
     threads_[index].clear();
 }
@@ -1457,7 +1457,7 @@ Foam::label Foam::allocateMutex()
         {
             if (POSIX::debug)
             {
-                Pout<< "allocateMutex : reusing index:" << i << endl;
+                Pout<< FUNCTION_NAME << " : reusing index:" << i << endl;
             }
             // Reuse entry
             mutexes_[i].reset(new pthread_mutex_t());
@@ -1469,7 +1469,7 @@ Foam::label Foam::allocateMutex()
 
     if (POSIX::debug)
     {
-        Pout<< "allocateMutex : new index:" << index << endl;
+        Pout<< FUNCTION_NAME << " : new index:" << index << endl;
     }
     mutexes_.append(autoPtr<pthread_mutex_t>(new pthread_mutex_t()));
     return index;
@@ -1480,7 +1480,7 @@ void Foam::lockMutex(const label index)
 {
     if (POSIX::debug)
     {
-        Pout<< "lockMutex : index:" << index << endl;
+        Pout<< FUNCTION_NAME << " : index:" << index << endl;
     }
     if (pthread_mutex_lock(&mutexes_[index]()))
     {
@@ -1494,7 +1494,7 @@ void Foam::unlockMutex(const label index)
 {
     if (POSIX::debug)
     {
-        Pout<< "unlockMutex : index:" << index << endl;
+        Pout<< FUNCTION_NAME << " : index:" << index << endl;
     }
     if (pthread_mutex_unlock(&mutexes_[index]()))
     {
@@ -1508,7 +1508,7 @@ void Foam::freeMutex(const label index)
 {
     if (POSIX::debug)
     {
-        Pout<< "freeMutex : index:" << index << endl;
+        Pout<< FUNCTION_NAME << " : index:" << index << endl;
     }
     mutexes_[index].clear();
 }
proposition_v1.patch (3,333 bytes)

wyldckat

2017-12-09 19:14

updater  

proposition_v1.tar.gz (7,141 bytes)

wyldckat

2017-12-09 19:15

updater  

proposition_v1.tar-2.gz (7,141 bytes)

henry

2017-12-10 11:11

manager   ~0009144

Last edited: 2017-12-10 11:12

View 2 revisions

Thanks Bruno

Resolved in OpenFOAM-5.x by commit b486157a616985e338cbf466256f5beb220a2001

Resolved in OpenFOAM-dev by commit dfd7d0b5b47fccf2d010211ca6560c865e6d389b

Issue History

Date Modified Username Field Change
2017-12-09 19:14 wyldckat New Issue
2017-12-09 19:14 wyldckat Status new => assigned
2017-12-09 19:14 wyldckat Assigned To => henry
2017-12-09 19:14 wyldckat File Added: proposition_v1.patch
2017-12-09 19:14 wyldckat File Added: proposition_v1.tar.gz
2017-12-09 19:15 wyldckat File Added: proposition_v1.tar-2.gz
2017-12-10 11:11 henry Status assigned => resolved
2017-12-10 11:11 henry Resolution open => fixed
2017-12-10 11:11 henry Fixed in Version => 5.x
2017-12-10 11:11 henry Note Added: 0009144
2017-12-10 11:12 henry Note Edited: 0009144 View Revisions