Debian Codegraph @

debian/patches/fix-locking

raw symbols SCIP
1 Description: Fix locking
2 Author: Simon Richter <[email protected]>
3 Last-Update: 2023-12-16
4
5 --- librevisa-0.0.20130812.orig/src/messagepump.cpp
6 +++ librevisa-0.0.20130812/src/messagepump.cpp
7 @@ -32,11 +32,20 @@
8 namespace librevisa {
9
10 messagepump::messagepump() throw() :
11 + keep_running(true),
12 worker(*this)
13 {
14 return;
15 }
16
17 +messagepump::~messagepump() throw()
18 +{
19 + keep_running = false;
20 + lock l(cs);
21 + cv.signal();
22 + worker.kill(SIGUSR1);
23 +}
24 +
25 void messagepump::register_watch(watch &w)
26 {
27 worker.start();
28 @@ -120,7 +129,7 @@ void messagepump::run()
29 timeval now;
30 ::gettimeofday(&now, 0);
31
32 - for(;;)
33 + while(keep_running)
34 {
35 timeout *expired = 0;
36 bool have_timeout = false;
37 @@ -212,6 +221,9 @@ void messagepump::run()
38 next_as_ts.tv_nsec = next.tv_usec * 1000;
39 }
40
41 + if(maxfd == -1 && !have_timeout)
42 + break;
43 +
44 int rc = ::pselect(maxfd + 1, &readfds, &writefds, &exceptfds, have_timeout? &next_as_ts : 0, &mask);
45 if(rc == -1)
46 {
47 --- librevisa-0.0.20130812.orig/src/messagepump.h
48 +++ librevisa-0.0.20130812/src/messagepump.h
49 @@ -33,6 +33,7 @@ class messagepump :
50 {
51 public:
52 messagepump() throw();
53 + ~messagepump() throw();
54
55 // thread::runnable
56 virtual void init();
57 @@ -84,6 +85,8 @@ public:
58 void update_timeout(timeout &, timeval const *);
59
60 private:
61 + bool keep_running;
62 +
63 typedef intrusive_list<watch> watch_list;
64 typedef watch_list::iterator watch_iterator;
65 watch_list watches;
66 --- librevisa-0.0.20130812.orig/src/thread_pthread.h
67 +++ librevisa-0.0.20130812/src/thread_pthread.h
68 @@ -40,6 +40,12 @@ public:
69 };
70
71 thread(runnable &r) : sui(r) { }
72 + ~thread() throw()
73 + {
74 + if(!sui.running)
75 + return;
76 + pthread_join(handle, 0);
77 + }
78
79 void start()
80 {
81 @@ -54,6 +60,9 @@ public:
82
83 void kill(int sig)
84 {
85 + if(!sui.running)
86 + return;
87 +
88 pthread_kill(handle, sig);
89 }
90