Custom function saves post twice (creates two revisions)

I have a custom function on my theme that gets all posts that are publish, assigns a number, saves that number to a custom and then changes the permalink to the number that's been saved in a custom field.

My problem is that when I save a post, it saves it twice and creates two revisions and all posts saved before get revised as well. (For example: if I have five posts, the first post will have 10 revisions).

Here's my code so far:

function updateNumbers( $post_id ){
    global $pagenow;
    if ($pagenow == 'post.php' &&  'post' == get_post_type()) {
        global $wpdb;
        $querystr = "SELECT $wpdb->posts.* FROM $wpdb->posts WHERE
        $wpdb->posts.post_status = 'publish' AND $wpdb->posts.post_type = 'post' ";
        $pageposts = $wpdb->get_results($querystr, OBJECT);
        $counts = 0 ;
        if ($pageposts):
        foreach ($pageposts as $post):
        $counts++;
        add_post_meta($post->ID, 'incr_number', $counts, true);
        remove_action('save_post', 'updateNumbers');
        wp_update_post(array('ID' => $post->ID,'post_name' => get_post_meta($post->ID,'incr_number', true)));
        endforeach;
        endif;
    }}
add_action('save_post', 'updateNumbers');

Thanks.