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

Comments

Projects
None yet
2 participants
@dennisip86

dennisip86 commented May 31, 2016

  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

This comment has been minimized.

Show comment
Hide comment
@ralight

ralight May 31, 2016

Contributor

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?

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

This comment has been minimized.

Show comment
Hide comment
@dennisip86

dennisip86 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!!

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

[180] Fix #includes in lib/send_mosq.c
Ensures that LWS_LIBRARY_VERSION_NUMBER is always present in all source
files when it is defined.

Thanks to dennisip86.

Bug: #180
@ralight

This comment has been minimized.

Show comment
Hide comment
@ralight

ralight Jun 1, 2016

Contributor

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

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 Jun 1, 2016

@ralight ralight added this to the 1.4.9 milestone Jun 1, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment