Ejemplo n.º 1
0
void end_child_serv(Server * svrptr)
{
  kill(svrptr->child_pid_list_root->pid, SIGUSR1);
  waitpid(-1, NULL, 0);
  del_node(svrptr->child_pid_list_root);
  svrptr->num_child -= 1;
}
CFSystemSrvr* CFSystemSrvr_list::ins_node( const FS_Receiveinfo_Type *receiveInfo, const CEE_handle_def* call_id )
{
	CFSystemSrvr* cnode;
	CFSystemSrvr* pnode;
	CFSystemSrvr* nnode;

	del_node(receiveInfo);

	cnode = list;
	pnode = list;

	while(cnode!=NULL )
	{
		pnode=cnode;
		cnode=cnode->next;
	}
	if((nnode = (CFSystemSrvr*) new CFSystemSrvr(receiveInfo))!=NULL)
	{
		nnode->next = cnode;
		if(pnode!=NULL) 
			pnode->next = nnode;
		else
			list = nnode;
		memcpy(&nnode->m_call_id, call_id, sizeof(CEE_handle_def));
	}
	return nnode;
}
Ejemplo n.º 3
0
static void *sayingThread(void *arg)
{
    int udpSock = getUdpSock();
    while(1)
    {
        sleep(1);
        LOCK_SAYING(
            if(sayingList != NULL)
    {
        PMSGPACK msg = sayingList;
        while(msg)
            {
                if((int)msg->priv < 4)
                {
                    sendMsg(udpSock, msg);
                    msg->priv = (void*)((int)(msg->priv) + 1);
                }
                else
                {
                    printf("\nmsg send timeout!\n");
                    del_node(&sayingList, msg);
                    delUser(&(msg->address), NULL, NULL);
                    if(sayingList == NULL)
                        break;
                }
                msg = msg->next;
            }
        }
        );
    }
Ejemplo n.º 4
0
RVAPI annexEStatus RVCALLCONV
annexECloseNode(
    IN  HANNEXE                 hAnnexE,
    IN  UINT32                  ip,
    IN  UINT16                  port
) {
    tAnnexE *pAnnexE = AsAnnexE( hAnnexE );
    tNode   *pNode;

    if (!pAnnexE)
        return annexEStatusBadParameter;

    pNode = get_node( pAnnexE, ip, port );
    if (pNode == NULL) {
        msaPrintFormat( pAnnexE->msaType, "annexECloseNode() - no such Remote Host(%08x:%i)!",
                   ip, port);
        return annexEStatusBadParameter;
    }
    else {
        msaPrintFormat( pNode->pAnnexE->msaType, "Remote Host(%08x:%i) closed!", pNode->RemoteHost.nIP, pNode->RemoteHost.nPort );
        del_node( pNode );
    }

    return annexEStatusNormal;
}
Ejemplo n.º 5
0
void destroy(ServiceList_Node * root)
{
  while(root!=NULL)
    {
      del_node(root);
    }
}
Ejemplo n.º 6
0
void
ack_received( tNode* pNode ) {
    tPDU* pPDU = pNode->pWaitingForAckPDU;
    pNode->pWaitingForAckPDU = NULL;

    /* notify user that the node is no longer waiting for ack */
    if (pNode->pAnnexE->events.AnnexEEvWriteable != NULL) {
        pNode->nRef++; /* protect node */
        pNode->pAnnexE->events.AnnexEEvWriteable(
                AsHANNEXE( pNode->pAnnexE ),
                pNode->pAnnexE->hAppAnnexE,
                pNode->RemoteHost.nIP,
                pNode->RemoteHost.nPort
            );
        if (pNode->nRef == 1) {
            del_node( pNode );
        }
        pNode->nRef--; /* unprotect node */
    }
    /* start IMA timer  */
    pNode->nRetry = 0;
    start_retransmit_or_ima_timer( pNode );
    /* free PDU! */
    free_pdu( pNode->pAnnexE, pPDU );
}
CTCPIPSystemSrvr* CTCPIPSystemSrvr_list::ins_node( short nSocketFnum )
{
	SRVRTRACE_ENTER(FILE_TSS+3);

	CTCPIPSystemSrvr* cnode = list;
	CTCPIPSystemSrvr* pnode = list;
	CTCPIPSystemSrvr* nnode;

	del_node(nSocketFnum);

	while(cnode!=NULL )
	{
		pnode=cnode;
		cnode=cnode->next;
	}
	if((nnode = (CTCPIPSystemSrvr*) new CTCPIPSystemSrvr(nSocketFnum))!=NULL)
	{
		nnode->next = cnode;
		if(pnode!=NULL) 
			pnode->next = nnode;
		else
			list = nnode;
	}
	SRVRTRACE_EXIT(FILE_TSS+3);
	return nnode;
}
Ejemplo n.º 8
0
void update_jobs_status()
{
	int status, pid;
	list_node_t *n, *p;
	for(;;)
	{
		/* check all background jobs status to delete from list */
		pid = waitpid(-1, &status, WUNTRACED|WNOHANG);
		/* update job status here */
		if( set_job_status(pid, status) < 0) {
			break; /* no background jobs */
		}
	}
	/* delete all jobs terminated */
	for (n = jobs->first; n; n = n->next)
	{
		if (n && n->value) {
			if(n->value->status == 1) {
				printf("Process %d terminated\n", n->value->pid);
				p = n->previous;
				del_node(jobs, n);
				n = p;
				if(!n) {
					break;
				}
			}
		}
	}
}
Ejemplo n.º 9
0
int MoveQ::deleteIf(int (*f)(const Move *), int del)
{
  MoveQNode *s, *t;
  int count;

  count = 0;
  if (!isEmpty()) {
    while (head && f(head->move)) {
      count++;
      del_head_node(head, del);
    }
    s = head;
    if (s) {
      t = s->next;
      while (t && f(t->move)) {
	count++;
	del_node(s, t, del);
	t = s->next;
      }
    }
    if (head == 0)
      tail = 0;
  }
  return count;
}
Ejemplo n.º 10
0
int main(int argc,char *argv[])
{
	char word[20];
	init_rbtree();
	HEADER=NIL;
	while(getword(word,20)!= EOF)
	{
		insert_node(word);
	}
	show_rbtree(HEADER);
	/*rbnode *p=insert_node("wang");
	rbnode *s=insert_node("zhu");
	left_rotate(HEADER,HEADER);
	printf("%s\n",HEADER->word);
	show_rbtree(HEADER);
	right_rotate(HEADER,HEADER);
	show_rbtree(HEADER);
	printf("%s\n",HEADER->word);
	*/
	rbnode *p = find_node(HEADER,"a");
	if(p == NIL)
	{
		printf("can't find\n");
		return -1;
	}
	del_node(HEADER,p);
	show_rbtree(HEADER);

}
Ejemplo n.º 11
0
Archivo: ini.c Proyecto: chengs/UEFI
void ini_delItem(LPINISECTION iniSection, LPINIITEM item)
{
	free(item->name);
	free(item->value);
	del_node((void**)&(iniSection->first_item), (void**)&(iniSection->last_item), item);
	free(item);
	iniSection->itemCount--;
}
Ejemplo n.º 12
0
SL_API void* sl_memory_renew_(void *p, sl_i sz, SL_DEBUG_FILE_INFO_PARAM)
{
    del_node(p);
    p = slc_realloc(p, sz);
    add_node(p, sz, file, func, line);

    return p;
}
Ejemplo n.º 13
0
void del_node_rec(bintree_node* n, bit_flag del_flags)
{
	if (!n) return;
	
	del_node_rec(n->left,del_flags);
	del_node_rec(n->right,del_flags);
	
	del_node(n,del_flags);
}
Ejemplo n.º 14
0
int main(void)
{
    node_t *head = NULL;

    head = create(head, 5);
    head = del_node(head);
    show_destroy(head);
    return 0;
}
Ejemplo n.º 15
0
void del_list(struct list * _list)
{
	struct node* cur = _list->head_node->next;
	for (; cur != _list->head_node; cur = cur->next)
		del_node(cur);
	
	free(_list->head_node);
	free(_list);
}
Ejemplo n.º 16
0
/* Returns the head of the bianry tree - Hibbard deletion  */
struct node *del_node(struct node *head, int value)
{
    struct node *curr = NULL;
    struct node *replace = NULL;

    if(head == NULL) return NULL;

    curr = head;

    if(value < curr->value && curr->left) {
        curr->left = del_node(curr->left, value);
    } else if(value > curr->value && curr->right) {
        curr->right = del_node(curr->right, value);
    } else {
        /* found the exact node*/
        if(curr->left == NULL)  {
            free(curr);
            return  curr->right;
        }

        if(curr->right == NULL)  {
            free(curr);
            return  curr->left;
        }

        /*  1: get_min from curr's right, this is the repalcement node so save ptr
         *  2: del the that from the location not from mremory
         *  3: update it's children and its currents location
         *  
         *  Eg: To delete 9 ->  repalce with node 11 
         *  and update node 11 left and right
         */
        replace = get_min(curr->right);
        delete_min(curr->right, FALSE);
        replace->right = curr->right;
        replace->left = curr->left;
        free(curr);

    }

    head->count = get_size(head->left) + get_size(head->right) + 1;
    return replace;
}
Ejemplo n.º 17
0
/**
 * del_nodes
 *
 * @param op
 * @param n
 */
static void
del_nodes(unsigned int *op, unsigned int n)
{
    unsigned int i, phandle;

    for (i = 0; i < n; i++) {
        phandle = *op++;
        say(DEBUG, "Delete node with phandle %8.8x\n", phandle);
        del_node(phandle);
    }
}
Ejemplo n.º 18
0
int yadb_delete(char* key) {
	int ret = 0;
	
	node_t* node = find_node(yadb(), key);
	
	if (node) {
		del_node(yadb(), node);
		ret = 1;
	}
	
	return ret;
}
Ejemplo n.º 19
0
void del_node(struct ip_node *node)
{
	struct ip_node *foo, *bar;

	foo = node->children;
	while (foo){
		bar = foo;
		foo = foo->next;
		del_node(bar);
	}

	ip_free(node);
}
Ejemplo n.º 20
0
Archivo: ini.c Proyecto: chengs/UEFI
void ini_delSection(LPINIFILE iniFile, LPINISECTION sec)
{
	LPINIITEM item = sec->first_item;
	free(sec->name);
	while(item)
	{
		LPINIITEM tmp = item->next;
		ini_delItem(sec, item);
		item = tmp;
	}
	del_node((void**)&(iniFile->first_section), (void**)&(iniFile->last_section), sec);
	free(sec);
}
Ejemplo n.º 21
0
void
EvRead( int socketId, liEvents event, int error, void* context ) {
    tAnnexE*    pAnnexE = (tAnnexE*)context;
    tNode*      pNode;

    error = error;
    event = event;
    socketId = socketId;

    if ((pAnnexE->pRecvPDU->nSize = liUdpRecv(
                pAnnexE->sock,
                &pAnnexE->pRecvPDU->PDU[0],
                pAnnexE->pRecvPDU->nMaxSize,
                &pAnnexE->pRecvPDU->nIP,
                &pAnnexE->pRecvPDU->nPort
                )) > 0) {

        /* check AnnexE PDU header! */
        if ((pAnnexE->pRecvPDU->nSize <= sizeof_IAnnexEHeader) ||
            (AEHGet_VER( pAnnexE->pRecvPDU->PDU ) != 0) ||
            (AEHGet_RES( pAnnexE->pRecvPDU->PDU ) != 0)) {

            /* reject!  */
            msaPrintFormat( pAnnexE->msaType, "(incoming PDU) bad header, rejected!" );
            return;
        }

        /* search for node  */
        pNode = get_node( pAnnexE, pAnnexE->pRecvPDU->nIP, pAnnexE->pRecvPDU->nPort );

        if (pNode == NULL) {
            pNode = add_node( pAnnexE, pAnnexE->pRecvPDU->nIP, pAnnexE->pRecvPDU->nPort );

            if (pNode == NULL) {
                /* no free resources!
                 reject! */
                msaPrintFormat( pAnnexE->msaType, "(incoming PDU) no free resources, rejected!" );
                return;
            }
        }

        pNode->nRef++; /* protect node  */
        process_pdu( pNode, pAnnexE->pRecvPDU );
        if (pNode->nRef == 1) {
            del_node( pNode );
        }
        else
            pNode->nRef--; /* unprotect node */
    }
}
Ejemplo n.º 22
0
void
remote_host_is_dead( tNode* pNode ) {
    msaPrintFormat( pNode->pAnnexE->msaType, "Remote Host(%08x:%i) is dead!", pNode->RemoteHost.nIP, pNode->RemoteHost.nPort );
    if (pNode->pAnnexE->events.AnnexEEvConnectionBroken != NULL) {
        pNode->pAnnexE->events.AnnexEEvConnectionBroken(
                AsHANNEXE( pNode->pAnnexE ),
                pNode->pAnnexE->hAppAnnexE,
                pNode->RemoteHost.nIP,
                pNode->RemoteHost.nPort
            );
    }
    else
        del_node( pNode );
}
Ejemplo n.º 23
0
void *		del_node_as(t_list ** list, bool (*match_node)(void *))
{
  if ((*list))
    {
      (*list)->cur = (*list)->begin;
      while ((*list)->cur)
	{
	  if (match_node((*list)->cur->data))
	    return (del_node(list, ((*list)->cur)));
	  (*list)->cur = (*list)->cur->next;
	}
    }
  return (NULL);
}
Ejemplo n.º 24
0
void remove_node(struct ip_node *root, struct ip_node *node)
{
	if (root==node || !node || !root)
		return;

	if (node->prev->children==node)
		/* it's the head of the list! */
		node->prev->children = node->next;
	else
		/* it's somewhere in the list */
		node->prev->next = node->next;
	if (node->next) node->next->prev = node->prev;
	node->next = node->prev = 0;

	del_node(node);
}
Ejemplo n.º 25
0
void release_list (list_t *list)
{
  list_node_t *p;

  fatal (!list->del, "Don't know how to free nodes.");

  /* Free all nodes. */
  p = list->first;
  while (p)
    {
      del_node (list, p);
      p = p->next;
    }

  free (list);
  
}
Ejemplo n.º 26
0
void
unblock_res_blocked_nodes( tAnnexE* pAnnexE ) {
    PLIST_ENTRY last;
    tNode*      lastPNode;
    BOOL        finished = FALSE;

    if (pAnnexE->State != RUNNING)
        return;

    last = GetLastList(&pAnnexE->ResBlockedNodeList);
    lastPNode = CONTAINING_RECORD( last, tNode, lPendLink );

    while ((!IsListEmpty( &pAnnexE->FreePDUList )) &&
           (!IsListEmpty( &pAnnexE->ResBlockedNodeList )) &&
           (!finished)) {

        tNode*      pNode;

        PLIST_ENTRY plink = RemoveHeadList( &pAnnexE->ResBlockedNodeList );
        pNode = CONTAINING_RECORD( plink, tNode, lPendLink );

        if (pAnnexE->events.AnnexEEvWriteable != NULL) {
            pNode->nRef++; /* protect node */
            pAnnexE->events.AnnexEEvWriteable(
                    AsHANNEXE( pNode->pAnnexE ),
                    pNode->pAnnexE->hAppAnnexE,
                    pNode->RemoteHost.nIP,
                    pNode->RemoteHost.nPort
                );
            if (pNode->nRef == 1) {
                del_node( pNode );
                continue;
            }
            pNode->nRef--; /* unprotect node */
        }

        if (pNode == lastPNode)
            finished = TRUE;
    }
}
Ejemplo n.º 27
0
int main(int argc, char const *argv[])
{   
    struct node *temp = NULL;
    struct node *head = NULL;
    head = add_node(head, 5);
    add_node(head, 3);
    add_node(head, 9);
    add_node(head, 3);
    printf("Size %d\n", get_size(head));
    add_node(head, 7);
    add_node(head, 1);
    add_node(head, 4);
    add_node(head, 9);
    add_node(head, 13);
    add_node(head, 2);
    add_node(head, 0);
    //delete_min(head, TRUE);
    temp = add_node(head, 11);
    temp = add_node(head, 15);

    temp = find_node(head, 6);
    if(temp) printf("found %d\n", temp->value);
    temp = find_node(head, 7);
    if(temp) printf("found %d\n", temp->value);

    printf("Size %d\n", get_size(head));

    printf("print inorder\n"); print_inorder(head); printf("\n");
    printf("print pre_order\n"); print_pre_order(head); printf("\n");
    printf("print post_order\n"); print_post_order(head); printf("\n");

    printf("height %d\n", get_height(head));

    del_node(head, 9);
    printf("print inorder\n"); print_inorder(head); printf("\n");
    
    bfs(head);
    return 0;
}
Ejemplo n.º 28
0
void main()
 {
    struct node *root=NULL;
	int n,ch;

	while(ch!=5)
	{
		system("cls");
		printf("\n1.Add Node\n2.Del Node\n3.Search\n4.Display\n5.Exit");
		printf("\nEnter choice: ");
		scanf("%d",&ch);
		switch(ch)
		{
			case 1:
				printf("Enter the element:- \n");
				scanf("%d",&n);
				add_node(&root,n);
				break;
			case 2:
				printf("Enter node data:- \n");
				scanf("%d",&n);
				del_node(&root,n);
				break;
			case 3:
				printf("Enter the element:- \n");
				scanf("%d",&n);
				search_node(root,n);
				getch();
				break;
			case 4:
				inorder(root);
				getch();
				break;
			case 5:
				break;
		}
	}
 }
Ejemplo n.º 29
0
int
dispatch_op(json_t *jmsg)
{
	char	*action;
	int	 ret = 0;
/*
	dump = json_dumps(jmsg, 0);
	jlog(L_DEBUG, "jmsg: %s", dump);
	free(dump);
*/
	if (json_unpack(jmsg, "{s:s}", "action", &action) == -1)
		return -1;

	if (strcmp(action, "listall-network") == 0) {
		if ((ret = listall_network(jmsg)) == 0) {
			/* all network are now fetched */
			if (cfg->ctrl_initialized == 0) {
				jlog(L_DEBUG, "networks initalized");
				ret = query_list_node();
			}
		}
	} else if (strcmp(action, "listall-node") == 0) {
		if ((ret = listall_node(jmsg)) == 0) {
			if (cfg->ctrl_initialized == 0) {
				cfg->ctrl_initialized = 1;
				jlog(L_DEBUG, "nodes initialized");
			}
		}
	} else if (strcmp(action, "provisioning") == 0) {
		ret = provisioning(jmsg);
	} else if (strcmp(action, "del-network") == 0) {
		ret = del_network(jmsg);
	} else if (strcmp(action, "del-node") == 0) {
		ret = del_node(jmsg);
	}

	return ret;
}
Ejemplo n.º 30
0
CTCPIPSystemSrvr* CTCPIPSystemSrvr_list::ins_node( const CEE_handle_def* call_id )
{
	CTCPIPSystemSrvr* cnode = list;
	CTCPIPSystemSrvr* pnode = list;
	CTCPIPSystemSrvr* nnode;

	del_node(call_id);

	while(cnode!=NULL )
	{
		pnode=cnode;
		cnode=cnode->next;
	}
	if((nnode = (CTCPIPSystemSrvr*) new CTCPIPSystemSrvr(call_id))!=NULL)
	{
		nnode->next = cnode;
		if(pnode!=NULL) 
			pnode->next = nnode;
		else
			list = nnode;
	}
	return nnode;
}