Browse code

dispatcher: update state if sending keepalive OPTIONS fails

- it can be due to DNS resolving failure, therefore needs to be counted
for making it inactive, otherwise keeps failing and writting errors

(cherry picked from commit 6c77c86ab8fdec51293f0d850b9b9771d6266816)

Daniel-Constantin Mierla authored on 15/07/2020 15:59:51
Showing 1 changed files
... ...
@@ -3365,6 +3365,8 @@ void ds_ping_set(ds_set_t *node)
3365 3365
 	int i, j;
3366 3366
 	str ping_from;
3367 3367
 	str obproxy;
3368
+	int state;
3369
+	ds_rctx_t rctx;
3368 3370
 
3369 3371
 	if(!node)
3370 3372
 		return;
... ...
@@ -3427,8 +3429,25 @@ void ds_ping_set(ds_set_t *node)
3427 3429
 			if(tmb.t_request(&uac_r, &node->dlist[j].uri, &node->dlist[j].uri,
3428 3430
 					   &ping_from, &obproxy)
3429 3431
 					< 0) {
3430
-				LM_ERR("unable to ping [%.*s]\n", node->dlist[j].uri.len,
3431
-						node->dlist[j].uri.s);
3432
+				LM_ERR("unable to ping [%.*s] in group [%d]\n",
3433
+						node->dlist[j].uri.len, node->dlist[j].uri.s,
3434
+						node->id);
3435
+				state = DS_TRYING_DST;
3436
+				if(ds_probing_mode != DS_PROBE_NONE) {
3437
+					state |= DS_PROBING_DST;
3438
+				}
3439
+				memset(&rctx, 0, sizeof(ds_rctx_t));
3440
+				rctx.code = 500;
3441
+				rctx.reason.s = "Sending keepalive failed";
3442
+				rctx.reason.len = 24;
3443
+				/* check if meantime someone disabled the target via RPC */
3444
+				if(!(node->dlist[j].flags & DS_DISABLED_DST)
3445
+						&& ds_update_state(NULL, node->id, &node->dlist[j].uri,
3446
+								state, &rctx) != 0) {
3447
+					LM_ERR("Setting the probing state failed (%.*s, group %d)\n",
3448
+							node->dlist[j].uri.len, node->dlist[j].uri.s,
3449
+							node->id);
3450
+				}
3432 3451
 			}
3433 3452
 		}
3434 3453
 	}