trema/trema — pull request #215 by y-higuchi (2012-12-14 12:11:23+00:00)
Title: Add warning message when multiple MESSAGE_TYPE_REQUEST/REPLY callback is being added.

This patch adds a warning message when multiple callback is being added, and a test case for the patch.

Current messenger can correctly handle only 1 message callback each for MESSAGE_TYPE_REQUEST/REPLY type on 1 service name.

Problem Detail:
for loop at [L1429](https://github.com/trema/trema/blob/develop/src/lib/messenger.c#L1429) iterates through registered callbacks.
In the case of MESSAGE_TYPE_REQUEST, callback arguments `transaction_id` and `service_name_len` are [byte swapped on every loop iteration] (https://github.com/trema/trema/blob/develop/src/lib/messenger.c#L1455-L1456), thus wrong `transaction_id` and `service_name_len` will be given to 2nd, 4th... registered callback functions.
If the registered callback does not use these arguments, then there is no problem.
> This is the reason why this patch only adds warnings and not reject such callback registration.

For the case of MESSAGE_TYPE_REPLY, context for request/reply pair is removed at [L1485](https://github.com/trema/trema/blob/develop/src/lib/messenger.c#L1485) after the 1st callback call, so the other callbacks will no be called, even if there are multiple callback registered.