Pārlūkot izejas kodu

topos: reuse uuid for requests withing dialog

- related to GH #1496

(cherry picked from commit 63e5a1f6d3f801136180bf2cb8a042d8af779f65)
Daniel-Constantin Mierla 7 gadi atpakaļ
vecāks
revīzija
f9e0bc365c
1 mainītis faili ar 18 papildinājumiem un 3 dzēšanām
  1. 18 3
      src/modules/topos/tps_storage.c

+ 18 - 3
src/modules/topos/tps_storage.c

@@ -372,13 +372,28 @@ error:
 int tps_storage_record(sip_msg_t *msg, tps_data_t *td, int dialog)
 int tps_storage_record(sip_msg_t *msg, tps_data_t *td, int dialog)
 {
 {
 	int ret;
 	int ret;
+	str suid;
 
 
-	sruid_next(&_tps_sruid);
+	if(dialog==0) {
+		sruid_next(&_tps_sruid);
+		suid = _tps_sruid.uid;
+	} else {
+		if(td->a_uuid.len>0) {
+			suid = td->a_uuid;
+		} else if(td->b_uuid.len>0) {
+			suid = td->b_uuid;
+		} else {
+			goto error;
+		}
+		suid.s++;
+		suid.len--;
+	}
 
 
-	ret = tps_storage_fill_contact(msg, td, &_tps_sruid.uid, TPS_DIR_DOWNSTREAM);
+	ret = tps_storage_fill_contact(msg, td, &suid, TPS_DIR_DOWNSTREAM);
 	if(ret<0) goto error;
 	if(ret<0) goto error;
-	ret = tps_storage_fill_contact(msg, td, &_tps_sruid.uid, TPS_DIR_UPSTREAM);
+	ret = tps_storage_fill_contact(msg, td, &suid, TPS_DIR_UPSTREAM);
 	if(ret<0) goto error;
 	if(ret<0) goto error;
+
 	ret = tps_storage_link_msg(msg, td, TPS_DIR_DOWNSTREAM);
 	ret = tps_storage_link_msg(msg, td, TPS_DIR_DOWNSTREAM);
 	if(ret<0) goto error;
 	if(ret<0) goto error;
 	if(td->as_contact.len <= 0 && td->bs_contact.len <= 0) {
 	if(td->as_contact.len <= 0 && td->bs_contact.len <= 0) {