Esempio n. 1
0
void rbtree_delete(rbtree t, void* key, compare_func compare) {
    node child;
    node n = lookup_node(t, key, compare);
    if (n == NULL) return;  /* Key not found, do nothing */
    if (n->left != NULL && n->right != NULL) {
        /* Copy key/value from predecessor and then delete it instead */
        node pred = maximum_node(n->left);
        n->key   = pred->key;
        n->value = pred->value;
        n = pred;
    }

    assert(n->left == NULL || n->right == NULL);
    child = n->right == NULL ? n->left  : n->right;
    if (node_color(n) == BLACK) {
        n->color = node_color(child);
        delete_case1(t, n);
    }
    replace_node(t, n, child);
    if (n->parent == NULL && child != NULL)
        child->color = BLACK;
    free(n);

    verify_properties(t);
}
Esempio n. 2
0
void rbtree_delete(GtkWidget *darea, rbtree t, int key) {
  node n = lookup_node(darea, t, key);
  node child;

  if (n == NULL) return;

  if (n->left != NULL && n->right != NULL) {
    node pred = maximum_node(n->left);

    n->key   = pred->key;
    n = pred;
  }

  child = n->right == NULL ? n->left : n->right;
  if (node_color(n) == BLACK) {
    n->color = node_color(child);

    delete_case1(darea, t, n);
  }

  replace_node(t, n, child);

  if (n->parent == NULL && child != NULL)
    child->color = BLACK;

  free(n);
}
Esempio n. 3
0
void __rbtree_remove(struct rbtree_node* node,struct rbtree* tree)
{
    struct rbtree_node *left = node->left;
    struct rbtree_node* right = node->right;
    struct rbtree_node* child = NULL;
    if(left != NULL && right != NULL )
    {
        struct rbtree_node* next = get_min(right);
        node->key = next->key;
        node->data = next->data;
        node = next;
    }

    assert(node->left == NULL || node->right == NULL);
    child = (node->right == NULL ? node->left : node->right);
    if(get_color(node) == RB_BLACK)
    {
        set_color(get_color(child),node);
        delete_case1(tree,node);
    }
    replace_node(tree,node,child);
    if(node->parent == NULL && child != NULL)//node is root,root should be black
        set_color(RB_BLACK,child);
    free(node);
}
Esempio n. 4
0
 //! Method that inserts the PCFG corresponding to a function call
 void ExtensibleGraph::nest_pcfgs_rec( Node* current, ObjectList<ExtensibleGraph*>* pcfgs, unsigned int& min_id )
 {
     if( !current->is_visited( ) )
     {
         current->set_visited( true );
         if( current->is_exit_node( ) )
             return;
         
         if( current->is_graph_node( ) )
         {
             // Inline inner nodes, if there is any inner function call
             nest_pcfgs_rec( current->get_graph_entry_node( ), pcfgs, min_id );
         }
         else if( current->is_function_call_node( ) )
         {
             // Look for the graph in the list of created pcfgs
             ExtensibleGraph* pcfg = NULL;
             Nodecl::FunctionCall called_func = current->get_statements( )[0].as<Nodecl::FunctionCall>( );
             Symbol called_sym( called_func.get_called( ).get_symbol( ) );
             std::cerr << "Called function: " << called_func.prettyprint( ) << std::endl;
             for( ObjectList<ExtensibleGraph*>::iterator it = pcfgs->begin( ); it != pcfgs->end( ) && pcfg == NULL; ++it )
             {
                 Symbol pcfg_sym( ( *it )->get_function_symbol( ) );
                 if( pcfg_sym.is_valid( ) )
                 {
                     if( called_sym == pcfg_sym )
                     {
                         pcfg = *it;
                     }
                 }
             }
             if( pcfg != NULL )
             {
                 // Copy the graph we want to embed, since we don't want to change the original 
                 ExtensibleGraph* new_nested_graph = pcfg->copy_graph( );
                 
                 // Rename the id of the nodes to avoid having nodes with the same id
                 new_nested_graph->rename_nodes_id( min_id );
                 
                 // Create nodes containing temporary variables with the return values
                 new_nested_graph->store_returns_in_temporary_vars( );
                 
                 // Rename the parameters used in the copied graph with the corresponding arguments used in the call
                 new_nested_graph->propagate_arguments_in_function_graph( called_func.get_arguments( ) );
                 
                 Node* function_code_node = new_nested_graph->get_graph( )->get_graph_entry_node( )->get_children( )[0];
                 replace_node( current, function_code_node );
             }
         }
         
         ObjectList<Node*> children = current->get_children( );
         for( ObjectList<Node*>::iterator it = children.begin( ); it != children.end( ); ++it )
         {
             nest_pcfgs_rec( *it, pcfgs, min_id );
         }
     }
 }
Esempio n. 5
0
/* rotate_right:

              N                L
           +-----+          +-----+
           L     R    ==>  GL     N
         +---+                  +---+
        GL   GR                GR   R
*/
static void rotate_right(ScmTreeCore *tc, Node *n)
{
    Node *l = n->left;
    SCM_ASSERT(l != NULL);
    Node *gr = l->right;

    replace_node(tc, n, l);
    l->right = n;  n->parent = l;
    n->left = gr;  if (gr) gr->parent = n;
}
Esempio n. 6
0
void rotate_right(rbtree t, node n) {
    node L = n->left;
    replace_node(t, n, L);
    n->left = L->right;
    if (L->right != NULL) {
        L->right->parent = n;
    }
    L->right = n;
    n->parent = L;
}
Esempio n. 7
0
void rotate_left(rbtree t, node n) {
    node r = n->right;
    replace_node(t, n, r);
    n->right = r->left;
    if (r->left != NULL) {
        r->left->parent = n;
    }
    r->left = n;
    n->parent = r;
}
Esempio n. 8
0
/* rotate_left:

              N                R
           +-----+          +-----+
           L     R    ==>   N     GR
               +---+      +---+
              GL   GR     L   GL
*/
static void rotate_left(ScmTreeCore *tc, Node *n)
{
    Node *r = n->right;
    SCM_ASSERT(r != NULL);
    Node *gl = r->left;

    replace_node(tc, n, r);
    r->left = n;   n->parent = r;
    n->right = gl; if (gl) gl->parent = n;
}
Esempio n. 9
0
File: rbtree.c Progetto: hgn/ospfd
void rotate_right(struct rbtree* t, struct rbtree_node* n) {
    struct rbtree_node* L = n->left;
    replace_node(t, n, L);
    n->left = L->right;
    if (L->right != NULL) {
        L->right->parent = n;
    }
    L->right = n;
    n->parent = L;
}
Esempio n. 10
0
File: rbtree.c Progetto: hgn/ospfd
void rotate_left(struct rbtree* t, struct rbtree_node* n) {
    struct rbtree_node* r = n->right;
    replace_node(t, n, r);
    n->right = r->left;
    if (r->left != NULL) {
        r->left->parent = n;
    }
    r->left = n;
    n->parent = r;
}
Esempio n. 11
0
void rotate_right(bbst tree, node n){
    node pivot = n->left;
    replace_node(tree, n, pivot);
    n->left = pivot->right;
    if(pivot->right != NULL){
        pivot->right->parent = n;
    }
    pivot->right = n;
    n->parent = pivot;
}
Esempio n. 12
0
static void rotate_left(L_RBTREE *t, node *n) {
    node *r = n->right;
    replace_node(t, n, r);
    n->right = r->left;
    if (r->left != NULL) {
        r->left->parent = n;
    }
    r->left = n;
    n->parent = r;
}
Esempio n. 13
0
static void rotate_right(L_RBTREE *t, node *n) {
    node *L = n->left;
    replace_node(t, n, L);
    n->left = L->right;
    if (L->right != NULL) {
        L->right->parent = n;
    }
    L->right = n;
    n->parent = L;
}
Esempio n. 14
0
void delete_one_child(rb_node* n, rb_tree* tree) {
	/*
	* Precondition: n has at most one non-null child.
	*/
	rb_node* child = is_leaf(n->right, tree) ? n->left : n->right;
	
	replace_node(n, child, tree);
	if (n->color == BLACK) {
		if (child->color == RED)
			child->color = BLACK;
		else
			delete_case1(child, tree);
	}
	free(n);
}
Esempio n. 15
0
void rotate_right(GtkWidget *darea, rbtree t, node n) {
  if (rotation)
    print_right_arrow(darea, n->left->x, n->left->y, 20);

  node L = n->left;
  replace_node(t, n, L);
  n->left = L->right;

  if (L->right != NULL)
    L->right->parent = n;

  L->right = n;
  n->parent = L;

  repair(L);
}
Esempio n. 16
0
void rotate_left(GtkWidget *darea, rbtree t, node n) {
  if (rotation)
    print_left_arrow(darea, n->right->x, n->right->y, 20);

  node R = n->right;
  replace_node(t, n, R);
  n->right = R->left;

  if (R->left != NULL)
    R->left->parent = n;

  R->left = n;
  n->parent = R;

  repair(R);
}
Esempio n. 17
0
File: rbtree.c Progetto: hgn/ospfd
struct rbtree_node *rbtree_delete(struct rbtree* t, void* key)
{
    struct rbtree_node* child;
    struct rbtree_node* n = lookup_node(t, key);
    if (n == NULL) return NULL; /* Key not found, do nothing */
    if (n->left != NULL && n->right != NULL) {
        /* Copy key/data from predecessor and then delete it instead */
        struct rbtree_node* pred = maximum_node(n->left);
        n->key = pred->key;
        n->data = pred->data;
        n = pred;
    }

    assert(n->left == NULL || n->right == NULL);
    child = n->right == NULL ? n->left : n->right;
    if (node_color(n) == BLACK) {
        n->color = node_color(child);
        delete_case1(t, n);
    }
    replace_node(t, n, child);

    return n;
}
Esempio n. 18
0
void bbst_delete(bbst tree, void* key, compare_func compare) {
    node child;
    node n = lookup_node(tree, key, compare);
    if (n == NULL) return;
    if (n->left != NULL && n->right != NULL) {
        /* find the biggest of the lower */
        node predecessor = maximum_node(n->left);
        n->key           = predecessor->key;
        n->value         = predecessor->value;
        n                = predecessor;
    }

    assert(n->left == NULL || n->right == NULL);
    child = n->right == NULL ? n->left : n->right;
    if (node_color(n) == BLACK) {
        n->color = node_color(child);
        delete_case1(tree, n);
    }
    replace_node(tree, n, child);
    if (n->parent == NULL && child != NULL)
        child->color = BLACK;
    free(n);
}
Esempio n. 19
0
/*
 *  l_rbtreeDelete()
 *
 *      Input:  t (rbtree, including root node)
 *              key (delete the node with this key)
 *      Return: void
 */
void
l_rbtreeDelete(L_RBTREE  *t,
               RB_TYPE    key)
{
node  *n, *child;

    PROCNAME("l_rbtreeDelete");

    if (!t) {
        L_ERROR("tree is null\n", procName);
        return;
    }

    n = lookup_node(t, key);
    if (n == NULL) return;  /* Key not found, do nothing */
    if (n->left != NULL && n->right != NULL) {
            /* Copy key/value from predecessor and then delete it instead */
        node *pred = maximum_node(n->left);
        n->key   = pred->key;
        n->value = pred->value;
        n = pred;
    }

        /* n->left == NULL || n->right == NULL */
    child = n->right == NULL ? n->left  : n->right;
    if (node_color(n) == L_BLACK_NODE) {
        n->color = node_color(child);
        delete_case1(t, n);
    }
    replace_node(t, n, child);
    if (n->parent == NULL && child != NULL)  /* root should be black */
        child->color = L_BLACK_NODE;
    LEPT_FREE(n);

    verify_properties(t);
}
Esempio n. 20
0
ptr_rbnode delete_node(ptr_rbnode root, rbtree_element_type_t val, int logging) {
    ptr_rbnode node = find_node(root, val);
    if (node) {
        ptr_rbnode left_max_node = NULL;
        if (node->left->nil == 0 && node->right->nil == 0) {
            left_max_node = find_max_node(node->left);
            node->val = left_max_node->val;
            node = left_max_node;
        }
        ptr_rbnode child = node->right->nil == 1 ? node->left : node->right;
        if (node->color == BLACK) {
            node->color = child->color;
            delete_one_child(node);
        }
        root = replace_node(root, child, node);
        free(node);
        return root;
    }
    else {
        if (logging) printf("%d is not in the tree\n", val);
        return root;
    }

}
Esempio n. 21
0
File: rbtree.c Progetto: nasa/QuIP
static void rb_delete(qrb_tree *tree_p, qrb_node *n_p )
{
	qrb_node *c_p;		// the single non-leaf child
	qrb_node *parent;

	tree_p->node_count --;

	if( tree_p->node_count == 0 ){
		assert( IS_ROOT_NODE(n_p) );
		givbuf(n_p);
		tree_p->root = NULL;
		return;
	}

	if( n_p->left != NULL && n_p->right != NULL ){
//fprintf(stderr,"before calling binary_tree_delete:\n");
//dump_rb_node(n_p);
		n_p = binary_tree_delete(n_p);
//fprintf(stderr,"after calling binary_tree_delete:\n");
//dump_rb_node(n_p);
	} else if( IS_ROOT_NODE(n_p) ){
		// we are deleting a root node with only one child
		if( n_p->left != NULL ){
			set_root_node(tree_p,n_p->left);
		} else {
			set_root_node(tree_p,n_p->right);
		}
		givbuf(n_p);
		return;
	}

	assert( n_p->left == NULL || n_p->right == NULL );

	if( n_p->left != NULL )
		c_p = n_p->left;
	else	c_p = n_p->right;	// may be NULL


	// if c_p is null, then we need to keep a reference to the parent...
	parent=n_p->parent;
	replace_node(tree_p,n_p,c_p);


	if( IS_RED(n_p) ){
		givbuf(n_p);
		return;
	}
	
	// Now we can free n_p
	givbuf(n_p);

	if( IS_RED(c_p) ){
		MAKE_BLACK(c_p);
		return;
	}

	// Now we know the node in question is black and has no red child
	//assert( n_p->left != NULL && n_p->right != NULL );

	// Now we know that both n_p and c_p are black

	rebalance(tree_p,c_p,parent);
}
Esempio n. 22
0
static Ret_t prv_do_generic_cmd_cb(InstanceID_t id,
                                   VoidPtr_t userData,
                                   SmlGenericCmdPtr_t cmdP)
{
    internals_t * internP = (internals_t *)userData;
    SmlStatusPtr_t statusP;
    SmlItemListPtr_t itemCell;

    if (internP->sequence
      && internP->seq_code != OMADM_SYNCML_ERROR_NOT_MODIFIED
      && internP->seq_code != OMADM_SYNCML_ERROR_SUCCESS)
    {
        // do not treat this command
        return SML_ERR_OK;
    }

    if (OMADM_SYNCML_ERROR_AUTHENTICATION_ACCEPTED != internP->srv_auth)
    {
        statusP = create_status(internP, internP->srv_auth, cmdP);

        add_element(internP, (basicElement_t *)statusP);
        return SML_ERR_OK;
    }

    itemCell = cmdP->itemList;
    while (itemCell)
    {
        int code;

        if (internP->sequence && internP->seq_code == OMADM_SYNCML_ERROR_NOT_MODIFIED)
        {
            code = OMADM_SYNCML_ERROR_NOT_EXECUTED;
        }
        else
        {
            switch (cmdP->elementType)
            {
            case SML_PE_ADD:
                code = add_node(internP, itemCell->item);
                break;
            case SML_PE_COPY:
                code = copy_node(internP, itemCell->item);
                break;
            case SML_PE_DELETE:
                code = delete_node(internP, itemCell->item);
                break;
            case SML_PE_REPLACE:
                 code = replace_node(internP, itemCell->item);
                 break;
            default:
                code = OMADM_SYNCML_ERROR_COMMAND_NOT_IMPLEMENTED;
            }
        }
        statusP = create_status(internP, code, cmdP);
        add_target_ref(statusP, itemCell->item->target);
        add_element(internP, (basicElement_t *)statusP);

        itemCell = itemCell->next;
    }

    return SML_ERR_OK;
}
Esempio n. 23
0
/* deletes a node TODIE who has at most one child, CHILD.
   Note that CHILD can be NULL (empty BLACK node) */
static void delete_node1(ScmTreeCore *tc, Node *todie, Node *child)
{
    Node *parent = todie->parent;

    replace_node(tc, todie, child);
    if (REDP(todie)) { DELETE_CASE("1"); return; }
    if (REDP(child)) { DELETE_CASE("2"); child->color = BLACK; return; }

  recur:
    /* At this point, child is BLACK. */
    if (parent == NULL) { DELETE_CASE("3"); return; }
    Node *sibling = SIBLING2(parent, child);
    /* sibling can't be NULL, since it would break the invariance of
       consistent # of black nodes for every path. */
    SCM_ASSERT(sibling != NULL);

    if (REDP(sibling)) {
        parent->color = RED;
        sibling->color = BLACK;
        if (LEFTP2(parent, child)) {
            rotate_left(tc, parent);
            sibling = SIBLING2(parent, child);
            DELETE_CASE("4a");
        } else {
            rotate_right(tc, parent);
            sibling = SIBLING2(parent, child);
            DELETE_CASE("4b");
        }
    }

    /* At this point, sibling is BLACK */
    if (BLACKP(parent) && BLACKP(sibling->left) && BLACKP(sibling->right)) {
        sibling->color = RED;

        child = parent;
        parent = parent->parent;
        DELETE_CASE("5");
        goto recur;
    }
    if (REDP(parent) && BLACKP(sibling->left) && BLACKP(sibling->right)) {
        parent->color = BLACK;
        sibling->color = RED;
        DELETE_CASE("6");
        return;
    }
    if (LEFTP2(parent, child)) {
        if (REDP(sibling->left) && BLACKP(sibling->right)) {
            sibling->color = RED;
            sibling->left->color = BLACK;
            rotate_right(tc, sibling);
            sibling = SIBLING2(parent, child);
            DELETE_CASE("7a");
        }
    } else {              /* RIGHTP(child) */
        if (BLACKP(sibling->left) && REDP(sibling->right)) {
            sibling->color = RED;
            sibling->right->color = BLACK;
            rotate_left(tc, sibling);
            sibling = SIBLING2(parent, child);
            DELETE_CASE("7b");
        }
    }
    sibling->color = parent->color;
    parent->color = BLACK;
    if (LEFTP2(parent, child)) {
        sibling->right->color = BLACK;
        rotate_left(tc, parent);
        DELETE_CASE("8a");
    } else {
        sibling->left->color = BLACK;
        rotate_right(tc, parent);
        DELETE_CASE("8b");
    }
}
Esempio n. 24
0
void RBDeleteNode(RBTree* tree, RBNode* node){

  RBNode* child = node->left == tree->nil ? node->right : node->left;

  //node is root, and have no child at all
  if(child == tree->nil && node->isBlack){
    free(node);
    tree->root = tree->nil;
    return;
  }

  replace_node(tree, node, child);

  //if node is red, replace and free will just work
  if(node->isBlack){
    if(!child->isBlack){
      child->isBlack = true;
      free(node);  
      if(node == tree->root){
        tree->root = child;
      }
      return;
    }else{
      //node will never be root, because child is black, and exactly one child exists
      //so node->parent will never be tree->nil
      RBNode* sibling = node == node->parent->left ? node->parent->right : node->parent->left;
      if(!sibling->isBlack){
        node->parent->isBlack = false;
        sibling->isBlack = true;
        if(node == node->parent->left){
          leftRotate(tree, node->parent);
        }else{
          rightRotate(tree, node->parent);
        }
      }else{
        if(node->parent->isBlack && sibling->left->isBlack && sibling->right->isBlack){
          sibling->isBlack = false;
          RBDeleteNode(tree, node->parent);
        }else if(!node->parent->isBlack && sibling->left->isBlack && sibling->right->isBlack){
          sibling->isBlack = false;
          node->parent->isBlack = true;
        }else if(node == node->parent->left && sibling->right->isBlack && !sibling->left->isBlack){
          sibling->isBlack = false;
          sibling->left->isBlack = true;
          rightRotate(tree, sibling);
        }else if(node == node->parent->right && sibling->left->isBlack && !sibling->right->isBlack){
          sibling->isBlack = false;
          sibling->right->isBlack = true;
          leftRotate(tree, sibling);
        }else{
          sibling->isBlack = node->parent->isBlack;
          node->parent->isBlack = true;
          if(node == node->parent->left){
            sibling->right->isBlack = true;
            leftRotate(tree, node->parent);
          }else{
            sibling->left->isBlack = true;
            rightRotate(tree, node->parent);
          }
        }
      }
    }
  }

  free(node);
}
Esempio n. 25
0
 //! <b>Requires</b>: node_to_be_replaced must be inserted in a tree
 //!   and new_node must not be inserted in a tree.
 //! 
 //! <b>Effects</b>: Replaces node_to_be_replaced in its position in the
 //!   tree with new_node. The tree does not need to be rebalanced
 //! 
 //! <b>Complexity</b>: Logarithmic. 
 //! 
 //! <b>Throws</b>: Nothing.
 //! 
 //! <b>Note</b>: This function will break container ordering invariants if
 //!   new_node is not equivalent to node_to_be_replaced according to the
 //!   ordering rules. This function is faster than erasing and inserting
 //!   the node, since no rebalancing and comparison is needed.
 //!
 //!Experimental function
 static void replace_node(node_ptr node_to_be_replaced, node_ptr new_node)
 {
    if(node_to_be_replaced == new_node)
       return;
    replace_node(node_to_be_replaced, tree_algorithms::get_header(node_to_be_replaced), new_node);
 }
Esempio n. 26
0
File: msg.c Progetto: artpol84/slurm
static void _proc_msg(int new_fd, char *msg, slurm_addr_t cli_addr)
{
	/* Locks: Read job and node data */
	slurmctld_lock_t job_read_lock = {
		NO_LOCK, READ_LOCK, READ_LOCK, NO_LOCK, NO_LOCK };
	/* Locks: Write job */
	slurmctld_lock_t job_write_lock = {
		NO_LOCK, WRITE_LOCK, NO_LOCK, NO_LOCK, NO_LOCK };
	/* Locks: Write job, write node, read partition */
	slurmctld_lock_t job_write_lock2 = {
		NO_LOCK, WRITE_LOCK, WRITE_LOCK, READ_LOCK, READ_LOCK };
	/* Locks: Write node data */
	slurmctld_lock_t node_write_lock = {
		NO_LOCK, NO_LOCK, WRITE_LOCK, NO_LOCK, READ_LOCK };
	char *cmd_ptr, *resp = NULL, *msg_decrypted = NULL;
	uid_t cmd_uid;
	uint32_t protocol_version = 0;

	if (!msg) {
		info("slurmctld/nonstop: NULL message received");
		resp = xstrdup("Error:\"NULL message received\"");
		goto send_resp;
	}

	msg_decrypted = _decrypt(msg, &cmd_uid);
	if (!msg_decrypted) {
		info("slurmctld/nonstop: Message decrypt failure");
		resp = xstrdup("Error:\"Message decrypt failure\"");
		goto send_resp;
	}
	if (nonstop_debug > 0)
		info("slurmctld/nonstop: msg decrypted:%s", msg_decrypted);
	cmd_ptr = msg_decrypted;

	/* 123456789012345678901234567890 */
	if (xstrncmp(cmd_ptr, version_string, 13) == 0) {
		cmd_ptr = strchr(cmd_ptr + 13, ':');
		if (cmd_ptr) {
			cmd_ptr++;
			protocol_version = SLURM_PROTOCOL_VERSION;
		}
	}

	if (protocol_version == 0) {
		info("slurmctld/nonstop: Message version invalid");
		resp = xstrdup("Error:\"Message version invalid\"");
		goto send_resp;
	}
	if (xstrncmp(cmd_ptr, "CALLBACK:JOBID:", 15) == 0) {
		resp = register_callback(cmd_ptr, cmd_uid, cli_addr,
					 protocol_version);
	} else if (xstrncmp(cmd_ptr, "DRAIN:NODES:", 12) == 0) {
		lock_slurmctld(node_write_lock);
		resp = drain_nodes_user(cmd_ptr, cmd_uid, protocol_version);
		unlock_slurmctld(node_write_lock);
	} else if (xstrncmp(cmd_ptr, "DROP_NODE:JOBID:", 15) == 0) {
		lock_slurmctld(job_write_lock2);
		resp = drop_node(cmd_ptr, cmd_uid, protocol_version);
		unlock_slurmctld(job_write_lock2);
	} else if (xstrncmp(cmd_ptr, "GET_FAIL_NODES:JOBID:", 21) == 0) {
		lock_slurmctld(job_read_lock);
		resp = fail_nodes(cmd_ptr, cmd_uid, protocol_version);
		unlock_slurmctld(job_read_lock);
	} else if (xstrncmp(cmd_ptr, "REPLACE_NODE:JOBID:", 19) == 0) {
		lock_slurmctld(job_write_lock2);
		resp = replace_node(cmd_ptr, cmd_uid, protocol_version);
		unlock_slurmctld(job_write_lock2);
	} else if (xstrncmp(cmd_ptr, "SHOW_CONFIG", 11) == 0) {
		resp = show_config(cmd_ptr, cmd_uid, protocol_version);
	} else if (xstrncmp(cmd_ptr, "SHOW_JOB:JOBID:", 15) == 0) {
		resp = show_job(cmd_ptr, cmd_uid, protocol_version);
	} else if (xstrncmp(cmd_ptr, "TIME_INCR:JOBID:", 16) == 0) {
		lock_slurmctld(job_write_lock);
		resp = time_incr(cmd_ptr, cmd_uid, protocol_version);
		unlock_slurmctld(job_write_lock);
	} else {
		info("slurmctld/nonstop: Invalid command: %s", cmd_ptr);
		xstrfmtcat(resp, "%s ECMD", SLURM_VERSION_STRING);
	}

 send_resp:
	if (nonstop_debug > 0)
		info("slurmctld/nonstop: msg send:%s", resp);
	_send_reply(new_fd, resp);
	xfree(resp);
	if (msg_decrypted)
		free(msg_decrypted);
	return;
}