Browse code

tm: more debug to track decision to relay reply or not

(cherry picked from commit b292adb668528340fca381925724540afc7f13e8)

Daniel-Constantin Mierla authored on 09/03/2019 08:40:59
Showing 1 changed files
... ...
@@ -1263,7 +1263,7 @@ static enum rps t_should_relay_response( struct cell *Trans , int new_code,
1263 1263
 	 * not relayed because it's not an INVITE transaction;
1264 1264
 	 * >= 300 are not relayed because 200 was already sent out
1265 1265
 	*/
1266
-	LM_DBG("->>>>>>>>> T_code=%d, new_code=%d\n",Trans->uas.status,new_code);
1266
+	LM_DBG("->>>>>>>>> T_code=%d, new_code=%d\n", Trans->uas.status,new_code);
1267 1267
 	inv_through=new_code>=200 && new_code<300 && is_invite(Trans);
1268 1268
 	/* if final response sent out, allow only INVITE 2xx  */
1269 1269
 	if ( Trans->uas.status >= 200 ) {
... ...
@@ -1273,6 +1273,8 @@ static enum rps t_should_relay_response( struct cell *Trans , int new_code,
1273 1273
 			Trans->uac[branch].last_received=new_code;
1274 1274
 			*should_relay=branch;
1275 1275
 			return RPS_PUSHED_AFTER_COMPLETION;
1276
+		} else {
1277
+			LM_DBG("final reply already sent\n");
1276 1278
 		}
1277 1279
 		/* except the exception above, too late  messages will be discarded */
1278 1280
 		goto discard;
... ...
@@ -1325,8 +1327,8 @@ static enum rps t_should_relay_response( struct cell *Trans , int new_code,
1325 1327
 			picked_branch = branch;
1326 1328
 			run_branch_failure_handlers( Trans, Trans->uac[branch].reply,
1327 1329
 									new_code, extra_flags);
1328
-		 	/* Don't do reset the reply if we are in a resume route, 
1329
-		  	 * we need to free it at the end of the continue processing */
1330
+			/* Don't do reset the reply if we are in a resume route,
1331
+			 * we need to free it at the end of the continue processing */
1330 1332
 			if (!(Trans->flags&T_ASYNC_CONTINUE))
1331 1333
 				Trans->uac[branch].reply = 0;
1332 1334
 		}
... ...
@@ -1348,6 +1350,7 @@ static enum rps t_should_relay_response( struct cell *Trans , int new_code,
1348 1350
 #endif /* CANCEL_REASON_SUPPORT */
1349 1351
 				}
1350 1352
 			}
1353
+			LM_DBG("store - other branches still active\n");
1351 1354
 			return RPS_STORE;
1352 1355
 		}
