freediameter - how to handle request messages outside of dispatch function

209 views Asked by At

So, I've advertised for DCCA application in my extension via fd_disp_register and I can parse and prepare the response message and at the end sending them from my callback function with no issue.

This always works if the answer message is prepared inside of callback function. But what if i want to reply the request message outside of my callback function ?

So, I tried it with a sample code. I changed the callback function logic so there were no sending message from it and instead another thread tries to fetch some information and send out the response.

This absolutely failed, because as soon as callback returns (with 0), the next action gonna take place (according to disp_action value) which is not in my favor.

So, I'd like to ask what is your solution to handle such case, I mean sending out the response messages outside of the callback function ?

Thanks.

1

There are 1 answers

0
Matt Williams On BEST ANSWER

I'm not sure I've ever done this before, but looking at libfdproto.h...

enum disp_action {
  DISP_ACT_CONT,  /* The next handler should be called, unless *msg == NULL. */
  DISP_ACT_SEND,  /* The updated message must be sent. No further callback is called. */
  DISP_ACT_ERROR  /* An error must be created and sent as a reply -- not valid for callbacks, only for fd_msg_dispatch. */
};

...it sounds like you want to set *act = DISP_ACT_CONT; and *msg = NULL; (because you've taken ownership of the message).

Does that work?