Git Product home page Git Product logo

Comments (5)

fpagliughi avatar fpagliughi commented on August 18, 2024 1

This seems to have been fixed in a recent update.

from paho.mqtt.cpp.

fpagliughi avatar fpagliughi commented on August 18, 2024

Thanks for pointing this out. First I want to make sure that each of the "options" classes (connect, will, ssl, etc) follow proper copy and move semantics, so I will look for the underlying bug which caused the problem. Can you tell me what you mean by "long" string?

And note that next commit to the develop branch will likely convert the password to binary (see #57), so the underlying code is changing rapidly.

In the long run, I intend to optimize the internal behavior of the classes to reduce the copying of large payloads. I'll likely move to a const reference type of class internally so you could make cheap copies of messages and options without copying the payloads... unless, of course you wanted to clone or change them, in which case it would copy-on-write.

But, in the meantime, I will look to add a connect() which takes a pointer.

Of course, if you don't need the options after the connect, you can just move them into the client:

connect_options opts(...);
cli.connect(std::move(opts));

from paho.mqtt.cpp.

tomasbol avatar tomasbol commented on August 18, 2024

The length of the string that I used was 58 characters. When I used shorter strings, the problem did not seem to occur.

Indeed, a move instruction could also be a solution or workaround for this problem.

from paho.mqtt.cpp.

fpagliughi avatar fpagliughi commented on August 18, 2024

Oh, wow, That's not very long. I will make a test case.

from paho.mqtt.cpp.

fpagliughi avatar fpagliughi commented on August 18, 2024

From the beginning, I was resisting using a pointer to the connect_options because connect() modifies the object by updating the context token. It seemed like an undesired side effect.

I'm thinking of an update that would affect this, in PR #90. It would replace the string-type containers for the various buffers (payloads, username, password, etc) with reference types. So, effectively, the connect_option'ss would contain (smart) pointers to the user name and password, and copying the options would be relatively fast and independent of the size of the username and password.

Please have a look and comment.

from paho.mqtt.cpp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.