[ST Edge] - Driver Lifecycle Inquiries

@nayelyz I can give you just a little bit more insight relating to the driver re-install issue noted above:

I’m working on a driver now that has a decent load on communications sockets since it’s monitoring the multicast address. And I’ve gotten to a point of being able to pretty regularly reproduce the problem.

  1. If I try to use the info_changed lifecycle to shut everything down before a driver re-install, this can result in the driver re-install hanging, as described in my earlier post. The things I am shutting down are: all channel handlers, sockets, and outstanding timers. Note however, that as I’m shutting these things down, my channel handlers are fairly busy receiving LAN traffic being received at the same time (which I have no control over).

  2. If I do NOT try to shut everything down, and instead just let it the channel handler activity continue, a driver re-install starts, but immediately crashes with the known cosock error:

2021-11-15T04:57:30.758361741+00:00 DEBUG LAN Device Monitor  **** Driver Script Start ****
2021-11-15T04:57:30.761512033+00:00 INFO LAN Device Monitor  LAN Device Monitor Driver v1 started
2021-11-15T04:57:30.781991241+00:00 TRACE LAN Device Monitor  Received event with handler environment_info
2021-11-15T04:57:30.791623241+00:00 TRACE LAN Device Monitor  Found DeviceLifecycleDispatcher handler in landevmonDriver
2021-11-15T04:57:30.794762574+00:00 DEBUG LAN Device Monitor  INIT handler for LAN Device Monitor
2021-11-15T04:57:30.798905741+00:00 INFO LAN Device Monitor  <Device: 4740ed93-8747-4f9f-bfa8-7fb8bcecf205 (LAN Device Monitor)> emitting event: {"attribute_id":"switch","state":{"value":"Monitoring On"},"component_id":"main","capability_id":"partyvoice23922.moncontrol"}
2021-11-15T04:57:30.809347616+00:00 WARN LAN Device Monitor  	Scheduling re-discover routine
2021-11-15T04:57:30.816358533+00:00 DEBUG LAN Device Monitor  LAN Device Monitor device thread event handled
2021-11-15T04:57:30.819758908+00:00 TRACE LAN Device Monitor  Received event with handler environment_info
2021-11-15T04:57:30.822972491+00:00 DEBUG LAN Device Monitor  Z-Wave hub node ID environment changed.
2021-11-15T04:57:30.831954783+00:00 TRACE LAN Device Monitor  Received event with handler _resync
2021-11-15T04:57:30.834891449+00:00 TRACE LAN Device Monitor  Received event with handler _resync
2021-11-15T04:57:30.839297199+00:00 FATAL LAN Device Monitor  Lua: runtime error: [string "cosock"]:296: cosock tried to call socket.select with no sockets and no timeout. this is a bug, please report it
stack traceback:
	[C]: in function 'error'
	[string "cosock"]:296: in field 'run'
	[string "st.driver"]:743: in method 'run'
	[string "init.lua"]:594: in main chunk

When that cosock error happens, the driver install keeps retrying indefinitely and just keeps getting the cosock error. At other times I’ve gotten this error sometimes the install retry is finally successful after several attempts, but here, it just repeats forever.

So my guess is that these issues are somehow related and may in part be caused by having busy sockets at the time of a driver reinstall. Apparently the sockets and channel handlers with in-progress LAN traffic are not getting properly shutdown and reset.

If the team has any suggestions as to the best way to quiesce a LAN driver to mitigate these kinds of issues, I’d love to hear them.

Anyway I hope this at least helps shine a bit more light on this issue.

1 Like