Use newly created get_queue_count() in check_query_allowed() to reduce
code duplication