<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
Ok, so not *in* SNTP, but related to SNTP. After a minute's wait, I
saw a pair of records get "sent" to the v2 server. They never
arrived. After that, I tried the stop/start of the server, and
that's where it hung. Sounds like a missing mutex unlock
somewhere. What resources does starting the server make use of,
that might have also been used by SNTP?<br>
<br>
Greg<br>
<br>
<br>
<div class="moz-cite-prefix">Greg D. wrote:<br>
</div>
<blockquote type="cite"
cite="mid:4ba5da24-bbd4-5dd5-f849-f9b1028262d1@gmail.com">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
Ok, but I'm in ap+client mode, but don't have anything attaching
to the AP side of things.<br>
<br>
AP+Client, hotspot running. Boot. Client gets an IP address,
server connects, metrics sent.<br>
Some time later (minutes or so), the modem finally connects. Wifi
is still connected, and is still the primary interface, but the
server is no longer getting updates from module. server stop,
server start, hang. The last thing to the console this past time
before the phone client no longer got updates was "starting SNTP
client"<br>
<br>
Not 100% repeatable, but close to it. I think partly it depends
on the modem's luck in getting a good cell connection; it's kind
of iffy here. Or, is the deadlock in the SNTP client instead of
MDNS?<br>
<br>
Greg<br>
<br>
<br>
<div class="moz-cite-prefix">Mark Webb-Johnson wrote:<br>
</div>
<blockquote type="cite"
cite="mid:9EE9E046-CB36-421E-A9F6-635084D34396@webb-johnson.net">
<meta http-equiv="Content-Type" content="text/html;
charset=UTF-8">
It is a task mutex lock, so for mdns I have used them in ‘wait
forever’ mode.
<div class=""><br class="">
</div>
<div class="">This is for the code I just submitted a few
minutes ago.</div>
<div class=""><br class="">
</div>
<div class="">Looking at the esp-idf mdns code, I think using AP
or CLIENT modes would have been ok. Only one interface coming
up/down then. But for APCLIENT mode, or when switch between AP
and CLIENT modes, the fault will be triggered.</div>
<div class=""><br class="">
</div>
<div class="">Regards, Mark.<br class="">
<div><br class="">
<blockquote type="cite" class="">
<div class="">On 19 Mar 2018, at 11:40 AM, Greg D. <<a
href="mailto:gregd2350@gmail.com" class=""
moz-do-not-send="true">gregd2350@gmail.com</a>>
wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<meta http-equiv="Content-Type" content="text/html;
charset=UTF-8" class="">
<div text="#000000" bgcolor="#FFFFFF" class=""> I wonder
if those locks are the cause of the hangs I'm
getting. Do they have timers on them, or will they
wait forever?<br class="">
<br class="">
Greg<br class="">
<br class="">
<br class="">
<div class="moz-cite-prefix">Mark Webb-Johnson wrote:<br
class="">
</div>
<blockquote type="cite"
cite="mid:1358F917-D8B3-4554-BA9C-BB933C8FCB7C@webb-johnson.net"
class="">
<meta http-equiv="Content-Type" content="text/html;
charset=UTF-8" class="">
Messy. The issue is the restarting of mdns, coupled
with AP/STA coming up/down in different threads.
That could result in a mdns_free while another
mdns_free or mdns_init is in progress. The mdns
library is not thread safe. In particular, they
mutex protect some internal stuff but not all of
mdns_free or any of mdns_init.
<div class=""><br class="">
</div>
<div class="">I introduced an ovms_mutex library to
main. This contains some helpful wrapper functions
to make mutexes easy and safe to use:</div>
<div class=""><br class="">
</div>
<blockquote style="margin: 0 0 0 40px; border: none;
padding: 0px;" class="">
<div class="">class OvmsMutex</div>
</blockquote>
<blockquote style="margin: 0 0 0 40px; border: none;
padding: 0px;" class="">
<blockquote style="margin: 0 0 0 40px; border:
none; padding: 0px;" class="">
<div class="">Encapsulates a mutex.</div>
<div class="">Provides Lock() and Unlock()
functions to access it.</div>
</blockquote>
<br class="">
</blockquote>
<blockquote style="margin: 0 0 0 40px; border: none;
padding: 0px;" class="">class OvmsMutexLock</blockquote>
<blockquote style="margin: 0 0 0 40px; border: none;
padding: 0px;" class="">
<blockquote style="margin: 0 0 0 40px; border:
none; padding: 0px;" class="">Encapsulates a
mutex lock in a safer manner.</blockquote>
<blockquote style="margin: 0 0 0 40px; border:
none; padding: 0px;" class="">Constructor locks
it, and destructor unlocks it.</blockquote>
<blockquote style="margin: 0 0 0 40px; border:
none; padding: 0px;" class="">Using this is as
simple as creating a mutex for the object to be
protected, and then creating a
OvmsMutexLock(&mutex) over that. When the
OvmsMutexLock comes in scope, it will lock the
mutex, and when it goes out of scope it will
unlock it.</blockquote>
<br class="">
</blockquote>
<blockquote style="margin: 0 0 0 40px; border: none;
padding: 0px;" class="">I’ve done this in other
projects, with great success. Using OvmsMutexLock
objects means you never forget to unlock the mutex
(no matter how weird and wonderful your code paths
are).</blockquote>
<div class="">
<div class=""><br class="">
</div>
<div class="">I then used OvmsMutex and
OvmsMutexLock in ovms_mdns. The mdns stuff seems
ok for me now.</div>
<div class=""><br class="">
</div>
<div class="">Regards, Mark.<br class="">
<div class=""><br class="">
<blockquote type="cite" class="">
<div class="">On 19 Mar 2018, at 9:51 AM,
Mark Webb-Johnson <<a
href="mailto:mark@webb-johnson.net"
class="" moz-do-not-send="true">mark@webb-johnson.net</a>>
wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div class=""><br class="">
It seems that mdns_free is being called,
while mdns_free is running…<br class="">
<br class="">
It is trivial to fix it in the timer
deletion code, but that just delays the
problem until a bit later (the hostname
free).<br class="">
<br class="">
I am looking at this now.<br class="">
<br class="">
Regards, Mark.<br class="">
<br class="">
<blockquote type="cite" class="">On 19
Mar 2018, at 9:40 AM, Stephen Casner
<<a href="mailto:casner@acm.org"
class="" moz-do-not-send="true">casner@acm.org</a>>
wrote:<br class="">
<br class="">
On Sun, 18 Mar 2018, Michael Balzer
wrote:<br class="">
<br class="">
<blockquote type="cite" class="">From
a first look at the mdns code in
your backtrace, I would guess<br
class="">
that's a double free() for the
timer, it seems the timer_handle<br
class="">
never gets NULLed.<br class="">
</blockquote>
<br class="">
That may be a bug (deficiency) in the
esp-idf mDNS code.<br class="">
<br class="">
Perhaps I hit it because
OvmsMDNS::StopMDNS was called without<br
class="">
everything coming up correctly first?<br
class="">
<br class="">
-- Steve<br
class="">
_______________________________________________<br class="">
OvmsDev mailing list<br class="">
<a
href="mailto:OvmsDev@lists.teslaclub.hk"
class="" moz-do-not-send="true">OvmsDev@lists.teslaclub.hk</a><br
class="">
<a class="moz-txt-link-freetext"
href="http://lists.teslaclub.hk/mailman/listinfo/ovmsdev"
moz-do-not-send="true">http://lists.teslaclub.hk/mailman/listinfo/ovmsdev</a><br
class="">
</blockquote>
<br class="">
_______________________________________________<br class="">
OvmsDev mailing list<br class="">
<a
href="mailto:OvmsDev@lists.teslaclub.hk"
class="" moz-do-not-send="true">OvmsDev@lists.teslaclub.hk</a><br
class="">
<a class="moz-txt-link-freetext"
href="http://lists.teslaclub.hk/mailman/listinfo/ovmsdev"
moz-do-not-send="true">http://lists.teslaclub.hk/mailman/listinfo/ovmsdev</a><br
class="">
</div>
</div>
</blockquote>
</div>
<br class="">
</div>
</div>
<br class="">
<fieldset class="mimeAttachmentHeader"></fieldset>
<br class="">
<pre class="" wrap="">_______________________________________________
OvmsDev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:OvmsDev@lists.teslaclub.hk" moz-do-not-send="true">OvmsDev@lists.teslaclub.hk</a>
<a class="moz-txt-link-freetext" href="http://lists.teslaclub.hk/mailman/listinfo/ovmsdev" moz-do-not-send="true">http://lists.teslaclub.hk/mailman/listinfo/ovmsdev</a>
</pre>
</blockquote>
<br class="">
</div>
_______________________________________________<br
class="">
OvmsDev mailing list<br class="">
<a href="mailto:OvmsDev@lists.teslaclub.hk" class=""
moz-do-not-send="true">OvmsDev@lists.teslaclub.hk</a><br
class="">
<a class="moz-txt-link-freetext"
href="http://lists.teslaclub.hk/mailman/listinfo/ovmsdev"
moz-do-not-send="true">http://lists.teslaclub.hk/mailman/listinfo/ovmsdev</a><br
class="">
</div>
</blockquote>
</div>
<br class="">
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
OvmsDev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:OvmsDev@lists.teslaclub.hk" moz-do-not-send="true">OvmsDev@lists.teslaclub.hk</a>
<a class="moz-txt-link-freetext" href="http://lists.teslaclub.hk/mailman/listinfo/ovmsdev" moz-do-not-send="true">http://lists.teslaclub.hk/mailman/listinfo/ovmsdev</a>
</pre>
</blockquote>
<br>
</blockquote>
<br>
</body>
</html>