At Bogdan's request, I checked out the stored proc for CDR Correlation in the opensips-cp project. <div><br></div><div>I see the Invite cursor declared as:</div><div> DECLARE inv_cursor CURSOR FOR SELECT time, callid, from_tag, to_tag FROM opensips.acc where method='INVITE' and cdr_id='0';<br>
</div><div><br></div><div>This seems like a problem to me.. Imagine a call with several invites in it (SST for example). It could pick up an INVITE in the middle of the call as the "initial invite" and then improperly account duration, etc. </div>
<div><br></div><div>Furthermore picking the BYE:</div><div>SELECT 1, time INTO bye_record, v_bye_time FROM opensips.acc WHERE method='BYE' AND callid=v_callid AND ((from_tag=v_from_tag AND to_tag=v_to_tag) OR (from_tag=v_to_tag AND to_tag=v_from_tag)) ORDER BY time ASC LIMIT 1;<br>
</div><div><br></div><div>Shouldn't that ordering at the end be DESC instead of ASC.. point is, don't you want the absolute FIRST invite per callid and the absolute last BYE per callid? (sure there shouldn't be much after the FIRST BYE, but still..)</div>
<div><br></div><div>BTW, Please redirect me if it's not appropriate to ask opensips-cp questions here..</div><div><br></div><div>-Brett</div><div><br></div>