First of all: I do hope that I write to proper list, I would have written on mosquitto-users but info on that pointed to mosquitto-dev. 
To the topic:
* in my case mosquitto client runs in threaded mode
* `mosquitto_publish(...)` can return message id in `*mid` argument
* as it's said in docs it can be used to assure in `mosquitto_publish_callback` 
I can see one issue with that: there is no guarantee that mosquitto_publish_callback won't be called prior to MID assignment which is called post mosquitto_publish. With that, we can get this scenario ( calls in order of execution in that scenario ) 
` pseudocode
while messages:
     if  ( mid_pos < mid_container_size ):
              mosquitto_publish --> mosquitto_callback --> try remove mid from container ( not stored yet ) --> store_mid_from_mosquitto_publish 
     else:
              cant_add_mid_to_container -> some_error_handling
`
I could guard MID adding/removing with mutex though it seems a bit counterproductive as I could just:
 - use `mosquitto_mid_generate(...)` 
- store it in my mid_container 
- pass it in mosquitto_publish(...)
- Result: be sure it's ready in mosquitto_callback, as there is no way that callback for this MID would be called prior to it's own send.
Of course I could just miss some important detail, or be entirely wrong - if so please be kind to fix me in my thinking it's appreciated.
Best regards,
Adam A. Dobrowolski || pholat