Browse code

- fix when db_url is not set (reported by Borislav Ivandic) - db connection is not needed in workers, just in mi processes

git-svn-id: https://openser.svn.sourceforge.net/svnroot/openser/trunk@2626 689a6050-402a-0410-94f2-e92a70836424

Daniel-Constantin Mierla authored on 21/08/2007 18:50:30
Showing 2 changed files
... ...
@@ -344,6 +344,9 @@ error:
344 344
 
345 345
 int ds_connect_db()
346 346
 {
347
+	if(ds_db_url==0)
348
+		return -1;
349
+
347 350
 	if (ds_db_handle) 
348 351
 	{
349 352
 		LM_CRIT("BUG - db connection found already open\n");
... ...
@@ -293,14 +293,6 @@ static int child_init(int rank)
293 293
 {
294 294
 	
295 295
 	LM_DBG(" #%d / pid <%d>\n", rank, getpid());
296
-	if(rank >0)
297
-	{
298
-		if(ds_connect_db() != 0)
299
-		{	
300
-			LM_ERR("could not connect to database\n");
301
-			return -1;
302
-		}
303
-	}
304 296
 
305 297
 	srand((11+rank)*getpid()*7);
306 298
 
... ...
@@ -309,10 +301,24 @@ static int child_init(int rank)
309 301
 
310 302
 static int mi_child_init()
311 303
 {
312
-	return ds_connect_db();
304
+	
305
+	if(ds_db_url!= NULL)
306
+		return ds_connect_db();
307
+	return 0;
313 308
 
314 309
 }
315 310
 
311
+/**
312
+ * destroy function
313
+ */
314
+void destroy(void)
315
+{
316
+	LM_DBG("destroying module ...\n");
317
+	ds_destroy_list();
318
+	if(ds_db_url)
319
+		ds_disconnect_db();
320
+}
321
+
316 322
 static inline int ds_get_ivalue(struct sip_msg* msg, ds_param_p dp, int *val)
317 323
 {
318 324
 	xl_value_t value;
... ...
@@ -416,17 +422,6 @@ static int w_ds_mark_dst1(struct sip_msg *msg, char *str1, char *str2)
416 422
 		return ds_mark_dst(msg, 1);
417 423
 }
418 424
 
419
-/**
420
- * destroy function
421
- */
422
-void destroy(void)
423
-{
424
-	LM_DBG("destroying module ...\n");
425
-	ds_destroy_list();
426
-	if(ds_db_url)
427
-		ds_disconnect_db();
428
-}
429
-
430 425
 /**
431 426
  *
432 427
  */