Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Select unreliably unblocks when closing sockets on linux #168

Closed
ghost opened this issue Jul 13, 2015 · 0 comments
Closed

Select unreliably unblocks when closing sockets on linux #168

ghost opened this issue Jul 13, 2015 · 0 comments
Labels
Milestone

Comments

@ghost
Copy link

ghost commented Jul 13, 2015

From Kyle---

This isn’t a very big deal, but something to perhaps clean up in the future. The new headless command server is letting me see much more information on our shutdown and one thing I notice is that we have an interface that is using tcpip_client_interface with nil timeouts for both read and write (it is expected that this interface won’t be constantly transmitting). Anyway, it is failing to shut down cleanly on exit (full message below).

It looks like tcpip_socket_stream expects to get a IOERROR or Errno::ENOTSOCK when the socket is closed while waiting on the select(), but that apparently isn’t happening.

It looks like this may be a common problem that can be refactored around by just doing a blocking read instead of using select:
https://www.ruby-forum.com/topic/4415582

I could refactor the target on the other side to send packets more frequently so we could use a timeout, but that seems a workaround rather than a fix.

2015/07/09 15:02:07.156 INFO: Killing thread for interface BUSMON_INT
2015/07/09 15:02:08.161 WARN: Failed to gracefully kill thread:
Caller Backtrace:
/opt/ruby-2.1.5/lib/ruby/gems/2.1.0/gems/cosmos-3.5.0/lib/cosmos/tools/cmd_tlm_server/interface_thread.rb:124:in stop' /opt/ruby-2.1.5/lib/ruby/gems/2.1.0/gems/cosmos-3.5.0/lib/cosmos/tools/cmd_tlm_server/interfaces.rb:121:instop_thread'
/opt/ruby-2.1.5/lib/ruby/gems/2.1.0/gems/cosmos-3.5.0/lib/cosmos/tools/cmd_tlm_server/connections.rb:84:in disconnect' /opt/ruby-2.1.5/lib/ruby/gems/2.1.0/gems/cosmos-3.5.0/lib/cosmos/tools/cmd_tlm_server/connections.rb:44:inblock in stop'
/opt/ruby-2.1.5/lib/ruby/gems/2.1.0/gems/cosmos-3.5.0/lib/cosmos/tools/cmd_tlm_server/connections.rb:43:in each' /opt/ruby-2.1.5/lib/ruby/gems/2.1.0/gems/cosmos-3.5.0/lib/cosmos/tools/cmd_tlm_server/connections.rb:43:instop'
/opt/ruby-2.1.5/lib/ruby/gems/2.1.0/gems/cosmos-3.5.0/lib/cosmos/tools/cmd_tlm_server/cmd_tlm_server.rb:226:in stop' /opt/ruby-2.1.5/lib/ruby/gems/2.1.0/gems/cosmos-3.5.0/lib/cosmos/tools/cmd_tlm_server/cmd_tlm_server_gui.rb:365:inensure in post_options_parsed_hook'
/opt/ruby-2.1.5/lib/ruby/gems/2.1.0/gems/cosmos-3.5.0/lib/cosmos/tools/cmd_tlm_server/cmd_tlm_server_gui.rb:365:in post_options_parsed_hook' /opt/ruby-2.1.5/lib/ruby/gems/2.1.0/gems/cosmos-3.5.0/lib/cosmos/gui/qt_tool.rb:181:inblock in run'
/opt/ruby-2.1.5/lib/ruby/gems/2.1.0/gems/cosmos-3.5.0/lib/cosmos/top_level.rb:682:in set_working_dir' /opt/ruby-2.1.5/lib/ruby/gems/2.1.0/gems/cosmos-3.5.0/lib/cosmos/gui/qt_tool.rb:177:inrun'
/opt/ruby-2.1.5/lib/ruby/gems/2.1.0/gems/cosmos-3.5.0/lib/cosmos/tools/cmd_tlm_server/cmd_tlm_server_gui.rb:403:in block in run' /opt/ruby-2.1.5/lib/ruby/gems/2.1.0/gems/cosmos-3.5.0/lib/cosmos/top_level.rb:511:incatch_fatal_exception'
/opt/ruby-2.1.5/lib/ruby/gems/2.1.0/gems/cosmos-3.5.0/lib/cosmos/tools/cmd_tlm_server/cmd_tlm_server_gui.rb:376:in run' ./CmdTlmServer:15:inblock in

'
/export/home/j1swtb/cosmos/tool_dispatcher/tools/tool_launch.rb:16:in tool_launch' ./CmdTlmServer:13:in'

Thread Backtrace:
/opt/ruby-2.1.5/lib/ruby/gems/2.1.0/gems/cosmos-3.5.0/lib/cosmos/core_ext/io.rb:25:in select' /opt/ruby-2.1.5/lib/ruby/gems/2.1.0/gems/cosmos-3.5.0/lib/cosmos/core_ext/io.rb:25:infast_select'
/opt/ruby-2.1.5/lib/ruby/gems/2.1.0/gems/cosmos-3.5.0/lib/cosmos/streams/tcpip_socket_stream.rb:57:in rescue in read' /opt/ruby-2.1.5/lib/ruby/gems/2.1.0/gems/cosmos-3.5.0/lib/cosmos/streams/tcpip_socket_stream.rb:51:inread'
/opt/ruby-2.1.5/lib/ruby/gems/2.1.0/gems/cosmos-3.5.0/lib/cosmos/streams/stream_protocol.rb:350:in read_and_handle_timeout' /opt/ruby-2.1.5/lib/ruby/gems/2.1.0/gems/cosmos-3.5.0/lib/cosmos/streams/stream_protocol.rb:366:inread_minimum_size'
/opt/ruby-2.1.5/lib/ruby/gems/2.1.0/gems/cosmos-3.5.0/lib/cosmos/streams/preidentified_stream_protocol.rb:97:in reduce_to_single_packet' /opt/ruby-2.1.5/lib/ruby/gems/2.1.0/gems/cosmos-3.5.0/lib/cosmos/streams/stream_protocol.rb:144:inblock in read'
/opt/ruby-2.1.5/lib/ruby/gems/2.1.0/gems/cosmos-3.5.0/lib/cosmos/streams/stream_protocol.rb:139:in loop' /opt/ruby-2.1.5/lib/ruby/gems/2.1.0/gems/cosmos-3.5.0/lib/cosmos/streams/stream_protocol.rb:139:inread'
/opt/ruby-2.1.5/lib/ruby/gems/2.1.0/gems/cosmos-3.5.0/lib/cosmos/interfaces/stream_interface.rb:56:in read' /opt/ruby-2.1.5/lib/ruby/gems/2.1.0/gems/cosmos-3.5.0/lib/cosmos/tools/cmd_tlm_server/interface_thread.rb:81:inblock in start'

2015/07/09 15:02:08.171 INFO: Disconnected from interface BUSMON_INT

@ghost ghost added the bug label Jul 17, 2015
jmthomas added a commit that referenced this issue Aug 4, 2015
@ghost ghost closed this as completed in 305d0fe Aug 5, 2015
ghost pushed a commit that referenced this issue Aug 5, 2015
closes #168, closes #80 Fix select blocking and implement IO without …
@ghost ghost modified the milestone: v3.6.0 Aug 7, 2015
ghost pushed a commit that referenced this issue Aug 12, 2021
Merge in COSMOSEE/base from connect_running_scripts to master

* commit 'df1fa92b4a4e314512a087067ba3018a1636b6a2':
  Support reconnecting to running script
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

0 participants