mirror of
				https://github.com/asterisk/asterisk.git
				synced 2025-10-22 20:56:39 +00:00 
			
		
		
		
	taskprocessor: Enable subsystems and overload by subsystem
To prevent one subsystem's taskprocessors from causing others to stall, new capabilities have been added to taskprocessors. * Any taskprocessor name that has a '/' will have the part before the '/' saved as its "subsystem". Examples: "sorcery/acl-0000006a" and "sorcery/aor-00000019" will be grouped to subsystem "sorcery". "pjsip/distributor-00000025" and "pjsip/distributor-00000026" will bn grouped to subsystem "pjsip". Taskprocessors with no '/' have an empty subsystem. * When a taskprocessor enters high-water alert status and it has a non-empty subsystem, the subsystem alert count will be incremented. * When a taskprocessor leaves high-water alert status and it has a non-empty subsystem, the subsystem alert count will be decremented. * A new api ast_taskprocessor_get_subsystem_alert() has been added that returns the number of taskprocessors in alert for the subsystem. * A new CLI command "core show taskprocessor alerted subsystems" has been added. * A new unit test was addded. REMINDER: The taskprocessor code itself doesn't take any action based on high-water alerts or overloading. It's up to taskprocessor users to check and take action themselves. Currently only the pjsip distributor does this. * A new pjsip/global option "taskprocessor_overload_trigger" has been added that allows the user to select the trigger mechanism the distributor uses to pause accepting new requests. "none": Don't pause on any overload condition. "global": Pause on ANY taskprocessor overload (the default and current behavior) "pjsip_only": Pause only on pjsip taskprocessor overloads. * The core pjsip pool was renamed from "SIP" to "pjsip" so it can be properly grouped into the "pjsip" subsystem. * stasis taskprocessor names were changed to "stasis" as the subsystem. * Sorcery core taskprocessor names were changed to "sorcery" to match the object taskprocessors. Change-Id: I8c19068bb2fc26610a9f0b8624bdf577a04fcd56
This commit is contained in:
		| @@ -51,6 +51,7 @@ static unsigned int unidentified_count; | ||||
| static unsigned int unidentified_period; | ||||
| static unsigned int unidentified_prune_interval; | ||||
| static int using_auth_username; | ||||
| static enum ast_sip_taskprocessor_overload_trigger overload_trigger; | ||||
|  | ||||
| struct unidentified_request{ | ||||
| 	struct timeval first_seen; | ||||
| @@ -534,7 +535,10 @@ static pj_bool_t distributor(pjsip_rx_data *rdata) | ||||
| 		ao2_cleanup(dist); | ||||
| 		return PJ_TRUE; | ||||
| 	} else { | ||||
| 		if (ast_taskprocessor_alert_get()) { | ||||
| 		if ((overload_trigger == TASKPROCESSOR_OVERLOAD_TRIGGER_GLOBAL && | ||||
| 			ast_taskprocessor_alert_get()) | ||||
| 			|| (overload_trigger == TASKPROCESSOR_OVERLOAD_TRIGGER_PJSIP_ONLY && | ||||
| 			ast_taskprocessor_get_subsystem_alert("pjsip"))) { | ||||
| 			/* | ||||
| 			 * When taskprocessors get backed up, there is a good chance that | ||||
| 			 * we are being overloaded and need to defer adding new work to | ||||
| @@ -1196,6 +1200,8 @@ static void global_loaded(const char *object_type) | ||||
|  | ||||
| 	ast_sip_get_unidentified_request_thresholds(&unidentified_count, &unidentified_period, &unidentified_prune_interval); | ||||
|  | ||||
| 	overload_trigger = ast_sip_get_taskprocessor_overload_trigger(); | ||||
|  | ||||
| 	/* Clean out the old task, if any */ | ||||
| 	ast_sched_clean_by_callback(prune_context, prune_task, clean_task); | ||||
| 	/* Have to do something with the return value to shut up the stupid compiler. */ | ||||
|   | ||||
		Reference in New Issue
	
	Block a user