Merge "res_pjsip.c: Make taskprocessor scheduling algorithm pick the shortest queue" into 16

This commit is contained in:
Joshua Colp
2018-11-12 05:38:36 -06:00
committed by Gerrit Code Review

View File

@@ -2792,9 +2792,6 @@
/*! Number of serializers in pool if one not supplied. */ /*! Number of serializers in pool if one not supplied. */
#define SERIALIZER_POOL_SIZE 8 #define SERIALIZER_POOL_SIZE 8
/*! Next serializer pool index to use. */
static int serializer_pool_pos;
/*! Pool of serializers to use if not supplied. */ /*! Pool of serializers to use if not supplied. */
static struct ast_taskprocessor *serializer_pool[SERIALIZER_POOL_SIZE]; static struct ast_taskprocessor *serializer_pool[SERIALIZER_POOL_SIZE];
@@ -4576,22 +4573,20 @@ static int serializer_pool_setup(void)
static struct ast_taskprocessor *serializer_pool_pick(void) static struct ast_taskprocessor *serializer_pool_pick(void)
{ {
struct ast_taskprocessor *serializer; int idx;
int pos = 0;
unsigned int pos; if (!serializer_pool[0]) {
return NULL;
}
/* for (idx = 1; idx < SERIALIZER_POOL_SIZE; ++idx) {
* Pick a serializer to use from the pool. if (ast_taskprocessor_size(serializer_pool[idx]) < ast_taskprocessor_size(serializer_pool[pos])) {
* pos = idx;
* Note: We don't care about any reentrancy behavior }
* when incrementing serializer_pool_pos. If it gets }
* incorrectly incremented it doesn't matter.
*/
pos = serializer_pool_pos++;
pos %= SERIALIZER_POOL_SIZE;
serializer = serializer_pool[pos];
return serializer; return serializer_pool[pos];
} }
int ast_sip_push_task(struct ast_taskprocessor *serializer, int (*sip_task)(void *), void *task_data) int ast_sip_push_task(struct ast_taskprocessor *serializer, int (*sip_task)(void *), void *task_data)