コード例 #1
0
int 
check_dependency (command_t cmd, outfile_t head)
{
	if (cmd == NULL||cmd->head_depend == NULL)
	{
		error(1,0,"Error: invalid command!");
		//printf("do something");
		return -1;
	}
	if(head == NULL)
		return 0;
	cmd->dependency=0;
	//dependency_text[i] should be a char*
	depend_list_t ptr = cmd->head_depend;
	while (ptr!= NULL)	
	{
		outfile_t depend = head;
		while (depend != NULL)
		{
			if (strcmp(ptr->filename,depend->text)==0)//if there exists dependency
			{
				add_to_waitlist(depend->cmd, ptr->cmd);	//(waited command, waiting command)
				cmd->dependency ++;	//has dependency, count+1
				break;	//跳出子循环;
			}
			depend = depend ->next;
		}
		ptr = ptr->next;
	}
	return cmd->dependency;
}
コード例 #2
0
int 
check_dependency (command_t cmd, outfile_t head)
{
	if (cmd == NULL || head == NULL)
	{
		app_printf("do something");
		return -1;
	}
	int dependency=0;
	//dependency_text[i] should be a char*
	while (cmd -> depend_file->filename != NULL)	
	{
		outfile_t depend = head;
		while (depend != outfile_tail)
		{
			if cmd -> depend_file->filename == depend->text)
			{
				add_to_waitlist(depend->cmd, depend_file->cmd)	//(waited command, waiting command)
				cmd->dependency ++;	//has dependency, count+1
				break;	//跳出子循环;
			}
			depend = depend ->next;
		}
	}
	return cmd->dependency;
}
コード例 #3
0
void set_command_status (command_t cmd, outfile_t head)
{
	if (check_dependency (cmd, head) == -1)
		error (1, 0, "Error check dependency!" )
	else if (check_dependency (cmd, head) == 0)
	{
		execute_command (cmd, time_travel);
		wakeup_waitlist(cmd);
	}
	else 	
	{
		add_to_waitlist();	//如果dependency>1,add to 多个waitlist,每次wake 则 dependency-1
							//当dependency=0时,则execute command
	}
}
コード例 #4
0
ファイル: libcman.c プロジェクト: smintz/cluster
static int process_cman_message(struct cman_handle *h, int flags, struct sock_header *msg)
{
	/* Data for us */
	if ((msg->command & CMAN_CMDMASK_CMD) == CMAN_CMD_DATA)
	{
		struct sock_data_header *dmsg = (struct sock_data_header *)msg;
		char *buf = (char *)msg;

		if (flags & CMAN_DISPATCH_IGNORE_DATA)
		{
			add_to_waitlist(&h->saved_data_msg, msg);
		}
		else
		{
			if (h->data_callback)
				h->data_callback(h, h->privdata,
						 buf+sizeof(*dmsg), msg->length-sizeof(*dmsg),
						 dmsg->port, dmsg->nodeid);
		}
		return 0;
	}

	/* Got a reply to a previous information request */
	if ((msg->command & CMAN_CMDFLAG_REPLY) && h->want_reply)
	{
		char *replybuf = (char *)msg;
		int replylen = msg->length - sizeof(struct sock_reply_header);
		struct sock_reply_header *reply = (struct sock_reply_header *)msg;

		if (flags & CMAN_DISPATCH_IGNORE_REPLY)
		{
			add_to_waitlist(&h->saved_reply_msg, msg);
			return 0;
		}

		replybuf += sizeof(struct sock_reply_header);
		if (replylen <= h->reply_buflen)
		{
			memcpy(h->reply_buffer, replybuf, replylen);
		}
		h->want_reply = 0;
		h->reply_status = reply->status;

		return 1;
	}

	/* OOB event */
	if (msg->command == CMAN_CMD_EVENT || msg->command == CMAN_CMD_CONFCHG)
	{
		if (flags & CMAN_DISPATCH_IGNORE_EVENT)
		{
			add_to_waitlist(&h->saved_event_msg, msg);
		}
		else
		{
			if (msg->command == CMAN_CMD_EVENT && h->event_callback) {
				struct sock_event_message *emsg = (struct sock_event_message *)msg;
				h->event_callback(h, h->privdata, emsg->reason, emsg->arg);
			}

			if (msg->command == CMAN_CMD_CONFCHG && h->confchg_callback)
			{
				struct sock_confchg_message *cmsg = (struct sock_confchg_message *)msg;

				h->confchg_callback(h, h->privdata,
						    cmsg->entries,cmsg->member_entries, 
						    &cmsg->entries[cmsg->member_entries], cmsg->left_entries, 
						    &cmsg->entries[cmsg->member_entries+cmsg->left_entries], cmsg->joined_entries);
			}
		}
	}

	return 0;
}