Mercurial > hg > freeDiameter
diff libfreeDiameter/messages.c @ 646:cfc8da9264f4
Prepared first part of the changes for #10
author | Sebastien Decugis <sdecugis@nict.go.jp> |
---|---|
date | Tue, 04 Jan 2011 16:20:50 +0900 |
parents | 9448cba86673 |
children | ae29bf971f20 |
line wrap: on
line diff
--- a/libfreeDiameter/messages.c Tue Jan 04 11:54:19 2011 +0900 +++ b/libfreeDiameter/messages.c Tue Jan 04 16:20:50 2011 +0900 @@ -123,6 +123,7 @@ struct { void (*fct)(void *, struct msg **); void * data; + struct timespec timeout; } msg_cb; /* Callback to be called when an answer is received, if not NULL */ char * msg_src_id; /* Diameter Id of the peer this message was received from. This string is malloc'd and must be freed */ }; @@ -903,7 +904,7 @@ } /* Associate / get answer callbacks */ -int fd_msg_anscb_associate( struct msg * msg, void ( *anscb)(void *, struct msg **), void * data ) +int fd_msg_anscb_associate( struct msg * msg, void ( *anscb)(void *, struct msg **), void * data, const struct timespec *timeout ) { TRACE_ENTRY("%p %p %p", msg, anscb, data); @@ -915,6 +916,11 @@ /* Associate callback and data with the message, if any */ msg->msg_cb.fct = anscb; msg->msg_cb.data = data; + if (timeout) { + memcpy(&msg->msg_cb.timeout, timeout, sizeof(struct timespec)); + } else { + memset(&msg->msg_cb.timeout, 0, sizeof(struct timespec)); /* clear the area */ + } return 0; }