1353 1356
 		if (picked_branch==-1) {
... ...
@@ -1411,8 +1414,8 @@ static enum rps t_should_relay_response( struct cell *Trans , int new_code,
1411 1414
 
1412 1415
 		/* now reset it; after the failure logic, the reply may
1413 1416
 		 * not be stored any more and we don't want to keep into
1414
-		 * transaction some broken reference. Don't do it if we                     
1415
-		 * are in a resume route, we need to free it at the end 
1417
+		 * transaction some broken reference. Don't do it if we
1418
+		 * are in a resume route, we need to free it at the end
1416 1419
 		 * of the continue processing */
1417 1420
 		if (!(Trans->flags&T_ASYNC_CONTINUE))
1418 1421
 			Trans->uac[branch].reply = 0;
... ...
@@ -1431,6 +1434,7 @@ static enum rps t_should_relay_response( struct cell *Trans , int new_code,
1431 1434
 			 * put it on wait again; perhaps splitting put_on_wait
1432 1435
 			 * from send_reply or a new RPS_ code would be healthy
1433 1436
 			*/
1437
+			LM_DBG("rps completed - uas status: %d\n", Trans->uas.status);
1434 1438
 			return RPS_COMPLETED;
1435 1439
 		}
1436 1440
 		/* look if the callback/failure_route introduced new branches ... */
... ...
@@ -1450,6 +1454,7 @@ static enum rps t_should_relay_response( struct cell *Trans , int new_code,
1450 1454
 					if (new_branch==-2) { /* branches open yet */
1451 1455
 						*should_store=1;
1452 1456
 						*should_relay=-1;
1457
+						LM_DBG("rps store - uas status: %d\n", Trans->uas.status);
1453 1458
 						return RPS_STORE;
1454 1459
 					}
1455 1460
 					/* error, use the old picked_branch */
... ...
@@ -1458,6 +1463,7 @@ static enum rps t_should_relay_response( struct cell *Trans , int new_code,
1458 1463
 						/* we are not allowed to relay the reply */
1459 1464
 						*should_store=0;
1460 1465
 						*should_relay=-1;
1466
+						LM_DBG("rps discarded - uas status: %d\n", Trans->uas.status);
1461 1467
 						return RPS_DISCARDED;
1462 1468
 					} else {
1463 1469
 						/* There are no open branches,
... ...
@@ -1485,6 +1491,8 @@ static enum rps t_should_relay_response( struct cell *Trans , int new_code,
1485 1491
 		/* we dont need 'prepare_to_cancel' here -- all branches
1486 1492
 		 * known to have completed */
1487 1493
 		/* prepare_to_cancel( Trans, cancel_bitmap, 0 ); */
1494
+		LM_DBG("rps completed - uas status: %d branch: %d\n",
1495
+				Trans->uas.status, picked_branch);
1488 1496
 		return RPS_COMPLETED;
1489 1497
 	}
1490 1498
 
... ...
@@ -1507,17 +1515,22 @@ static enum rps t_should_relay_response( struct cell *Trans , int new_code,
1507 1515
 #ifdef CANCEL_REASON_SUPPORT
1508 1516
 			cancel_data->reason.cause=new_code;
1509 1517
 #endif /* CANCEL_REASON_SUPPORT */
1518
+			LM_DBG("rps completed - uas status: %d\n", Trans->uas.status);
1510 1519
 			return RPS_COMPLETED;
1511
-		} else return RPS_PROVISIONAL;
1520
+		} else {
1521
+			LM_DBG("rps provisional - uas status: %d\n", Trans->uas.status);
1522
+			return RPS_PROVISIONAL;
1523
+		}
1512 1524
 	}
1513 1525
 
1514 1526
 error:
1515 1527
 	/* reply_status didn't match -- it must be something weird */
1516
-	LM_CRIT("error - oh my gooosh! We don't know whether to relay %d\n",
1528
+	LM_CRIT("error - unable to decide whether to relay %d\n",
1517 1529
 		new_code);
1518 1530
 discard:
1519 1531
 	*should_store=0;
1520 1532
 	*should_relay=-1;
1533
+	LM_DBG("finished with rps discarded - uas status: %d\n", Trans->uas.status);
1521 1534
 	return RPS_DISCARDED;
1522 1535
 
1523 1536
 branches_failed:
... ...
@@ -1534,6 +1547,7 @@ branches_failed:
1534 1547
 			LM_ERR("reply generation failed\n");
1535 1548
 		}
1536 1549
 	}
1550
+	LM_DBG("finished with rps completed - uas status: %d\n", Trans->uas.status);
1537 1551
 	return RPS_COMPLETED;
1538 1552
 }
1539 1553
 
... ...
@@ -1806,8 +1820,8 @@ enum rps relay_reply( struct cell *t, struct sip_msg *p_msg, int branch,
1806 1820
 	/* *** store and relay message as needed *** */
1807 1821
 	reply_status = t_should_relay_response(t, msg_status, branch,
1808 1822
 		&save_clone, &relay, cancel_data, p_msg );
1809
-	LM_DBG("branch=%d, save=%d, relay=%d icode=%d msg status=%u\n",
1810
-		branch, save_clone, relay, t->uac[branch].icode, msg_status);
1823
+	LM_DBG("reply status=%d branch=%d, save=%d, relay=%d icode=%d msg status=%u\n",
1824
+		reply_status, branch, save_clone, relay, t->uac[branch].icode, msg_status);
1811 1825
 
1812 1826
 	/* store the message if needed */
1813 1827
 	if (save_clone) {