Browse code

sl: re-attempt to bind to tm after all mods init

- handle the situation when tm is initialized after the sl module
- re-binding is done on child callback with rank PROC_INIT

(cherry picked from commit 85d3488c3910d447f6900df166bc6b0c16a64e9c)

Daniel-Constantin Mierla authored on 30/01/2015 07:15:58
Showing 1 changed files
... ...
@@ -164,13 +164,13 @@ static int mod_init(void)
164 164
 		return -1;
165 165
 	}
166 166
 
167
+	memset(&tmb, 0, sizeof(struct tm_binds));
167 168
 	if(sl_bind_tm!=0)
168 169
 	{
169 170
 		if(load_tm_api(&tmb)==-1)
170 171
 		{
171 172
 			LM_INFO("could not bind tm module - only stateless mode"
172
-					" available\n");
173
-			sl_bind_tm=0;
173
+					" available during modules initialization\n");
174 174
 		}
175 175
 	}
176 176
 
... ...
@@ -186,6 +186,14 @@ static int child_init(int rank)
186 186
 			ERR("init_sl_stats_child failed\n");
187 187
 			return -1;
188 188
 		}
189
+		if(sl_bind_tm!=0 && tmb.register_tmcb==0) {
190
+			if(load_tm_api(&tmb)==-1) {
191
+				LM_INFO("could not bind tm module - only stateless mode"
192
+					" available during runtime\n");
193
+				sl_bind_tm=0;
194
+			}
195
+		}
196
+
189 197
 	}
190 198
 	return 0;
191 199
 }
... ...
@@ -267,7 +275,7 @@ int send_reply(struct sip_msg *msg, int code, str *reason)
267 275
 		}
268 276
 	}
269 277
 
270
-	if(sl_bind_tm!=0)
278
+	if(sl_bind_tm!=0 && tmb.t_gett!=0)
271 279
 	{
272 280
 		t = tmb.t_gett();
273 281
 		if(t!= NULL && t!=T_UNDEFINED)
... ...
@@ -324,7 +332,7 @@ int get_reply_totag(struct sip_msg *msg, str *totag)
324 332
 	struct cell * t;
325 333
 	if(msg==NULL || totag==NULL)
326 334
 		return -1;
327
-	if(sl_bind_tm!=0)
335
+	if(sl_bind_tm!=0 && tmb.t_gett!=0)
328 336
 	{
329 337
 		t = tmb.t_gett();
330 338
 		if(t!= NULL && t!=T_UNDEFINED)