@@ -99,6 +99,9 @@ typedef struct _ds_db_head
99
99
str ping_method ;
100
100
str persistent_state ;
101
101
102
+ str ping_sock ;
103
+ struct socket_info * ping_sock_info ;
104
+
102
105
struct _ds_db_head * next ;
103
106
} ds_db_head_t ;
104
107
@@ -119,6 +122,9 @@ ds_db_head_t default_db_head = {
119
122
{NULL , -1 },
120
123
{"1" , 1 },
121
124
125
+ {NULL , -1 },
126
+ NULL ,
127
+
122
128
NULL
123
129
};
124
130
ds_db_head_t * ds_db_heads = NULL ;
@@ -420,6 +426,7 @@ DEF_GETTER_FUNC(script_attrs_avp);
420
426
DEF_GETTER_FUNC (ping_from );
421
427
DEF_GETTER_FUNC (ping_method );
422
428
DEF_GETTER_FUNC (persistent_state );
429
+ DEF_GETTER_FUNC (ping_sock );
423
430
424
431
static partition_specific_param_t partition_params [] = {
425
432
{str_init ("db_url" ), {NULL , 0 }, GETTER_FUNC (db_url )},
@@ -433,6 +440,7 @@ static partition_specific_param_t partition_params[] = {
433
440
PARTITION_SPECIFIC_PARAM (ping_from , "" ),
434
441
PARTITION_SPECIFIC_PARAM (ping_method , "" ),
435
442
PARTITION_SPECIFIC_PARAM (persistent_state , "1" ),
443
+ PARTITION_SPECIFIC_PARAM (ping_sock , "" ),
436
444
};
437
445
438
446
static const unsigned int partition_param_count = sizeof (partition_params ) /
@@ -483,7 +491,7 @@ static int split_partition_argument(str *arg, str *partition_name)
483
491
arg -> len -= partition_name -> len + 1 ;
484
492
485
493
trim (partition_name );
486
- for (;arg -> s [0 ] == ' ' && arg -> len ; ++ arg -> s , -- arg -> len );
494
+ for (;( arg -> s [0 ] == ' ' || arg -> s [ 0 ] == '\n' ) && arg -> len ; ++ arg -> s , -- arg -> len );
487
495
return 0 ;
488
496
}
489
497
@@ -759,6 +767,20 @@ static int partition_init(ds_db_head_t *db_head, ds_partition_t *partition)
759
767
if (pkg_str_dup (& partition -> ping_method , & db_head -> ping_method ) < 0 )
760
768
LM_ERR ("cannot duplicate ping_method\n" );
761
769
}
770
+
771
+ if (db_head -> ping_sock .s && db_head -> ping_sock .len > 0 ) {
772
+ if (pkg_str_dup (& partition -> ping_sock , & db_head -> ping_sock ) < 0 ) {
773
+ LM_ERR ("cannot duplicate ping_sock\n" );
774
+ return -1 ;
775
+ }
776
+ partition -> ping_sock_info = (struct socket_info * )parse_sock_info (& partition -> ping_sock );
777
+ if (partition -> ping_sock_info == NULL ) {
778
+ LM_ERR ("socket <%.*s> is not local to opensips (we must listen "
779
+ "on it\n" , partition -> ping_sock .len , partition -> ping_sock .s );
780
+ return -1 ;
781
+ }
782
+ }
783
+
762
784
partition -> persistent_state = ds_persistent_state ;
763
785
if (str_strcmp (& db_head -> persistent_state , const_str ("0" )) ||
764
786
str_strcmp (& db_head -> persistent_state , const_str ("no" )) ||
0 commit comments