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

New client with same daemon creates new IRC session unnecessarily #44

Open
AdamISZ opened this issue Mar 13, 2017 · 3 comments
Open

New client with same daemon creates new IRC session unnecessarily #44

AdamISZ opened this issue Mar 13, 2017 · 3 comments

Comments

@AdamISZ
Copy link
Member

AdamISZ commented Mar 13, 2017

If joinmarketd is run persistently with new clients connecting, new instances of JMDaemonServerProtocol are created, meaning that the member variable self.irc_config is reset to None, meaning a new IRC session + nick is created even though the IRC config is the same.

The parts of the class instance which manage the connection should therefore be class variables, but this requires a bit of work. At least the messagechannelcollection object must be thus, and also it seems the orderbookwatch related data. So this is a bit more of a rework than I'd thought it would be. Also there might be something simpler than moving to class variables, perhaps moving these elements to the JMDaemonServerProtocolFactory, not sure.

This isn't labeled as a bug because it does not break functionality, but any long running daemon used repeatedly by clients will create a bunch of useless IRC connections, so it nearly counts. Should be fixed soon.

@AdamISZ
Copy link
Member Author

AdamISZ commented Mar 13, 2017

Note that this does not occur in all-in-one mode (no_daemon=1 in config), which is the default for both scripts and Joinmarket-Qt; noticed it for electrum, where that option is not currently used.

@undeath
Copy link
Contributor

undeath commented Nov 23, 2018

Isn't the current behaviour correct? Assume a single jmdaemon is used by multiple clients, they all will require different nicks and thus different connections.

@AdamISZ
Copy link
Member Author

AdamISZ commented Jun 3, 2022

@undeath's response to this very old issue was correct in as far as it goes. The problem was slightly wrongly characterised by me here.

On the one hand, starting a new protocol instance, with a new nick, clearly is correct. The problem I was observing here was just a result of the fact that there was not a 'shut down message channels' event on the completion of a task while the process is still running. This obviously didn't matter for one-and-done scripts where jmclient and jmdaemon were running in the same process, but did for a distinct joinmarketd.py against which you ran multiple different tasks via command messages sent remotely.

I believe the problem was partially fixed, but only in new usage contexts, by the inclusion of request_mc_shutdown. See these two use cases:

self.clientfactory.proto_client.request_mc_shutdown()

and

self.clientfactory.proto_client.request_mc_shutdown()

but I believe the problem would still exist for a user running a remote joinmarketd.py and starting yieldgenerator multiple times with scripts; the old connections don't shut down (TODO: let's please check that that's actually true).

Assuming this analysis is still correct, it shows up something about refactoring the codebase pretty clearly:

  • Encapsulate long running processes as services so that we can handle shutdown in a uniform way. This concretely means that all instantiations of the yield generator should be done using jmclient.yield_generator.YieldGeneratorService instead of isolated so we always do this the same way.
  • Moving more of the functions into the RPC framework so again, we do everything the same way and don't duplicate work. So our CLI scripts could literally call the same functions as remote clients do in the now clearly defined API.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants