Mercurial > hg > freeDiameter
comparison libfreeDiameter/messages.c @ 637:22e8fac3b2d6
Split interface file in modules
author | Sebastien Decugis <sdecugis@nict.go.jp> |
---|---|
date | Thu, 16 Dec 2010 18:56:41 +0900 |
parents | bb8a4fa301b3 |
children | 9448cba86673 |
comparison
equal
deleted
inserted
replaced
636:c23ca590fa57 | 637:22e8fac3b2d6 |
---|---|
115 struct msg_hdr msg_public; /* Message data that can be managed by extensions. */ | 115 struct msg_hdr msg_public; /* Message data that can be managed by extensions. */ |
116 | 116 |
117 uint8_t *msg_rawbuffer; /* data buffer that was received, saved during fd_msg_parse_buffer and freed in fd_msg_parse_dict */ | 117 uint8_t *msg_rawbuffer; /* data buffer that was received, saved during fd_msg_parse_buffer and freed in fd_msg_parse_dict */ |
118 int msg_routable; /* Is this a routable message? (0: undef, 1: routable, 2: non routable) */ | 118 int msg_routable; /* Is this a routable message? (0: undef, 1: routable, 2: non routable) */ |
119 struct msg *msg_query; /* the associated query if the message is a received answer */ | 119 struct msg *msg_query; /* the associated query if the message is a received answer */ |
120 int msg_associated; /* and the counter part information in the query, to avoid double free */ | |
120 struct rt_data *msg_rtdata; /* Routing list for the query */ | 121 struct rt_data *msg_rtdata; /* Routing list for the query */ |
121 struct session *msg_sess; /* Cached message session if any */ | 122 struct session *msg_sess; /* Cached message session if any */ |
122 struct { | 123 struct { |
123 void (*fct)(void *, struct msg **); | 124 void (*fct)(void *, struct msg **); |
124 void * data; | 125 void * data; |
339 CHECK_FCT( fd_sess_ref_msg(sess) ); | 340 CHECK_FCT( fd_sess_ref_msg(sess) ); |
340 } | 341 } |
341 | 342 |
342 /* associate with query */ | 343 /* associate with query */ |
343 ans->msg_query = qry; | 344 ans->msg_query = qry; |
345 qry->msg_associated = 1; | |
344 | 346 |
345 /* Done */ | 347 /* Done */ |
346 *msg = ans; | 348 *msg = ans; |
347 return 0; | 349 return 0; |
348 } | 350 } |
626 { | 628 { |
627 TRACE_ENTRY("%p", object); | 629 TRACE_ENTRY("%p", object); |
628 | 630 |
629 if (CHECK_MSG(object)) { | 631 if (CHECK_MSG(object)) { |
630 if (_M(object)->msg_query) { | 632 if (_M(object)->msg_query) { |
633 _M(_M(object)->msg_query)->msg_associated = 0; | |
631 CHECK_FCT( fd_msg_free( _M(object)->msg_query ) ); | 634 CHECK_FCT( fd_msg_free( _M(object)->msg_query ) ); |
632 _M(object)->msg_query = NULL; | 635 _M(object)->msg_query = NULL; |
636 } else { | |
637 if (_M(object)->msg_associated) { | |
638 TRACE_DEBUG(INFO, "Not freeing query %p referenced in an answer (will be freed along the answer).", object); | |
639 return 0; | |
640 } | |
633 } | 641 } |
634 } | 642 } |
635 | 643 |
636 destroy_tree(_C(object)); | 644 destroy_tree(_C(object)); |
637 return 0; | 645 return 0; |
686 msg->msg_public.msg_code, | 694 msg->msg_public.msg_code, |
687 msg->msg_public.msg_appl, | 695 msg->msg_public.msg_appl, |
688 msg->msg_public.msg_hbhid, | 696 msg->msg_public.msg_hbhid, |
689 msg->msg_public.msg_eteid | 697 msg->msg_public.msg_eteid |
690 ); | 698 ); |
691 fd_log_debug(INOBJHDR "intern: rwb:%p rt:%d cb:%p(%p) qry:%p sess:%p src:%s\n", | 699 fd_log_debug(INOBJHDR "intern: rwb:%p rt:%d cb:%p(%p) qry:%p asso:%d sess:%p src:%s\n", |
692 INOBJHDRVAL, msg->msg_rawbuffer, msg->msg_routable, msg->msg_cb.fct, msg->msg_cb.data, msg->msg_query, msg->msg_sess, msg->msg_src_id?:"(nil)"); | 700 INOBJHDRVAL, msg->msg_rawbuffer, msg->msg_routable, msg->msg_cb.fct, msg->msg_cb.data, msg->msg_query, msg->msg_associated, msg->msg_sess, msg->msg_src_id?:"(nil)"); |
693 } | 701 } |
694 | 702 |
695 /* Dump an avp object */ | 703 /* Dump an avp object */ |
696 static void obj_dump_avp ( struct avp * avp, int indent ) | 704 static void obj_dump_avp ( struct avp * avp, int indent ) |
697 { | 705 { |
859 TRACE_ENTRY( "%p %p", answer, query ); | 867 TRACE_ENTRY( "%p %p", answer, query ); |
860 | 868 |
861 CHECK_PARAMS( CHECK_MSG(answer) && CHECK_MSG(query) && (answer->msg_query == NULL ) ); | 869 CHECK_PARAMS( CHECK_MSG(answer) && CHECK_MSG(query) && (answer->msg_query == NULL ) ); |
862 | 870 |
863 answer->msg_query = query; | 871 answer->msg_query = query; |
872 query->msg_associated = 1; | |
864 | 873 |
865 return 0; | 874 return 0; |
866 } | 875 } |
867 | 876 |
868 int fd_msg_answ_getq( struct msg * answer, struct msg ** query ) | 877 int fd_msg_answ_getq( struct msg * answer, struct msg ** query ) |
880 { | 889 { |
881 TRACE_ENTRY( "%p", answer ); | 890 TRACE_ENTRY( "%p", answer ); |
882 | 891 |
883 CHECK_PARAMS( CHECK_MSG(answer) ); | 892 CHECK_PARAMS( CHECK_MSG(answer) ); |
884 | 893 |
894 answer->msg_query->msg_associated = 0; | |
885 answer->msg_query = NULL; | 895 answer->msg_query = NULL; |
886 | 896 |
887 return 0; | 897 return 0; |
888 } | 898 } |
889 | 899 |