pastebin - collaborative debugging tool
eckelmann.kpaste.net RSS


quantron libvt defer RT signals bevor trying to obtain the QMutex
Posted by Anonymous on Thu 17th Jan 2019 10:06
raw | new post

  1. diff --git a/ptxdist/local_src/libvt/ECom/ecbinterface.cpp b/ptxdist/local_src/libvt/ECom/ecbinterface.cpp
  2. index cd3fd19..3b23009 100644
  3. --- a/ptxdist/local_src/libvt/ECom/ecbinterface.cpp
  4. +++ b/ptxdist/local_src/libvt/ECom/ecbinterface.cpp
  5. @@ -36,6 +36,9 @@
  6.  #include <QReadWriteLock>
  7.  #include <QFlags>
  8.  
  9. +#include <signal.h>
  10. +#include <pthread.h>
  11. +
  12.  /************************************************************************/
  13.  /*    here: Defines                                                     */
  14.  /************************************************************************/
  15. @@ -118,10 +121,35 @@ char* _pEndBuffer=(_RxBuffer.data() + RXBUFFER_SIZE_E);
  16.  bool _full(false);
  17.  QMutex __Lock;
  18.  
  19. +
  20. +#if 1
  21. +
  22. +static pthread_once_t  init_sigrtmask_once = PTHREAD_ONCE_INIT;
  23. +static sigset_t                block_sigrtset;
  24. +
  25. +static void initblocksigmask(void)
  26. +{
  27. +       int i;
  28. +
  29. +       (void)sigemptyset(&block_sigrtset);
  30. +
  31. +       /* fixme: We should use getconf RTSIG_MAX */
  32. +       for (i=0 ; i < 32 ; i++)
  33. +               (void)sigaddset(&block_sigrtset, SIGRTMIN+i);
  34. +}
  35. +
  36. +#define __Lock_LOCK    { pthread_once(&init_sigrtmask_once, initblocksigmask); pthread_sigmask(SIG_BLOCK, &block_sigrtset, NULL); __Lock.lock(); }
  37. +#define __Lock_UNLOCK  { __Lock.unlock(); pthread_sigmask(SIG_UNBLOCK, &block_sigrtset, NULL); }
  38. +
  39. +#else
  40. +#define __Lock_LOCK    __Lock.lock()
  41. +#define __Lock_UNLOCK  __Lock.unlock()
  42. +#endif
  43. +
  44.  int data_in( char* data, int size){
  45.     int iRet(-1);
  46.  
  47. -   __Lock.lock();  
  48. +   __Lock_LOCK;
  49.     if ( _full == true ) {
  50.        // Spezielles Event versenden an GUI-Thread, damit Buffer abgearbeitet wird/gelöscht wird.
  51.        postECbEvent( ECB_FULLEVENT_E );
  52. @@ -173,7 +201,7 @@ int data_in( char* data, int size){
  53.           _full = true;
  54.        }
  55.     }
  56. -   __Lock.unlock();
  57. +   __Lock_UNLOCK;
  58.  
  59.     if ( iRet == size ) {
  60.        // Spezielles Event versenden an GUI-Thread, damit Buffer abgearbeitet wird.
  61. @@ -192,7 +220,7 @@ int data_check(void){
  62.     WORD_UI length;
  63.  
  64.     length.word = -1;
  65. -   __Lock.lock();
  66. +   __Lock_LOCK;
  67.  
  68.  
  69.     if ( ( _pReadBuffer != _pWriteBuffer ) || (_full == true) ) {
  70. @@ -228,13 +256,13 @@ int data_check(void){
  71.     else {
  72.        length.word = 0;
  73.     }
  74. -   __Lock.unlock();
  75. +   __Lock_UNLOCK;
  76.  
  77.     return length.word;
  78.  }
  79.  
  80.  void data_clear(void){
  81. -   __Lock.lock();
  82. +   __Lock_LOCK;
  83.  
  84.     // Variablen/Buffer zurücksetzen
  85.     _pReadBuffer=_RxBuffer.data();
  86. @@ -242,7 +270,7 @@ void data_clear(void){
  87.     _pEndBuffer=(_RxBuffer.data() + RXBUFFER_SIZE_E);
  88.     _full = false;
  89.  
  90. -   __Lock.unlock();
  91. +   __Lock_UNLOCK;
  92.  }
  93.  
  94.  int data_out( char* data, int size){
  95. @@ -250,7 +278,7 @@ int data_out( char* data, int size){
  96.     WORD_UI length;
  97.     int iRet = 0;
  98.  
  99. -   __Lock.lock();
  100. +   __Lock_LOCK;
  101.     length.word = -1;
  102.  
  103.     if ( (_pReadBuffer != _pWriteBuffer) || (_full==true) ) {
  104. @@ -304,7 +332,7 @@ int data_out( char* data, int size){
  105.           _pReadBuffer = _RxBuffer.data();
  106.        }
  107.     }
  108. -   __Lock.unlock();
  109. +   __Lock_UNLOCK;
  110.  
  111.     if ( (iRet < 0) || (iRet != size) ) {
  112.        // Beim Schreiben kam es zu einem Fehler

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with {%HIGHLIGHT}





All content is user-submitted.
The administrators of this site (kpaste.net) are not responsible for their content.
Abuse reports should be emailed to us at