Different sizeof(struct mosquitto) in Broker #180

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

Projects

None yet

2 participants

@dennisip86
  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
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
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:

#  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 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
c035913
@ralight
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