Mercurial > hg > freeDiameter
comparison freeDiameter/p_out.c @ 165:4679ff581d6a
Fix invalid restore of the hop-by-hop id on forwarded answers
author | Sebastien Decugis <sdecugis@nict.go.jp> |
---|---|
date | Wed, 27 Jan 2010 10:56:54 +0900 |
parents | abd3c441780b |
children | e1da03ba112f |
comparison
equal
deleted
inserted
replaced
164:6f6fd233b923 | 165:4679ff581d6a |
---|---|
41 struct msg_hdr * hdr; | 41 struct msg_hdr * hdr; |
42 int msg_is_a_req; | 42 int msg_is_a_req; |
43 uint8_t * buf; | 43 uint8_t * buf; |
44 size_t sz; | 44 size_t sz; |
45 int ret; | 45 int ret; |
46 uint32_t bkp_hbh = 0; | |
46 | 47 |
47 TRACE_ENTRY("%p %p %p %p", msg, cnx, hbh, srl); | 48 TRACE_ENTRY("%p %p %p %p", msg, cnx, hbh, srl); |
48 | 49 |
49 /* Retrieve the message header */ | 50 /* Retrieve the message header */ |
50 CHECK_FCT( fd_msg_hdr(*msg, &hdr) ); | 51 CHECK_FCT( fd_msg_hdr(*msg, &hdr) ); |
51 | 52 |
52 msg_is_a_req = (hdr->msg_flags & CMD_FLAG_REQUEST); | 53 msg_is_a_req = (hdr->msg_flags & CMD_FLAG_REQUEST); |
53 if (msg_is_a_req) { | 54 if (msg_is_a_req) { |
54 CHECK_PARAMS(hbh && srl); | 55 CHECK_PARAMS(hbh && srl); |
55 /* Alloc the hop-by-hop id and increment the value for next message */ | 56 /* Alloc the hop-by-hop id and increment the value for next message */ |
57 bkp_hbh = hdr->msg_hbhid; | |
56 hdr->msg_hbhid = *hbh; | 58 hdr->msg_hbhid = *hbh; |
57 *hbh = hdr->msg_hbhid + 1; | 59 *hbh = hdr->msg_hbhid + 1; |
58 } | 60 } |
59 | 61 |
60 /* Log the message */ | 62 /* Log the message */ |
68 CHECK_FCT(fd_msg_bufferize( *msg, &buf, &sz )); | 70 CHECK_FCT(fd_msg_bufferize( *msg, &buf, &sz )); |
69 pthread_cleanup_push( free, buf ); | 71 pthread_cleanup_push( free, buf ); |
70 | 72 |
71 /* Save a request before sending so that there is no race condition with the answer */ | 73 /* Save a request before sending so that there is no race condition with the answer */ |
72 if (msg_is_a_req) { | 74 if (msg_is_a_req) { |
73 CHECK_FCT_DO( ret = fd_p_sr_store(srl, msg, &hdr->msg_hbhid), { free(buf); return ret; } ); | 75 CHECK_FCT_DO( ret = fd_p_sr_store(srl, msg, &hdr->msg_hbhid, bkp_hbh), { free(buf); return ret; } ); |
74 } | 76 } |
75 | 77 |
76 /* Send the message */ | 78 /* Send the message */ |
77 CHECK_FCT_DO( ret = fd_cnx_send(cnx, buf, sz), { free(buf); return ret; } ); | 79 CHECK_FCT_DO( ret = fd_cnx_send(cnx, buf, sz), { free(buf); return ret; } ); |
78 pthread_cleanup_pop(1); | 80 pthread_cleanup_pop(1); |