From: Karsten Keil Date: Sat, 24 Sep 2011 07:29:28 +0000 (+0200) Subject: New pid handling X-Git-Url: http://git.eversberg.eu/gitweb.cgi?p=lcr.git;a=commitdiff_plain;h=73353997fd842a1ec34f048be4261f46240113ba New pid handling The old method was racy, it did use the callback function to deliver the result, which need special handling because of possible deadlocks. Now we use a request function which returns the value directely. The old method is still available, but will get removed soon. Signed-off-by: Karsten Keil --- diff --git a/dss1.cpp b/dss1.cpp index 1dd009e..e745bd3 100644 --- a/dss1.cpp +++ b/dss1.cpp @@ -16,7 +16,9 @@ extern "C" { } #include +#ifdef OLD_MT_ASSIGN extern unsigned int mt_assign_pid; +#endif #include "ie.cpp" @@ -2011,10 +2013,18 @@ void Pdss1::message_setup(unsigned int epoint_id, int message_id, union paramete /* creating l3id */ l1l2l3_trace_header(p_m_mISDNport, this, L3_NEW_L3ID_REQ, DIRECTION_OUT); +#ifdef OLD_MT_ASSIGN /* see MT_ASSIGN notes at do_layer3() */ mt_assign_pid = 0; ret = p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_ASSIGN, 0, NULL); - if (mt_assign_pid == 0 || ret < 0) { + if (mt_assign_pid == 0 || ret < 0) + p_m_d_l3id = mt_assign_pid; + mt_assign_pid = ~0; +#else + p_m_d_l3id = request_new_pid(p_m_mISDNport->ml3); + if (p_m_d_l3id == MISDN_PID_NONE) +#endif + { struct lcr_msg *message; add_trace("callref", NULL, "no free id"); @@ -2027,8 +2037,10 @@ void Pdss1::message_setup(unsigned int epoint_id, int message_id, union paramete trigger_work(&p_m_d_delete); return; } +#ifdef OLD_MT_ASSIGN p_m_d_l3id = mt_assign_pid; mt_assign_pid = ~0; +#endif add_trace("callref", "new", "0x%x", p_m_d_l3id); end_trace(); diff --git a/mISDN.cpp b/mISDN.cpp index 3961fd8..1d75fc3 100644 --- a/mISDN.cpp +++ b/mISDN.cpp @@ -37,7 +37,9 @@ struct mISDNport *mISDNport_first; unsigned char mISDN_rand[256]; int mISDN_rand_count = 0; +#ifdef OLD_MT_ASSIGN unsigned int mt_assign_pid = ~0; +#endif int mISDNsocket = -1; static int upqueue_pipe[2]; @@ -2045,6 +2047,7 @@ int do_layer3(struct mlayer3 *ml3, unsigned int cmd, unsigned int pid, struct l3 struct mISDNport *mISDNport = (struct mISDNport *)ml3->priv; struct mbuffer *mb; +#ifdef OLD_MT_ASSIGN /* special MT_ASSIGN handling: * * if we request a PID from mlayer, we always do it while lcr is locked. @@ -2062,6 +2065,7 @@ int do_layer3(struct mlayer3 *ml3, unsigned int cmd, unsigned int pid, struct l3 mt_assign_pid = pid; return(0); } +#endif /* queue message, create, if required */ if (!l3m) { l3m = alloc_l3_msg();