Different sizeof(struct mosquitto) in Broker #180

dennisip86 opened this Issue May 31, 2016 · 3 comments


None yet

2 participants

  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 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 commented May 31, 2016 edited

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:

    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 ralight added a commit that referenced this issue May 31, 2016
@ralight ralight [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 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