jack2: question about possible race condition
"Miartus, Adam (Arion Recruitment; ADITG/ESM)" <[email protected]> Mon, 26 Aug 2019 15:15:36 +0000
| Newsgroups | gmane.comp.audio.jackit |
|---|---|
| Message-ID | <[email protected]> |
--===============4354886767496964074==
Content-Language: en-US
Content-Type: multipart/alternative;
boundary="_000_B174E9FCEE9A8C46B11E4DF2E32993627DBD72HI2EXCH01aditjvco_"
--_000_B174E9FCEE9A8C46B11E4DF2E32993627DBD72HI2EXCH01aditjvco_
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
Dear Jack2 Maintainers,
I have a question about JackAudioDriver.cpp. It seems to me like there coul=
d be a possible race condition in JackAudioDriver::ProcessGraphSyncMaster()=
, where the driver would do read and write on a slave device without waitin=
g for graph execution end.
Below is the proposed "fix", or what I would expect is correct, am I readin=
g something wrong in the code? What do you guys think?
diff --git a/common/JackAudioDriver.cpp b/common/JackAudioDriver.cpp
index ef7c683..9172fe8 100644
--- a/common/JackAudioDriver.cpp
+++ b/common/JackAudioDriver.cpp
@@ -327,16 +327,12 @@ void JackAudioDriver::ProcessGraphSyncMaster()
// fBeginDateUst is set in the "low level" layer, fEndDateUst is from =
previous cycle
if (fEngine->Process(fBeginDateUst, fEndDateUst)) {
- if (ResumeRefNum() < 0) {
- jack_error("JackAudioDriver::ProcessGraphSyncMaster: ResumeRef=
Num error");
- }
-
if (ProcessReadSlaves() < 0) {
jack_error("JackAudioDriver::ProcessGraphSync: ProcessReadSlav=
es error, engine may now behave abnormally!!");
}
- if (ProcessWriteSlaves() < 0) {
- jack_error("JackAudioDriver::ProcessGraphSync: ProcessWriteSla=
ves error, engine may now behave abnormally!!");
+ if (ResumeRefNum() < 0) {
+ jack_error("JackAudioDriver::ProcessGraphSyncMaster: ResumeRef=
Num error");
}
// Waits for graph execution end
@@ -344,6 +340,10 @@ void JackAudioDriver::ProcessGraphSyncMaster()
jack_error("JackAudioDriver::ProcessGraphSync: SuspendRefNum e=
rror, engine may now behave abnormally!!");
}
+ if (ProcessWriteSlaves() < 0) {
+ jack_error("JackAudioDriver::ProcessGraphSync: ProcessWriteSla=
ves error, engine may now behave abnormally!!");
+ }
+
} else { // Graph not finished: do not activate it
jack_error("JackAudioDriver::ProcessGraphSync: Process error");
}
--
2.7.4
Best regards
Adam Miartus
Engineering Software Multimedia (ADITG/ESM)
Tel. +49 5121 49 6973
--_000_B174E9FCEE9A8C46B11E4DF2E32993627DBD72HI2EXCH01aditjvco_
Content-Type: text/html; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
<html xmlns:v=3D"urn:schemas-microsoft-com:vml" xmlns:o=3D"urn:schemas-micr=
osoft-com:office:office" xmlns:w=3D"urn:schemas-microsoft-com:office:word" =
xmlns:m=3D"http://schemas.microsoft.com/office/2004/12/omml" xmlns=3D"http:=
//www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3Dus-ascii"=
>
<meta name=3D"Generator" content=3D"Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:"Yu Gothic";
panose-1:2 11 4 0 0 0 0 0 0 0;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:"\@Yu Gothic";
panose-1:2 11 4 0 0 0 0 0 0 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#0563C1;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:#954F72;
text-decoration:underline;}
span.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Calibri",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri",sans-serif;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:70.85pt 70.85pt 2.0cm 70.85pt;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext=3D"edit" spidmax=3D"1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext=3D"edit">
<o:idmap v:ext=3D"edit" data=3D"1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang=3D"DE" link=3D"#0563C1" vlink=3D"#954F72">
<div class=3D"WordSection1">
<p class=3D"MsoNormal"><span lang=3D"EN-GB">Dear Jack2 Maintainers,<o:p></o=
:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"EN-GB"><o:p> </o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"EN-GB">I have a question about JackAud=
ioDriver.cpp. It seems to me like there could be a possible race condition =
in JackAudioDriver::ProcessGraphSyncMaster(), where the driver would do rea=
d and write on a slave device without
waiting for graph execution end.<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"EN-GB"><o:p> </o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"EN-GB">Below is the proposed “fi=
x”, or what I would expect is correct, am I reading something wrong i=
n the code? What do you guys think?<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"EN-GB"><o:p> </o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"EN-GB">diff --git a/common/JackAudioDr=
iver.cpp b/common/JackAudioDriver.cpp<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"EN-GB">index ef7c683..9172fe8 100644<o=
:p></o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"EN-GB">--- a/common/JackAudioDriver.cp=
p<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"EN-GB">+++ b/common/JackAu=
dioDriver.cpp<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"EN-GB">@@ -327,16 +327,12 @@ void =
JackAudioDriver::ProcessGraphSyncMaster()<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"EN-GB"> // fBe=
ginDateUst is set in the "low level" layer, fEndDateUst is from p=
revious cycle<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"EN-GB"> if (fE=
ngine->Process(fBeginDateUst, fEndDateUst)) {<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"EN-GB"><o:p></o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"EN-GB">- =
if (ResumeRefNum() < 0) {<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"EN-GB">- =
jack_error("JackAudioDriver::Proc=
essGraphSyncMaster: ResumeRefNum error");<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"EN-GB">- =
}<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"EN-GB">-<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"EN-GB"> &=
nbsp; if (ProcessReadSlaves() < 0) {<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"EN-GB"> &=
nbsp; jack_error("JackAudioDriver:=
:ProcessGraphSync: ProcessReadSlaves error, engine may now behave abnormall=
y!!");<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"EN-GB"> &=
nbsp; }<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"EN-GB"><o:p></o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"EN-GB">- =
if (ProcessWriteSlaves() < 0) {<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"EN-GB">- =
jack_error("JackAudioDriver::Proc=
essGraphSync: ProcessWriteSlaves error, engine may now behave abnormally!!&=
quot;);<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"EN-GB">+ &n=
bsp; if (ResumeRefNum() < 0) {<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"EN-GB">+ &n=
bsp; jack_error("JackAudioDriver::=
ProcessGraphSyncMaster: ResumeRefNum error");<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"EN-GB"> &=
nbsp; }<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"EN-GB"><o:p></o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"EN-GB"> &=
nbsp; // Waits for graph execution end<o:p></o:p></span></=
p>
<p class=3D"MsoNormal"><span lang=3D"EN-GB">@@ -344,6 +340,10 @@ void J=
ackAudioDriver::ProcessGraphSyncMaster()<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"EN-GB"> &=
nbsp; jack_error("JackAudioDriver:=
:ProcessGraphSync: SuspendRefNum error, engine may now behave abnormally!!&=
quot;);<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"EN-GB"> &=
nbsp; }<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"EN-GB"><o:p></o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"EN-GB">+ &n=
bsp; if (ProcessWriteSlaves() < 0) {<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"EN-GB">+ &n=
bsp; jack_error("JackAudioDriver::=
ProcessGraphSync: ProcessWriteSlaves error, engine may now behave abnormall=
y!!");<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"EN-GB">+ &n=
bsp; }<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"EN-GB">+<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"EN-GB"> } else=
{ // Graph not finished: do not activate it<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"EN-GB"> &=
nbsp; jack_error("JackAudioDriver::ProcessGraphSync: Proce=
ss error");<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"EN-GB"> }<o:p>=
</o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"EN-GB">-- <o:p></o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"EN-GB">2.7.4<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"EN-GB"><o:p> </o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"EN-US" style=3D"font-size:10.0pt;font-=
family:"Arial",sans-serif">Best regards</span><span lang=3D"EN-US=
"><br>
</span><span lang=3D"EN-US" style=3D"font-family:"Arial",sans-ser=
if"><br>
</span><b><span lang=3D"EN-US" style=3D"font-size:10.0pt;font-family:"=
Arial",sans-serif">Adam Miartus</span></b><span lang=3D"EN-US"><br>
</span><span lang=3D"EN-US" style=3D"font-size:10.0pt;font-family:"Ari=
al",sans-serif">Engineering Software Multimedia (ADITG/ESM)</span><spa=
n lang=3D"EN-US"><br>
</span><span lang=3D"EN-US" style=3D"font-family:"Arial",sans-ser=
if"><br>
</span><span lang=3D"EN-US" style=3D"font-size:10.0pt;font-family:"Ari=
al",sans-serif">Tel.
</span><span style=3D"font-size:10.0pt;font-family:"Arial",sans-s=
erif">+49 5121 49 6973</span><o:p></o:p></p>
<p class=3D"MsoNormal"><span lang=3D"EN-GB"><o:p> </o:p></span></p>
</div>
</body>
</html>
--_000_B174E9FCEE9A8C46B11E4DF2E32993627DBD72HI2EXCH01aditjvco_--
--===============4354886767496964074==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
Jack-Devel mailing list
[email protected]
http://lists.jackaudio.org/listinfo.cgi/jack-devel-jackaudio.org
--===============4354886767496964074==--