Browse code

modules_k/rls: core_hash() not used correctly to distribute notifier traffic

- Found and fixed by Hugh Waite @ Crocodile RCS Ltd

Peter Dunkley authored on 11/09/2012 12:06:54
Showing 3 changed files
... ...
@@ -744,9 +744,9 @@ int rls_handle_notify(struct sip_msg* msg, char* c1, char* c2)
744 744
 	query_vals[n_query_cols].nul = 0;
745 745
 	if (dbmode == RLS_DB_ONLY)
746 746
 		query_vals[n_query_cols].val.int_val=
747
-			core_hash(res_id, NULL,
747
+			core_hash(res_id, NULL, 0) %
748 748
 				(waitn_time * rls_notifier_poll_rate
749
-					* rls_notifier_processes) - 1);
749
+					* rls_notifier_processes);
750 750
 	else
751 751
 		query_vals[n_query_cols].val.int_val = UPDATED_TYPE;
752 752
 	n_query_cols++;
... ...
@@ -184,8 +184,8 @@ int delete_expired_subs_rlsdb( void )
184 184
 			LM_ERR("cannot build rls subs did\n");
185 185
 			goto error;
186 186
 		}
187
-		subs.updated = core_hash(&rlsubs_did, NULL,
188
-			(waitn_time * rls_notifier_poll_rate * rls_notifier_processes) - 1);
187
+		subs.updated = core_hash(&rlsubs_did, NULL, 0) %
188
+			(waitn_time * rls_notifier_poll_rate * rls_notifier_processes);
189 189
 
190 190
 		n_query_cols = 0;
191 191
 
... ...
@@ -586,8 +586,8 @@ int rls_handle_subscribe(struct sip_msg* msg, str watcher_user, str watcher_doma
586 586
 		LM_ERR("cannot build rls subs did\n");
587 587
 		goto error;
588 588
 	}
589
-	subs.updated = core_hash(&rlsubs_did, NULL,
590
-		(waitn_time * rls_notifier_poll_rate * rls_notifier_processes) - 1);
589
+	subs.updated = core_hash(&rlsubs_did, NULL, 0) %
590
+		(waitn_time * rls_notifier_poll_rate * rls_notifier_processes);
591 591
 	
592 592
 	if(get_to(msg)->tag_value.s==NULL || get_to(msg)->tag_value.len==0)
593 593
 	{ /* initial Subscribe */