... | ... |
@@ -142,7 +142,7 @@ Desc: sets reply routing block, to which control is passed after |
142 | 142 |
upstream "202 I will take care of it"); Note that the |
143 | 143 |
set of command which are useable within reply_routes is |
144 | 144 |
strictly limited to rewriting URI, initiating new branches, |
145 |
- logging, and sending 'unsafe' replies (t_reply_unsafe). Any |
|
145 |
+ logging, and sending stateful replies (t_reply). Any |
|
146 | 146 |
other commands may result in unpredictable behaviour and |
147 | 147 |
possible server failure. |
148 | 148 |
Note that whenever reply_route is entered, uri is reset to |
... | ... |
@@ -189,8 +189,7 @@ Example: see test/uas.cfg: |
189 | 189 |
Name: t_reply |
190 | 190 |
Params: code, reason phrase |
191 | 191 |
Desc: sends a stateful reply after a transaction has been |
192 |
- established; see t_newtran for usage; note: never use |
|
193 |
- t_reply from within reply_route ... always use t_reply_unsafe |
|
192 |
+ established; see t_newtran for usage; |
|
194 | 193 |
|
195 | 194 |
----- only --- advanced --- commands --- from --- here --- on ----- |
196 | 195 |
|
... | ... |
@@ -226,13 +225,6 @@ Params: *import_structure |
226 | 225 |
Desc: for programmatic use only -- import exported TM functions; |
227 | 226 |
see the acc module for an example of use |
228 | 227 |
|
229 |
-Name: t_reply_unsafe |
|
230 |
-Params: code, reason phrase |
|
231 |
-Desc: sends a stateful reply after a transaction has been |
|
232 |
- established; it can only be used from reply processing; |
|
233 |
- using it from regular processing will introduce erroneous |
|
234 |
- conditions; using t_reply from reply_processing will |
|
235 |
- introduce a deadlock |
|
236 | 228 |
|
237 | 229 |
External Usage of TM |
238 | 230 |
--------------------- |
... | ... |
@@ -50,6 +50,9 @@ |
50 | 50 |
#include "fix_lumps.h" |
51 | 51 |
#include "t_stats.h" |
52 | 52 |
|
53 |
+/* are we processing original or shmemed request ? */ |
|
54 |
+enum route_mode rmode=MODE_REQUEST; |
|
55 |
+ |
|
53 | 56 |
/* private place where we create to-tags for replies */ |
54 | 57 |
static char tm_tags[TOTAG_LEN]; |
55 | 58 |
static char *tm_tag_suffix; |
... | ... |
@@ -858,6 +861,7 @@ void on_negative_reply( struct cell* t, struct sip_msg* msg, |
858 | 861 |
{ |
859 | 862 |
int act_ret; |
860 | 863 |
struct sip_msg faked_msg; |
864 |
+ enum route_mode backup_mode; |
|
861 | 865 |
|
862 | 866 |
/* nobody cares about a negative transaction -- ok, return */ |
863 | 867 |
if (!t->on_negative) { |
... | ... |
@@ -900,7 +904,10 @@ void on_negative_reply( struct cell* t, struct sip_msg* msg, |
900 | 904 |
*/ |
901 | 905 |
faked_msg.id=t->uas.request->id-1; |
902 | 906 |
|
907 |
+ backup_mode=rmode; |
|
908 |
+ rmode=MODE_ONREPLY_REQUEST; |
|
903 | 909 |
act_ret=run_actions(reply_rlist[t->on_negative], &faked_msg ); |
910 |
+ rmode=backup_mode; |
|
904 | 911 |
|
905 | 912 |
if (act_ret<0) { |
906 | 913 |
LOG(L_ERR, "on_negative_reply: Error in do_action\n"); |
... | ... |
@@ -80,7 +80,9 @@ |
80 | 80 |
|
81 | 81 |
inline static int w_t_check(struct sip_msg* msg, char* str, char* str2); |
82 | 82 |
inline static int w_t_reply(struct sip_msg* msg, char* str, char* str2); |
83 |
+#ifdef _OBSOLETED |
|
83 | 84 |
inline static int w_t_reply_unsafe(struct sip_msg* msg, char* str, char* str2); |
85 |
+#endif |
|
84 | 86 |
inline static int w_t_release(struct sip_msg* msg, char* str, char* str2); |
85 | 87 |
inline static int fixup_t_send_reply(void** param, int param_no); |
86 | 88 |
inline static int fixup_str2int( void** param, int param_no); |
... | ... |
@@ -113,7 +115,9 @@ struct module_exports exports= { |
113 | 115 |
"t_newtran", |
114 | 116 |
"t_lookup_request", |
115 | 117 |
T_REPLY, |
118 |
+#ifdef _OBSO |
|
116 | 119 |
T_REPLY_UNSAFE, |
120 |
+#endif |
|
117 | 121 |
"t_retransmit_reply", |
118 | 122 |
"t_release", |
119 | 123 |
T_RELAY_TO, |
... | ... |
@@ -133,7 +137,9 @@ struct module_exports exports= { |
133 | 137 |
w_t_newtran, |
134 | 138 |
w_t_check, |
135 | 139 |
w_t_reply, |
140 |
+#ifdef _OBSO |
|
136 | 141 |
w_t_reply_unsafe, |
142 |
+#endif |
|
137 | 143 |
w_t_retransmit_reply, |
138 | 144 |
w_t_release, |
139 | 145 |
w_t_relay_to, |
... | ... |
@@ -151,7 +157,9 @@ struct module_exports exports= { |
151 | 157 |
0, /* t_newtran */ |
152 | 158 |
0, /* t_lookup_request */ |
153 | 159 |
2, /* t_reply */ |
160 |
+#ifdef _OBSO |
|
154 | 161 |
2, /* t_reply_unsafe */ |
162 |
+#endif |
|
155 | 163 |
0, /* t_retransmit_reply */ |
156 | 164 |
0, /* t_release */ |
157 | 165 |
2, /* t_relay_to */ |
... | ... |
@@ -168,7 +176,9 @@ struct module_exports exports= { |
168 | 176 |
0, /* t_newtran */ |
169 | 177 |
0, /* t_lookup_request */ |
170 | 178 |
fixup_t_send_reply, /* t_reply */ |
179 |
+#ifdef _OBSO |
|
171 | 180 |
fixup_t_send_reply, /* t_reply_unsafe */ |
181 |
+#endif |
|
172 | 182 |
0, /* t_retransmit_reply */ |
173 | 183 |
0, /* t_release */ |
174 | 184 |
fixup_hostport2proxy, /* t_relay_to */ |
... | ... |
@@ -182,7 +192,11 @@ struct module_exports exports= { |
182 | 192 |
0 /* t_newdlg */ |
183 | 193 |
|
184 | 194 |
}, |
195 |
+#ifdef _OBSO |
|
185 | 196 |
15, |
197 |
+#else |
|
198 |
+ 14, |
|
199 |
+#endif |
|
186 | 200 |
|
187 | 201 |
/* ------------ exported variables ---------- */ |
188 | 202 |
(char *[]) { /* Module parameter names */ |
... | ... |
@@ -462,10 +476,19 @@ inline static int w_t_reply(struct sip_msg* msg, char* str, char* str2) |
462 | 476 |
"for which no T-state has been established\n"); |
463 | 477 |
return -1; |
464 | 478 |
} |
465 |
- return t_reply( t, msg, (unsigned int) str, str2); |
|
479 |
+ /* if called from reply_route, make sure that unsafe version |
|
480 |
+ * is called; we are already in a mutex and another mutex in |
|
481 |
+ * the safe version would lead to a deadlock |
|
482 |
+ */ |
|
483 |
+ if (rmode==MODE_ONREPLY_REQUEST) { |
|
484 |
+ DBG("DEBUG: t_reply_unsafe called from w_t_reply\n"); |
|
485 |
+ return t_reply_unsafe(t, msg, (unsigned int) str, str2); |
|
486 |
+ } else { |
|
487 |
+ return t_reply( t, msg, (unsigned int) str, str2); |
|
488 |
+ } |
|
466 | 489 |
} |
467 | 490 |
|
468 |
- |
|
491 |
+#ifdef _OBSOLETED |
|
469 | 492 |
inline static int w_t_reply_unsafe(struct sip_msg* msg, char* str, char* str2) |
470 | 493 |
{ |
471 | 494 |
struct cell *t; |
... | ... |
@@ -483,6 +506,7 @@ inline static int w_t_reply_unsafe(struct sip_msg* msg, char* str, char* str2) |
483 | 506 |
} |
484 | 507 |
return t_reply_unsafe(t, msg, (unsigned int) str, str2); |
485 | 508 |
} |
509 |
+#endif |
|
486 | 510 |
|
487 | 511 |
|
488 | 512 |
inline static int w_t_release(struct sip_msg* msg, char* str, char* str2) |