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

Different sizeof(struct mosquitto) in Broker #180

Closed
dennisip86 opened this issue May 31, 2016 · 3 comments
Closed

Different sizeof(struct mosquitto) in Broker #180

dennisip86 opened this issue May 31, 2016 · 3 comments

Comments

@dennisip86
Copy link

  1. Set WITH_WEBSOCKETS = yes
  2. Print the sizeof(struct mosquitto) in src/read_handle.c:232
  3. print the sizeof(struct mosquitto) in lib/send_mosq.c:86
  4. Publish a message to a subscriber

I got 448 and 456

@ralight
Copy link
Contributor

ralight commented May 31, 2016

Yes, that is as expected. struct mosquitto is a private type, you shouldn't be worrying about its size.

The struct mosquitto in src/read_handle.c is as used by the broker.
The struct mosquitto in lib/send_mosq.c is as used by the client library.

The broker and client library have different requirements, so the struct changes.

What is it you're trying to achieve?

@dennisip86
Copy link
Author

dennisip86 commented May 31, 2016

The sizeof(struct mosquitto) 448 and 456 was printed by the same broker.
It will crash when access the member of struct mosquitto declare after:

#  ifdef WITH_WEBSOCKETS
#    if defined(LWS_LIBRARY_VERSION_NUMBER)
    struct lws *wsi;
#    else
    struct libwebsocket_context *ws_context;
    struct libwebsocket *wsi;
#    endif
#  endif

Because struct mosquitto is different size between src/ and lib/ in the same broker!!

ralight added a commit that referenced this issue May 31, 2016
Ensures that LWS_LIBRARY_VERSION_NUMBER is always present in all source
files when it is defined.

Thanks to dennisip86.

Bug: #180
@ralight
Copy link
Contributor

ralight commented Jun 1, 2016

Thanks, I thought you were worried about the difference between the client and broker struct instead. This is now fixed.

@ralight ralight closed this as completed Jun 1, 2016
@ralight ralight added this to the 1.4.9 milestone Jun 1, 2016
@lock lock bot locked as resolved and limited conversation to collaborators Aug 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants