Răsfoiți Sursa

dispatcher: renamed field to reflect better the purpose and print in rpc result

Daniel-Constantin Mierla 2 luni în urmă
părinte
comite
deb8405b40

+ 11 - 11
src/modules/dispatcher/dispatch.c

@@ -3408,26 +3408,26 @@ int ds_update_state(sip_msg_t *msg, int group, str *address, int state,
 			}
 
 			if(state & DS_TRYING_DST) {
-				idx->dlist[i].message_count++;
+				idx->dlist[i].probing_count++;
 				LM_DBG("destination did not replied %d times, threshold %d\n",
-						idx->dlist[i].message_count, probing_threshold);
+						idx->dlist[i].probing_count, probing_threshold);
 				/* Destination is not replying.. Increasing failure counter */
 				if((mode == 1)
-						|| (idx->dlist[i].message_count >= probing_threshold)) {
+						|| (idx->dlist[i].probing_count >= probing_threshold)) {
 					/* Destination has too many lost messages.. Bringing it to inactive state */
 					idx->dlist[i].flags &= ~DS_TRYING_DST;
 					idx->dlist[i].flags |= DS_INACTIVE_DST;
-					idx->dlist[i].message_count = 0;
+					idx->dlist[i].probing_count = 0;
 					LM_DBG("deactivate destination, threshold %d reached\n",
 							probing_threshold);
 				}
 			} else {
 				if(!(init_state & DS_TRYING_DST)
 						&& (old_state & DS_INACTIVE_DST)) {
-					idx->dlist[i].message_count++;
+					idx->dlist[i].probing_count++;
 					/* Destination was inactive but it is just replying.. Increasing successful counter */
 					if((mode == 0)
-							&& (idx->dlist[i].message_count
+							&& (idx->dlist[i].probing_count
 									< inactive_threshold)) {
 						/* Destination has not enough successful replies.. Leaving it into inactive state */
 						idx->dlist[i].flags |= DS_INACTIVE_DST;
@@ -3437,16 +3437,16 @@ int ds_update_state(sip_msg_t *msg, int group, str *address, int state,
 						}
 						LM_DBG("destination replied successful %d times, "
 							   "threshold %d\n",
-								idx->dlist[i].message_count,
+								idx->dlist[i].probing_count,
 								inactive_threshold);
 					} else {
 						/* Destination has enough replied messages.. Bringing it to active state */
-						idx->dlist[i].message_count = 0;
+						idx->dlist[i].probing_count = 0;
 						LM_DBG("activate destination, threshold %d reached\n",
 								inactive_threshold);
 					}
 				} else {
-					idx->dlist[i].message_count = 0;
+					idx->dlist[i].probing_count = 0;
 				}
 			}
 
@@ -3710,8 +3710,8 @@ void ds_fprint_set(FILE *fout, ds_set_t *node)
 		else if(node->dlist[j].flags & DS_TRYING_DST) {
 			fprintf(fout, "    Trying");
 			/* print the tries for this host. */
-			if(node->dlist[j].message_count > 0) {
-				fprintf(fout, " (Fail %d/%d)", node->dlist[j].message_count,
+			if(node->dlist[j].probing_count > 0) {
+				fprintf(fout, " (Fail %d/%d)", node->dlist[j].probing_count,
 						probing_threshold);
 			} else {
 				fprintf(fout, "           ");

+ 1 - 1
src/modules/dispatcher/dispatch.h

@@ -251,7 +251,7 @@ typedef struct _ds_dest {
 	struct ip_addr ip_address; 	/*!< IP of the address */
 	unsigned short int port; 	/*!< port of the URI */
 	unsigned short int proto; 	/*!< protocol of the URI */
-	int message_count;
+	int probing_count;
 	struct timeval dnstime;
 	ds_ocdata_t ocdata;	/*!< overload control attributes */
 	struct _ds_dest *next;

+ 3 - 2
src/modules/dispatcher/dispatcher.c

@@ -2054,12 +2054,13 @@ int ds_rpc_print_set(
 				rpc->fault(ctx, 500, "Internal error creating dest struct");
 				return -1;
 			}
-			if(rpc->struct_add(wh, "SSdddSSSSjj", "BODY",
+			if(rpc->struct_add(wh, "SSddddSSSSjj", "BODY",
 					   &(node->dlist[j].attrs.body), "DUID",
 					   (node->dlist[j].attrs.duid.s)
 							   ? &(node->dlist[j].attrs.duid)
 							   : &data,
-					   "MAXLOAD", node->dlist[j].attrs.maxload, "WEIGHT",
+					   "PROBING_COUNT", node->dlist[j].probing_count, "MAXLOAD",
+					   node->dlist[j].attrs.maxload, "WEIGHT",
 					   node->dlist[j].attrs.weight, "RWEIGHT",
 					   node->dlist[j].attrs.rweight, "SOCKET",
 					   (node->dlist[j].attrs.socket.s)