<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">Gregory,<div><br></div><div>You are correct, it moved the problem.</div><div><br></div><div>I’ll study the code looking for loops, but...</div><div><br></div><div>one thing to note, there are two uses of the data for IO, and both would force evaluation of length/encode. One puts data in the GUI, one sends data by Ethernet. When only the GUI code is forcing IO, there is no hang. It is the Ethernet IO that causes the hang.</div><div><br></div><div>Because the GUI forcing does not hang, it leads me to believe there are no loops in the code.</div><div><br></div><div>Below is some description of overall application. -> means order of operation. T == Thread#. I note where the hang is, and what statement removal fixes it.</div><div><br></div><div>Mike</div><div><br></div><div>————</div><div><br></div><div><div><br></div><div>Main</div><div>T1 -> put TVar -> Start T2 -> Start T3</div><div><br></div><div>Async Module (TChan1/2/3 input/output wrapper around Eth based server in another process)</div><div>(This module takes a function that sends and recv data so that it is independent from communication mechanism)</div><div>(There are 2 output channels, one for response to commands in TCHan1, and one for a stream of telemetry)</div><div>T2 -> take TChan1 (config) -> </div><div>      Serialize ->                      (Hangs here)</div><div>      Send Eth</div><div><br></div><div>T2 -> Read Eth -> </div><div>      Deserialize -> </div><div>      put TChan2 (data1)</div><div>      put TChan3 (data2)</div><div><br></div><div>fetchTelemetryServer (Consumes from Async Module T2 and puts data in sequence for callback)</div><div>T3 -> tryTake MVar2 (server lock) -> </div><div>      take TChan3 (data) -> </div><div>      put TSequence (data) -> </div><div>      put MVar2 (server unlock)</div><div><br></div><div>showOptionDialogServer (Produces for Async Module T2)</div><div>(Changes the config in a dialog and send it to the server to modify telemetry definition)</div><div>wxH Menu Callback -> take MVar2 (server lock) -></div><div>                     take MVar1 (gui lock) -></div><div>                     take TVar (config) -></div><div>                     convert config to strings</div><div>                     display in dialog</div><div>                     pull strings from dialog</div><div>                     build modified config </div><div>                     put TVar (config) -></div><div>                     put TChan1 (config) ->                    (Remove and no hang)</div><div>                     put MVar1 (gui unlock) -> </div><div>                     put MVar2 (server lock)</div><div><br></div><div>performTelemetryServer</div><div>(Takes data from telemetry and prepares it for painting)</div><div>wxH Timer Callback -> take MVar1 (gui lock) -></div><div>                      take TSequence (data) -> </div><div>                      modify data</div><div>                      put Var (data2) -> </div><div>                      repaint -></div><div>                      put MVar1 (gui unlock)</div><div><br></div><div>onPaint</div><div>(Update the graphs in the GUI)</div><div>wx Paint Callback -> tryTake MVar1 (gui lock) -> </div><div>                     get Var (data2) -> </div><div>                     get TVar (config) -></div><div>                     draw on gui -> </div><div>                     put MVar1 (gui unlock)</div></div><div><br></div><div><br></div><div><br><div><div><div>On Nov 11, 2014, at 9:45 AM, Gregory Collins <<a href="mailto:greg@gregorycollins.net">greg@gregorycollins.net</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Nov 10, 2014 at 11:11 PM, Michael Jones <span dir="ltr"><<a href="mailto:mike@proclivis.com" target="_blank">mike@proclivis.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div id=":2e8" class="a3s" style="overflow:hidden">       ec <- return $ encode command<br>
       traceEventIO $ "sendCommand: encoded"<br>
       l <- ec `seq` return $ BSL.length ec</div></blockquote></div><br>Your encode function probably loops on some inputs. When you call "return $ foo", foo is not forced; that doesn't happen in your example until BSL.length forces its input. If I'm right, changing the first line to "return $! encode command" will move the hang to before the call to traceEventIO.</div><div class="gmail_extra"><br></div><div class="gmail_extra"><div>-- <br></div><div class="gmail_signature">Gregory Collins <<a href="mailto:greg@gregorycollins.net" target="_blank">greg@gregorycollins.net</a>></div>
</div></div>
</blockquote></div><br></div></div></body></html>