• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ free_buf函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中free_buf函数的典型用法代码示例。如果您正苦于以下问题:C++ free_buf函数的具体用法?C++ free_buf怎么用?C++ free_buf使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了free_buf函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: load_all_front_end_state

/*
 * load_all_front_end_state - Load the front_end node state from file, recover
 *	on slurmctld restart. Execute this after loading the configuration
 *	file data. Data goes into common storage.
 * IN state_only - if true, overwrite only front_end node state and reason
 *	Use this to overwrite the "UNKNOWN state typically used in slurm.conf
 * RET 0 or error code
 * NOTE: READ lock_slurmctld config before entry
 */
extern int load_all_front_end_state(bool state_only)
{
#ifdef HAVE_FRONT_END
	char *node_name = NULL, *reason = NULL, *data = NULL, *state_file;
	int data_allocated, data_read = 0, error_code = 0, node_cnt = 0;
	uint16_t node_state;
	uint32_t data_size = 0, name_len;
	uint32_t reason_uid = NO_VAL;
	time_t reason_time = 0;
	front_end_record_t *front_end_ptr;
	int state_fd;
	time_t time_stamp;
	Buf buffer;
	char *ver_str = NULL;
	uint16_t protocol_version = (uint16_t) NO_VAL;

	/* read the file */
	lock_state_files ();
	state_fd = _open_front_end_state_file(&state_file);
	if (state_fd < 0) {
		info ("No node state file (%s) to recover", state_file);
		error_code = ENOENT;
	} else {
		data_allocated = BUF_SIZE;
		data = xmalloc(data_allocated);
		while (1) {
			data_read = read(state_fd, &data[data_size], BUF_SIZE);
			if (data_read < 0) {
				if (errno == EINTR)
					continue;
				else {
					error ("Read error on %s: %m",
						state_file);
					break;
				}
			} else if (data_read == 0)     /* eof */
				break;
			data_size      += data_read;
			data_allocated += data_read;
			xrealloc(data, data_allocated);
		}
		close (state_fd);
	}
	xfree (state_file);
	unlock_state_files ();

	buffer = create_buf (data, data_size);

	safe_unpackstr_xmalloc( &ver_str, &name_len, buffer);
	debug3("Version string in front_end_state header is %s", ver_str);
	if (ver_str) {
		if (!strcmp(ver_str, FRONT_END_STATE_VERSION)) {
			protocol_version = SLURM_PROTOCOL_VERSION;
		}
	}

	if (protocol_version == (uint16_t) NO_VAL) {
		error("*****************************************************");
		error("Can not recover front_end state, version incompatible");
		error("*****************************************************");
		xfree(ver_str);
		free_buf(buffer);
		return EFAULT;
	}
	xfree(ver_str);

	safe_unpack_time(&time_stamp, buffer);

	while (remaining_buf (buffer) > 0) {
		uint16_t base_state;
		if (protocol_version >= SLURM_2_3_PROTOCOL_VERSION) {
			safe_unpackstr_xmalloc (&node_name, &name_len, buffer);
			safe_unpack16 (&node_state,  buffer);
			safe_unpackstr_xmalloc (&reason,    &name_len, buffer);
			safe_unpack_time (&reason_time, buffer);
			safe_unpack32 (&reason_uid,  buffer);
			base_state = node_state & NODE_STATE_BASE;
		} else
			goto unpack_error;

		/* validity test as possible */

		/* find record and perform update */
		front_end_ptr = find_front_end_record(node_name);
		if (front_end_ptr == NULL) {
			error("Front_end node %s has vanished from "
			      "configuration", node_name);
		} else if (state_only) {
			uint16_t orig_flags;
			orig_flags = front_end_ptr->node_state &
				     NODE_STATE_FLAGS;
//.........这里部分代码省略.........
开发者ID:kwangiit,项目名称:SLURMPP,代码行数:101,代码来源:front_end.c


示例2: init_buf

void *_forward_thread(void *arg)
{
	forward_msg_t *fwd_msg = (forward_msg_t *)arg;
	Buf buffer = init_buf(fwd_msg->buf_len);
	List ret_list = NULL;
	slurm_fd_t fd = -1;
	ret_data_info_t *ret_data_info = NULL;
	char *name = NULL;
	hostlist_t hl = hostlist_create(fwd_msg->header.forward.nodelist);
	slurm_addr_t addr;
	char *buf = NULL;
	int steps = 0;
	int start_timeout = fwd_msg->timeout;

	/* repeat until we are sure the message was sent */
	while ((name = hostlist_shift(hl))) {
		if (slurm_conf_get_addr(name, &addr) == SLURM_ERROR) {
			error("forward_thread: can't find address for host "
			      "%s, check slurm.conf", name);
			slurm_mutex_lock(fwd_msg->forward_mutex);
			mark_as_failed_forward(&fwd_msg->ret_list, name,
					       SLURM_UNKNOWN_FORWARD_ADDR);
 			free(name);
			if (hostlist_count(hl) > 0) {
				slurm_mutex_unlock(fwd_msg->forward_mutex);
				continue;
			}
			goto cleanup;
		}
		if ((fd = slurm_open_msg_conn(&addr)) < 0) {
			error("forward_thread to %s: %m", name);

			slurm_mutex_lock(fwd_msg->forward_mutex);
			mark_as_failed_forward(
				&fwd_msg->ret_list, name,
				SLURM_COMMUNICATIONS_CONNECTION_ERROR);
			free(name);
			if (hostlist_count(hl) > 0) {
				slurm_mutex_unlock(fwd_msg->forward_mutex);
				continue;
			}
			goto cleanup;
		}
		buf = hostlist_ranged_string_xmalloc(hl);

		xfree(fwd_msg->header.forward.nodelist);
		fwd_msg->header.forward.nodelist = buf;
		fwd_msg->header.forward.cnt = hostlist_count(hl);
		/* info("sending %d forwards (%s) to %s", */
/* 		     fwd_msg->header.forward.cnt, */
/* 		     fwd_msg->header.forward.nodelist, name); */
		if (fwd_msg->header.forward.nodelist[0]) {
			debug3("forward: send to %s along with %s",
			       name, fwd_msg->header.forward.nodelist);
		} else
			debug3("forward: send to %s ", name);

		pack_header(&fwd_msg->header, buffer);

		/* add forward data to buffer */
		if (remaining_buf(buffer) < fwd_msg->buf_len) {
			buffer->size += (fwd_msg->buf_len + BUF_SIZE);
			xrealloc(buffer->head, buffer->size);
		}
		if (fwd_msg->buf_len) {
			memcpy(&buffer->head[buffer->processed],
			       fwd_msg->buf, fwd_msg->buf_len);
			buffer->processed += fwd_msg->buf_len;
		}

		/*
		 * forward message
		 */
		if (_slurm_msg_sendto(fd,
				     get_buf_data(buffer),
				     get_buf_offset(buffer),
				     SLURM_PROTOCOL_NO_SEND_RECV_FLAGS ) < 0) {
			error("forward_thread: slurm_msg_sendto: %m");

			slurm_mutex_lock(fwd_msg->forward_mutex);
			mark_as_failed_forward(&fwd_msg->ret_list, name,
					       errno);
			free(name);
			if (hostlist_count(hl) > 0) {
				free_buf(buffer);
				buffer = init_buf(fwd_msg->buf_len);
				slurm_mutex_unlock(fwd_msg->forward_mutex);
				slurm_close_accepted_conn(fd);
				fd = -1;
				continue;
			}
			goto cleanup;
		}

		if ((fwd_msg->header.msg_type == REQUEST_SHUTDOWN) ||
		    (fwd_msg->header.msg_type == REQUEST_RECONFIGURE) ||
		    (fwd_msg->header.msg_type == REQUEST_REBOOT_NODES)) {
			slurm_mutex_lock(fwd_msg->forward_mutex);
			ret_data_info = xmalloc(sizeof(ret_data_info_t));
			list_push(fwd_msg->ret_list, ret_data_info);
//.........这里部分代码省略.........
开发者ID:IFCA,项目名称:slurm,代码行数:101,代码来源:forward.c


示例3: _handle_mult_rc_ret

static int _handle_mult_rc_ret(void)
{
	Buf buffer;
	uint16_t msg_type;
	persist_rc_msg_t *msg = NULL;
	dbd_list_msg_t *list_msg = NULL;
	int rc = SLURM_ERROR;
	Buf out_buf = NULL;

	buffer = slurm_persist_recv_msg(slurmdbd_conn);
	if (buffer == NULL)
		return rc;

	safe_unpack16(&msg_type, buffer);
	switch (msg_type) {
	case DBD_GOT_MULT_MSG:
		if (slurmdbd_unpack_list_msg(
			    &list_msg, slurmdbd_conn->version,
			    DBD_GOT_MULT_MSG, buffer)
		    != SLURM_SUCCESS) {
			error("slurmdbd: unpack message error");
			break;
		}

		slurm_mutex_lock(&agent_lock);
		if (agent_list) {
			ListIterator itr =
				list_iterator_create(list_msg->my_list);
			while ((out_buf = list_next(itr))) {
				Buf b;
				if ((rc = _unpack_return_code(
					     slurmdbd_conn->version, out_buf))
				    != SLURM_SUCCESS)
					break;

				if ((b = list_dequeue(agent_list))) {
					free_buf(b);
				} else {
					error("slurmdbd: DBD_GOT_MULT_MSG "
					      "unpack message error");
				}
			}
			list_iterator_destroy(itr);
		}
		slurm_mutex_unlock(&agent_lock);
		slurmdbd_free_list_msg(list_msg);
		break;
	case PERSIST_RC:
		if (slurm_persist_unpack_rc_msg(
			    &msg, buffer, slurmdbd_conn->version)
		    == SLURM_SUCCESS) {
			rc = msg->rc;
			if (rc != SLURM_SUCCESS) {
				if (msg->ret_info == DBD_REGISTER_CTLD &&
				    slurm_get_accounting_storage_enforce()) {
					error("slurmdbd: PERSIST_RC is %d from "
					      "%s(%u): %s",
					      rc,
					      slurmdbd_msg_type_2_str(
						      msg->ret_info, 1),
					      msg->ret_info,
					      msg->comment);
					fatal("You need to add this cluster "
					      "to accounting if you want to "
					      "enforce associations, or no "
					      "jobs will ever run.");
				} else
					debug("slurmdbd: PERSIST_RC is %d from "
					      "%s(%u): %s",
					      rc,
					      slurmdbd_msg_type_2_str(
						      msg->ret_info, 1),
					      msg->ret_info,
					      msg->comment);
			}
			slurm_persist_free_rc_msg(msg);
		} else
			error("slurmdbd: unpack message error");
		break;
	default:
		error("slurmdbd: bad message type %d != PERSIST_RC", msg_type);
	}

unpack_error:
	free_buf(buffer);
	return rc;
}
开发者ID:mej,项目名称:slurm,代码行数:87,代码来源:slurmdbd_agent.c


示例4: memset


//.........这里部分代码省略.........
				int agent_count = 0;
				ListIterator agent_itr =
					list_iterator_create(agent_list);
				list_msg.my_list = list_create(NULL);
				while ((buffer = list_next(agent_itr))) {
					list_enqueue(list_msg.my_list, buffer);
					agent_count++;
					if (agent_count > handle_agent_count)
						break;
				}
				list_iterator_destroy(agent_itr);
				buffer = pack_slurmdbd_msg(
					&list_req, SLURM_PROTOCOL_VERSION);
			} else if (cnt > 1) {
				list_msg.my_list = agent_list;
				buffer = pack_slurmdbd_msg(
					&list_req, SLURM_PROTOCOL_VERSION);
			} else
				buffer = (Buf) list_peek(agent_list);
		} else
			buffer = NULL;
		slurm_mutex_unlock(&agent_lock);
		if (buffer == NULL) {
			slurm_mutex_unlock(&slurmdbd_lock);

			slurm_mutex_lock(&assoc_cache_mutex);
			if (slurmdbd_conn->fd >= 0 && running_cache)
				slurm_cond_signal(&assoc_cache_cond);
			slurm_mutex_unlock(&assoc_cache_mutex);

			continue;
		}

		/* NOTE: agent_lock is clear here, so we can add more
		 * requests to the queue while waiting for this RPC to
		 * complete. */
		rc = slurm_persist_send_msg(slurmdbd_conn, buffer);
		if (rc != SLURM_SUCCESS) {
			if (*slurmdbd_conn->shutdown) {
				slurm_mutex_unlock(&slurmdbd_lock);
				break;
			}
			error("slurmdbd: Failure sending message: %d: %m", rc);
		} else if (list_msg.my_list) {
			rc = _handle_mult_rc_ret();
		} else {
			rc = _get_return_code();
			if (rc == EAGAIN) {
				if (*slurmdbd_conn->shutdown) {
					slurm_mutex_unlock(&slurmdbd_lock);
					break;
				}
				error("slurmdbd: Failure with "
				      "message need to resend: %d: %m", rc);
			}
		}
		slurm_mutex_unlock(&slurmdbd_lock);
		slurm_mutex_lock(&assoc_cache_mutex);
		if (slurmdbd_conn->fd >= 0 && running_cache)
			slurm_cond_signal(&assoc_cache_cond);
		slurm_mutex_unlock(&assoc_cache_mutex);

		slurm_mutex_lock(&agent_lock);
		if (agent_list && (rc == SLURM_SUCCESS)) {
			/*
			 * If we sent a mult_msg we just need to free buffer,
			 * we don't need to requeue, just mark list_msg.my_list
			 * as NULL as that is the sign we sent a mult_msg.
			 */
			if (list_msg.my_list) {
				if (list_msg.my_list != agent_list)
					FREE_NULL_LIST(list_msg.my_list);
				list_msg.my_list = NULL;
			} else
				buffer = (Buf) list_dequeue(agent_list);

			free_buf(buffer);
			fail_time = 0;
		} else {
			/* We need to free a mult_msg even on failure */
			if (list_msg.my_list) {
				if (list_msg.my_list != agent_list)
					FREE_NULL_LIST(list_msg.my_list);
				list_msg.my_list = NULL;
				free_buf(buffer);
			}

			fail_time = time(NULL);
		}
		slurm_mutex_unlock(&agent_lock);
		/* END_TIMER; */
		/* info("at the end with %s", TIME_STR); */
	}

	slurm_mutex_lock(&agent_lock);
	_save_dbd_state();
	FREE_NULL_LIST(agent_list);
	slurm_mutex_unlock(&agent_lock);
	return NULL;
}
开发者ID:mej,项目名称:slurm,代码行数:101,代码来源:slurmdbd_agent.c


示例5: jobacctinfo_setinfo

extern int jobacctinfo_setinfo(jobacctinfo_t *jobacct,
			       enum jobacct_data_type type, void *data,
			       uint16_t protocol_version)
{
	int rc = SLURM_SUCCESS;
	int *fd = (int *)data;
	struct rusage *rusage = (struct rusage *)data;
	uint32_t *uint32 = (uint32_t *) data;
	uint64_t *uint64 = (uint64_t *) data;
	double *dub = (double *) data;
	jobacct_id_t *jobacct_id = (jobacct_id_t *) data;
	struct jobacctinfo *send = (struct jobacctinfo *) data;

	if (!plugin_polling)
		return SLURM_SUCCESS;

	switch (type) {
	case JOBACCT_DATA_TOTAL:
		memcpy(jobacct, send, sizeof(struct jobacctinfo));
		break;
	case JOBACCT_DATA_PIPE:
		if (protocol_version >= SLURM_14_03_PROTOCOL_VERSION) {
			int len;
			Buf buffer = init_buf(0);
			jobacctinfo_pack(jobacct, protocol_version,
					 PROTOCOL_TYPE_SLURM, buffer);
			len = get_buf_offset(buffer);
			safe_write(*fd, &len, sizeof(int));
			safe_write(*fd, get_buf_data(buffer), len);
			free_buf(buffer);
		} else if (protocol_version >= SLURM_2_6_PROTOCOL_VERSION) {
			safe_write(*fd, &jobacct->user_cpu_sec,
				   sizeof(uint32_t));
			safe_write(*fd, &jobacct->user_cpu_usec,
				   sizeof(uint32_t));
			safe_write(*fd, &jobacct->sys_cpu_sec,
				   sizeof(uint32_t));
			safe_write(*fd, &jobacct->sys_cpu_usec,
				   sizeof(uint32_t));
			safe_write(*fd, &jobacct->max_vsize, sizeof(uint32_t));
			safe_write(*fd, &jobacct->tot_vsize, sizeof(uint32_t));
			safe_write(*fd, &jobacct->max_rss, sizeof(uint32_t));
			safe_write(*fd, &jobacct->tot_rss, sizeof(uint32_t));
			safe_write(*fd, &jobacct->max_pages, sizeof(uint32_t));
			safe_write(*fd, &jobacct->tot_pages, sizeof(uint32_t));
			safe_write(*fd, &jobacct->min_cpu, sizeof(uint32_t));
			safe_write(*fd, &jobacct->tot_cpu, sizeof(uint32_t));
			safe_write(*fd, &jobacct->act_cpufreq,
				   sizeof(uint32_t));
			safe_write(*fd, &jobacct->energy.consumed_energy,
				   sizeof(uint32_t));

			safe_write(*fd, &jobacct->max_disk_read,
				   sizeof(double));
			safe_write(*fd, &jobacct->tot_disk_read,
				   sizeof(double));
			safe_write(*fd, &jobacct->max_disk_write,
				   sizeof(double));
			safe_write(*fd, &jobacct->tot_disk_write,
				   sizeof(double));

			_write_jobacct_id(*fd, &jobacct->max_vsize_id,
					  protocol_version);
			_write_jobacct_id(*fd, &jobacct->max_rss_id,
					  protocol_version);
			_write_jobacct_id(*fd, &jobacct->max_pages_id,
					  protocol_version);
			_write_jobacct_id(*fd, &jobacct->min_cpu_id,
					  protocol_version);
			_write_jobacct_id(*fd, &jobacct->max_disk_read_id,
					  protocol_version);
			_write_jobacct_id(*fd, &jobacct->max_disk_write_id,
					  protocol_version);
		}

		break;
	case JOBACCT_DATA_RUSAGE:
		jobacct->user_cpu_sec = rusage->ru_utime.tv_sec;
		jobacct->user_cpu_usec = rusage->ru_utime.tv_usec;
		jobacct->sys_cpu_sec = rusage->ru_stime.tv_sec;
		jobacct->sys_cpu_usec = rusage->ru_stime.tv_usec;
		break;
	case JOBACCT_DATA_MAX_RSS:
		jobacct->max_rss = *uint64;
		break;
	case JOBACCT_DATA_MAX_RSS_ID:
		jobacct->max_rss_id = *jobacct_id;
		break;
	case JOBACCT_DATA_TOT_RSS:
		jobacct->tot_rss = *uint64;
		break;
	case JOBACCT_DATA_MAX_VSIZE:
		jobacct->max_vsize = *uint64;
		break;
	case JOBACCT_DATA_MAX_VSIZE_ID:
		jobacct->max_vsize_id = *jobacct_id;
		break;
	case JOBACCT_DATA_TOT_VSIZE:
		jobacct->tot_vsize = *uint64;
		break;
//.........这里部分代码省略.........
开发者ID:BYUHPC,项目名称:slurm,代码行数:101,代码来源:slurm_jobacct_gather.c


示例6: START_TEST


//.........这里部分代码省略.........
	pack_ar->acct           	 = xstrdup("Socrates");
	pack_ar->assoc_next     	 = xmalloc(sizeof(slurmdb_assoc_rec_t));
	pack_ar->assoc_next->rgt         = 11;
	pack_ar->assoc_next->grp_jobs    = 22;
	pack_ar->assoc_next_id  	 = xmalloc(sizeof(slurmdb_assoc_rec_t));
	pack_ar->assoc_next_id->grp_jobs = 33;
	pack_ar->cluster        	 = xstrdup("Parmenides");
	pack_ar->def_qos_id   	         = 1;
	pack_ar->grp_jobs                = 2;
	pack_ar->grp_submit_jobs         = 3;
	pack_ar->grp_tres                = xstrdup("Parmenides");
	pack_ar->grp_tres_ctld           = NULL;
	pack_ar->grp_tres_mins           = xstrdup("Parmenides");
	pack_ar->grp_tres_run_mins       = xstrdup("Parmenides");
	pack_ar->grp_tres_run_mins_ctld  = NULL;
	pack_ar->grp_wall                = 6;
	pack_ar->id                      = 7;
	pack_ar->is_def                  = 8;
	pack_ar->lft                     = 9;
	pack_ar->max_jobs                = 1;
	pack_ar->max_submit_jobs         = 2;
	pack_ar->max_tres_mins_pj        = xstrdup("Parmenides");
	pack_ar->max_tres_mins_ctld      = NULL;
	pack_ar->max_tres_run_mins       = xstrdup("Parmenides");
	pack_ar->max_tres_run_mins_ctld  = NULL;
	pack_ar->max_tres_pj             = xstrdup("Parmenides");
	pack_ar->max_tres_ctld           = NULL;
	pack_ar->max_tres_pn             = xstrdup("Parmenides");
	pack_ar->max_tres_pn_ctld        = NULL;
	pack_ar->max_wall_pj             = 7;
	pack_ar->parent_acct             = xstrdup("Parmenides");
	pack_ar->parent_id               = 8;
	pack_ar->partition               = xstrdup("Parmenides");
	pack_ar->qos_list                = list_create(slurm_destroy_char);
	pack_ar->rgt                     = 9;
	pack_ar->shares_raw              = 1;
	pack_ar->uid                     = 2;
	pack_ar->usage                   = xmalloc(sizeof(slurmdb_assoc_usage_t));
	pack_ar->user                    = xstrdup("Parmenides");

	list_append(pack_ar->accounting_list, (void *)art);
	list_append(pack_ar->qos_list       , (void *)qos);


	slurmdb_pack_assoc_rec(pack_ar, SLURM_MIN_PROTOCOL_VERSION, buf);
	set_buf_offset(buf, 0);
	slurmdb_assoc_rec_t *unpack_ar;
	rc = slurmdb_unpack_assoc_rec((void **)&unpack_ar, SLURM_MIN_PROTOCOL_VERSION, buf);
	ck_assert(rc                    	     == SLURM_SUCCESS);
	ck_assert_str_eq(pack_ar->acct,                 unpack_ar->acct);
	ck_assert(NULL                   	     == unpack_ar->assoc_next);
	ck_assert(NULL                 	             == unpack_ar->assoc_next_id);
	ck_assert_str_eq(pack_ar->cluster,              unpack_ar->cluster);
	ck_assert(pack_ar->def_qos_id         	     == unpack_ar->def_qos_id);
	ck_assert(pack_ar->grp_jobs                  == unpack_ar->grp_jobs);
	ck_assert(pack_ar->grp_submit_jobs           == unpack_ar->grp_submit_jobs);
	ck_assert_str_eq(pack_ar->grp_tres,             unpack_ar->grp_tres);
	ck_assert(pack_ar->grp_tres_ctld  	     == unpack_ar->grp_tres_ctld);
	ck_assert_str_eq(pack_ar->grp_tres_run_mins,    unpack_ar->grp_tres_run_mins);
	ck_assert(pack_ar->grp_wall                  == unpack_ar->grp_wall);
	ck_assert(pack_ar->id                        == unpack_ar->id);
	ck_assert(pack_ar->is_def                    == unpack_ar->is_def);
	ck_assert(pack_ar->lft                       == unpack_ar->lft);
	ck_assert(pack_ar->max_jobs                  == unpack_ar->max_jobs);
	ck_assert(pack_ar->max_submit_jobs           == unpack_ar->max_submit_jobs);
	ck_assert_str_eq(pack_ar->max_tres_mins_pj,     unpack_ar->max_tres_mins_pj);
	ck_assert(pack_ar->max_tres_mins_ctld        == unpack_ar->max_tres_mins_ctld);
	ck_assert_str_eq(pack_ar->max_tres_run_mins,    unpack_ar->max_tres_run_mins);
	ck_assert(pack_ar->max_tres_run_mins_ctld    == unpack_ar->max_tres_run_mins_ctld);
	ck_assert_str_eq(pack_ar->max_tres_pj,          unpack_ar->max_tres_pj);
	ck_assert(pack_ar->max_tres_ctld             == unpack_ar->max_tres_ctld);
	ck_assert_str_eq(pack_ar->max_tres_pn,          unpack_ar->max_tres_pn);
	ck_assert(pack_ar->max_tres_pn_ctld          == unpack_ar->max_tres_pn_ctld);
	ck_assert(pack_ar->max_wall_pj               == unpack_ar->max_wall_pj);
	ck_assert_str_eq(pack_ar->parent_acct,          unpack_ar->parent_acct);
	ck_assert(pack_ar->parent_id                 == unpack_ar->parent_id);
	ck_assert_str_eq(pack_ar->partition,            unpack_ar->partition);
	ck_assert(pack_ar->rgt                       == unpack_ar->rgt);
	ck_assert(pack_ar->shares_raw          	     == unpack_ar->shares_raw);
	ck_assert(pack_ar->uid                       == unpack_ar->uid);
	ck_assert(NULL                               == unpack_ar->usage);
	ck_assert_str_eq(pack_ar->user,                 unpack_ar->user);

	slurmdb_accounting_rec_t *b = (slurmdb_accounting_rec_t *)list_peek(pack_ar->accounting_list);
	slurmdb_accounting_rec_t *a = (slurmdb_accounting_rec_t *)list_peek(pack_ar->accounting_list);

	char *before = (char *)list_peek(pack_ar->qos_list);
	char *after  = (char *)list_peek(unpack_ar->qos_list);

	ck_assert(b->id == a->id);

	ck_assert_str_eq(before, after);

	free_buf(buf);
	xfree(pack_ar->assoc_next);
	xfree(pack_ar->assoc_next_id);
	xfree(pack_ar->usage);
	slurmdb_destroy_assoc_rec(pack_ar);
	slurmdb_destroy_assoc_rec(unpack_ar);
}
开发者ID:SchedMD,项目名称:slurm,代码行数:101,代码来源:pack_assoc_rec-test.c


示例7: interruptDmaSpi

void interruptDmaSpi(void) {
	free_buf(pb_spi);
	DMA_SetCurrDataCounter(DMA1_Stream5, SIZE_BIG_BUFFER);
	return;
}
开发者ID:korrav,项目名称:master_emmiter,代码行数:5,代码来源:spiExchange.c


示例8: do_spells


//.........这里部分代码省略.........
	    argument = one_argument(argument,arg);
	    if (!is_number(arg))
	    {
		send_to_char("Arguments must be numerical or all.\n\r",ch);
		return;
	    }
	    max_lev = atoi(arg);

	    if (max_lev < 1 || max_lev > LEVEL_HERO)
	    {
		sprintf(buf,"Levels must be between 1 and %d.\n\r",LEVEL_HERO);
		send_to_char(buf,ch);
		return;
	    }

	    if (argument[0] != '\0')
	    {
		argument = one_argument(argument,arg);
		if (!is_number(arg))
		{
		    send_to_char("Arguments must be numerical or all.\n\r",ch);
		    return;
		}
		min_lev = max_lev;
		max_lev = atoi(arg);

		if (max_lev < 1 || max_lev > LEVEL_HERO)
		{
		    sprintf(buf,
			"Levels must be between 1 and %d.\n\r",LEVEL_HERO);
		    send_to_char(buf,ch);
		    return;
		}

		if (min_lev > max_lev)
		{
		    send_to_char("That would be silly.\n\r",ch);
		    return;
		}
	    }
	}
    }


    /* initialize data */
    for (level = 0; level < LEVEL_HERO + 1; level++)
    {
        spell_columns[level] = 0;
        spell_list[level][0] = '\0';
    }

    for (sn = 0; sn < MAX_SKILL; sn++)
    {
        if (skill_table[sn].name == NULL )
	    break;

	if ((level = skill_table[sn].skill_level[ch->Class()->GetIndex()]) < LEVEL_HERO + 1
	&&  level >= min_lev && level <= max_lev
	&&  skill_table[sn].spell_fun != spell_null
	&&  ch->pcdata->learned[sn] > 0
	&&  (skill_table[sn].ctype==CMD_SPELL || skill_table[sn].ctype==CMD_BOTH))
        {
	    found = TRUE;
	    level = skill_table[sn].skill_level[ch->Class()->GetIndex()];
	    if (ch->level < level)
	    	sprintf(buf,"%-18s n/a      ", skill_table[sn].name);
	    else
	    {
        mana = UMAX(skill_table[sn].min_mana,
		    100/(2 + ch->level - level));
            sprintf(buf,"%-18s  %3d mana  ",skill_table[sn].name,mana);
	    }

	    if (spell_list[level][0] == '\0')
          	sprintf(spell_list[level],"\n\rLevel %2d: %s",level,buf);
	    else /* append */
	    {
          	if ( ++spell_columns[level] % 2 == 0)
		    strcat(spell_list[level],"\n\r          ");
          	strcat(spell_list[level],buf);
	    }
	}
    }

    /* return results */

    if (!found)
    {
      	send_to_char("No spells found.\n\r",ch);
      	return;
    }

    buffer = new_buf();
    for (level = 0; level < LEVEL_HERO + 1; level++)
      	if (spell_list[level][0] != '\0')
	    add_buf(buffer,spell_list[level]);
    add_buf(buffer,"\n\r");
    page_to_char(buf_string(buffer),ch);
    free_buf(buffer);
}
开发者ID:rezalas,项目名称:riftshadow,代码行数:101,代码来源:skills.c


示例9: _process_server_request

static void _process_server_request(recv_header_t *_hdr, void *payload)
{
	send_header_t *hdr = &_hdr->send_hdr;
	char *nodename = pmixp_info_job_host(hdr->nodeid);
	Buf buf;
	int rc;

	buf = create_buf(payload, hdr->msgsize);

	switch (hdr->type) {
	case PMIXP_MSG_FAN_IN:
	case PMIXP_MSG_FAN_OUT: {
		pmixp_coll_t *coll;
		pmix_proc_t *procs = NULL;
		size_t nprocs = 0;
		pmixp_coll_type_t type = 0;

		rc = pmixp_coll_unpack_ranges(buf, &type, &procs, &nprocs);
		if (SLURM_SUCCESS != rc) {
			PMIXP_ERROR("Bad message header from node %s", nodename);
			return;
		}
		coll = pmixp_state_coll_get(type, procs, nprocs);
		xfree(procs);

		PMIXP_DEBUG("FENCE collective message from node \"%s\", type = %s, seq = %d",
			    nodename, (PMIXP_MSG_FAN_IN == hdr->type) ? "fan-in" : "fan-out",
			    hdr->seq);
		rc = pmixp_coll_check_seq(coll, hdr->seq, nodename);
		if (PMIXP_COLL_REQ_FAILURE == rc) {
			/* this is unexepable event: either something went
			 * really wrong or the state machine is incorrect.
			 * This will 100% lead to application hang.
			 */
			PMIXP_ERROR("Bad collective seq. #%d from %s, current is %d",
				    hdr->seq, nodename, coll->seq);
			pmixp_debug_hang(0); /* enable hang to debug this! */
			slurm_kill_job_step(pmixp_info_jobid(), pmixp_info_stepid(),
					    SIGKILL);

			break;
		} else if (PMIXP_COLL_REQ_SKIP == rc) {
			PMIXP_DEBUG("Wrong collective seq. #%d from %s, current is %d, skip this message",
				    hdr->seq, nodename, coll->seq);
			free_buf(buf);
			break;
		}

		if (PMIXP_MSG_FAN_IN == hdr->type) {
			pmixp_coll_contrib_node(coll, nodename, buf);
			/* we don't need this buffer anymore */
			free_buf(buf);
		} else {
			pmixp_coll_bcast(coll, buf);
			/* buf will be free'd by the PMIx callback */
		}

		break;
	}
	case PMIXP_MSG_DMDX: {
		pmixp_dmdx_process(buf, nodename, hdr->seq);
		break;
	}
	case PMIXP_MSG_HEALTH_CHK: {
		/* this is just health ping.
		 * TODO: can we do something more sophisticated?
		 */
		free_buf(buf);
		break;
	}
	default:
		PMIXP_ERROR("Unknown message type %d", hdr->type);
		break;
	}
	xfree(nodename);
}
开发者ID:Q-Leap-Networks,项目名称:qlustar-slurm,代码行数:76,代码来源:pmixp_server.c


示例10: pack_slurmdbd_msg


//.........这里部分代码省略.........
	case DBD_REMOVE_RES:
	case DBD_REMOVE_WCKEYS:
	case DBD_REMOVE_USERS:
	case DBD_ARCHIVE_DUMP:
		_pack_cond_msg(
			(dbd_cond_msg_t *)req->data, rpc_version, req->msg_type,
			buffer);
		break;
	case DBD_GET_ASSOC_USAGE:
	case DBD_GOT_ASSOC_USAGE:
	case DBD_GET_CLUSTER_USAGE:
	case DBD_GOT_CLUSTER_USAGE:
	case DBD_GET_WCKEY_USAGE:
	case DBD_GOT_WCKEY_USAGE:
		slurmdbd_pack_usage_msg(
			(dbd_usage_msg_t *)req->data, rpc_version,
			req->msg_type, buffer);
		break;
	case DBD_FINI:
		slurmdbd_pack_fini_msg((dbd_fini_msg_t *)req->data,
				       rpc_version, buffer);
		break;
	case DBD_JOB_COMPLETE:
		_pack_job_complete_msg((dbd_job_comp_msg_t *)req->data,
				       rpc_version,
				       buffer);
		break;
	case DBD_JOB_START:
		_pack_job_start_msg(req->data, rpc_version, buffer);
		break;
	case DBD_ID_RC:
		slurmdbd_pack_id_rc_msg(req->data, rpc_version, buffer);
		break;
	case DBD_JOB_SUSPEND:
		_pack_job_suspend_msg(
			(dbd_job_suspend_msg_t *)req->data, rpc_version,
			buffer);
		break;
	case DBD_MODIFY_ACCOUNTS:
	case DBD_MODIFY_ASSOCS:
	case DBD_MODIFY_CLUSTERS:
	case DBD_MODIFY_FEDERATIONS:
	case DBD_MODIFY_JOB:
	case DBD_MODIFY_QOS:
	case DBD_MODIFY_RES:
	case DBD_MODIFY_USERS:
		_pack_modify_msg(
			(dbd_modify_msg_t *)req->data, rpc_version,
			req->msg_type, buffer);
		break;
	case DBD_NODE_STATE:
		_pack_node_state_msg(
			(dbd_node_state_msg_t *)req->data, rpc_version,
			buffer);
		break;
	case DBD_STEP_COMPLETE:
		_pack_step_complete_msg(
			(dbd_step_comp_msg_t *)req->data, rpc_version,
			buffer);
		break;
	case DBD_STEP_START:
		_pack_step_start_msg((dbd_step_start_msg_t *)req->data,
				     rpc_version,
				     buffer);
		break;
	case DBD_REGISTER_CTLD:
		_pack_register_ctld_msg(
			(dbd_register_ctld_msg_t *)req->data, rpc_version,
			buffer);
		break;
	case DBD_ROLL_USAGE:
		_pack_roll_usage_msg((dbd_roll_usage_msg_t *)req->data,
				     rpc_version,
				     buffer);
		break;
	case DBD_ADD_RESV:
	case DBD_REMOVE_RESV:
	case DBD_MODIFY_RESV:
		_pack_rec_msg(
			(dbd_rec_msg_t *)req->data, rpc_version, req->msg_type,
			buffer);
		break;
	case DBD_GET_CONFIG:
		packstr((char *)req->data, buffer);
		break;
	case DBD_RECONFIG:
	case DBD_GET_STATS:
	case DBD_CLEAR_STATS:
	case DBD_SHUTDOWN:
		break;
	default:
		error("slurmdbd: Invalid message type pack %u(%s:%u)",
		      req->msg_type,
		      slurmdbd_msg_type_2_str(req->msg_type, 1),
		      req->msg_type);
		free_buf(buffer);
		return NULL;
	}
	return buffer;
}
开发者ID:SchedMD,项目名称:slurm,代码行数:101,代码来源:slurmdbd_pack.c


示例11: stretch

void
stretch(u8** image, BMP_HEADER* p_header, u8* color_buf, int width, int height)
{
	char	flag_bilinear, char_test;
        int     i, j;
        float   x_ratio, y_ratio, x, y;
        printf("Give a float ratio to X-stretch (must > 0)\n");

	/* 
	 * no matter whether it's a '\n' in input-buf, SCANF ignores it
	 * except SCANF needs %c
	 */
	scanf("%f", &x_ratio);
	/* eat the '\n' which user has typed follow a useful num */
	while ((char_test = getchar()) != '\n' && char_test != EOF) ;

        printf("Give a float ratio to Y-stretch (must > 0)\n");
	scanf("%f", &y_ratio);
	while ((char_test = getchar()) != '\n' && char_test != EOF) ;

        printf("Choose one algorithm\n"
		"[a] -> adjacent pixel\n"
		"[b] -> bilinear interposition\n");
	__asm__ __volatile__("4:");
	while ((char_test = getchar()) != '\n' && char_test != EOF) {
		flag_bilinear = char_test;

		/* not *++bp, bp is a global-var */
		*bp	 = '\n';
	}

	/* algorithm bilinear-interposition */
	switch (flag_bilinear) {
		case 'b':
			flag_bilinear = 1;
			break;
		case 'a':
			flag_bilinear = 0;
			break;
		default:
			printf("Hey bro, type 'a' or 'b'\n");
			__asm__ __volatile__("jmp 4b");
			break;
	}

        int     width_new   =       (int)(width * x_ratio);
        int     height_new  =       (int)(height * y_ratio);
        u8*     image_new[height_new];

        width_pad(&width_new);

        calloc_buf(image_new, width_new, height_new);

	if (!flag_bilinear) {
		int x_int, y_int;
		for (i = 0; i < height_new; i++) {
			y_int	=	(int)((float)i / y_ratio);
			for (j = 0; j < width_new; j++) {
				x_int	=	(int)((float)j / x_ratio);
				if (x_int >= width)
					/* why minus 1? see below */
					x_int = width - 1;
				if (y_int >= height)
					y_int = height - 1;
				/* here is the answer */
				image_new[i][j] =       image[y_int][x_int];
			}
		}
	}
	else {
		for (i = 0; i < height_new; i++) {
			y       =       ((float)i / y_ratio);
			for (j = 0; j < width_new; j++) {
				x       =       ((float)j / x_ratio);
				if ((int)x >= width)
					/* the same reason here */
					x = width - 1;
				if ((int)y >= height)
					y = height - 1;
				/* the same answer here */
				image_new[i][j] = x - floor(x) || y - floor(y) ? \
						  bilinear_interposition(image, x, y, width, height) : \
						  image[(int)y][(int)x];
			}
		}
	}

        if (write_bmp_calloc(image_new, color_buf, width_new, height_new, p_header)) {
                printf("Sorry, Stretch Failure!\n");
                exit(EXIT_FAILURE);
        }

        free_buf(image_new, width_new, height_new);
        printf("\nStretch Done!\tWhat's more?\n");
}
开发者ID:treblih,项目名称:dip,代码行数:95,代码来源:geometry.c


示例12: do_skills


//.........这里部分代码省略.........
		     sn == gsn_skirmisher_skill  ||
		     sn == gsn_dragoon_skill     ||
		     sn == gsn_tactician_skill) && ch->level < AVATAR)) {
			send_to_char("You are not learned in that.\n\r",ch);
		}
		else
		{
			sprintf(buf, "Your skill in '%s' is %d%%.\n\r",
			skill_table[sn].name, ch->pcdata->learned[sn]);
			send_to_char(buf, ch);
		}
		return;
	}
    }



    /* initialize data */
    for (level = 0; level < LEVEL_HERO + 1; level++)
    {
        skill_columns[level] = 0;
        skill_list[level][0] = '\0';
    }

    for (sn = 0; sn < MAX_SKILL; sn++)
    {
        if (skill_table[sn].name == NULL )
	    break;

		hide_skill=FALSE;
        /*if ((level = skill_table[sn].skill_level[ch->Class()->GetIndex()]) < LEVEL_HERO + 1
	&&  (fAll || level <= ch->level)
	&&  level >= min_lev && level <= max_lev
	&&  skill_table[sn].spell_fun == spell_null
        &&  ch->pcdata->learned[sn] > 0)*/
	if ((level = skill_table[sn].skill_level[ch->Class()->GetIndex()]) < LEVEL_HERO + 1
	&&  level >= min_lev && level <= max_lev
	&&  skill_table[sn].spell_fun == spell_null
	&&  ch->pcdata->learned[sn] > 0)
        {

        for(p=0; p<MAX_STYLE_SKILL; p++)
        {
        	if(!str_prefix(style_percent[p].name, skill_table[sn].name))
        	{
        		gn = gn_skill_lookup(sn);
        		if(gn > 1)
        		{
        			style_skill = skill_lookup( group_table[gn].name );
        			if(ch->pcdata->learned[style_skill] < style_percent[p].percent)
        				hide_skill=TRUE;
					if(hide_skill) break;
				}
	    	}
	    }

        if ( sn == gsn_gladiator_skill || sn == gsn_duelist_skill ||
		     sn == gsn_barbarian_skill || sn == gsn_dragoon_skill ||
		     sn == gsn_skirmisher_skill || sn == gsn_tactician_skill)
			hide_skill=TRUE;
		
		found = TRUE;
	    level = skill_table[sn].skill_level[ch->Class()->GetIndex()];
		if(!hide_skill)
		{
			if (ch->level < level)
	    		sprintf(buf,"%-18s n/a      ", skill_table[sn].name);
	    	else
	    		sprintf(buf,"%-18s %3d%%      ",skill_table[sn].name,
		    			ch->pcdata->learned[sn]);

	   		if (skill_list[level][0] == '\0')
          		sprintf(skill_list[level],"\n\rLevel %2d: %s",level,buf);
	    	else /* append */
	    	{
          		if ( ++skill_columns[level] % 2 == 0)
		    	strcat(skill_list[level],"\n\r          ");
          		strcat(skill_list[level],buf);
	    	}

		}
	}
    }

    /* return results */

    if (!found)
    {
      	send_to_char("No skills found.\n\r",ch);
      	return;
    }

    buffer = new_buf();
    for (level = 0; level < LEVEL_HERO + 1; level++)
      	if (skill_list[level][0] != '\0')
	    add_buf(buffer,skill_list[level]);
    add_buf(buffer,"\n\r");
    page_to_char(buf_string(buffer),ch);
    free_buf(buffer);
}
开发者ID:rezalas,项目名称:riftshadow,代码行数:101,代码来源:skills.c


示例13: ban_site

/*
 * Bans a site from being able to login to the mud.
 */
void ban_site(CHAR_DATA * ch, char *argument, bool fPerm)
{
    char buf[MAX_STRING_LENGTH], buf2[MAX_STRING_LENGTH];
    char arg1[MAX_INPUT_LENGTH], arg2[MAX_INPUT_LENGTH];
    char *name;
    BUFFER *buffer;
    BAN_DATA *pban, *prev;
    bool prefix = FALSE, suffix = FALSE;
    int type;

    argument = one_argument(argument, arg1);
    argument = one_argument(argument, arg2);

    if (arg1[0] == '\0')
    {
        if (ban_list == NULL)
        {
            send_to_char("No sites banned at this time.\r\n", ch);
            return;
        }

        buffer = new_buf();

        add_buf(buffer, "Banned sites  level  type     status\r\n");
        for (pban = ban_list; pban != NULL; pban = pban->next)
        {
            sprintf(buf2, "%s%s%s",
                IS_SET(pban->ban_flags, BAN_PREFIX) ? "*" : "",
                pban->name,
                IS_SET(pban->ban_flags, BAN_SUFFIX) ? "*" : "");
            sprintf(buf, "%-12s    %-3d  %-7s  %s\r\n",
                buf2, pban->level,
                IS_SET(pban->ban_flags, BAN_NEWBIES) ? "newbies" :
                IS_SET(pban->ban_flags, BAN_PERMIT) ? "permit" :
                IS_SET(pban->ban_flags, BAN_ALL) ? "all" : "",
                IS_SET(pban->ban_flags,
                    BAN_PERMANENT) ? "perm" : "temp");
            add_buf(buffer, buf);
        }

        page_to_char(buf_string(buffer), ch);
        free_buf(buffer);
        return;
    }

    /* find out what type of ban */
    if (arg2[0] == '\0' || !str_prefix(arg2, "all"))
    {
        type = BAN_ALL;
    }
    else if (!str_prefix(arg2, "newbies"))
    {
        type = BAN_NEWBIES;
    }
    else if (!str_prefix(arg2, "permit"))
    {
        type = BAN_PERMIT;
    }
    else
    {
        send_to_char("Acceptable ban types are all, newbies, and permit.\r\n", ch);
        return;
    }

    name = arg1;

    if (name[0] == '*')
    {
        prefix = TRUE;
        name++;
    }

    if (name[strlen(name) - 1] == '*')
    {
        suffix = TRUE;
        name[strlen(name) - 1] = '\0';
    }

    if (strlen(name) == 0)
    {
        send_to_char("You have to ban SOMETHING.\r\n", ch);
        return;
    }

    prev = NULL;
    for (pban = ban_list; pban != NULL; prev = pban, pban = pban->next)
    {
        if (!str_cmp(name, pban->name))
        {
            if (pban->level > get_trust(ch))
            {
                send_to_char("That ban was set by a higher power.\r\n", ch);
                return;
            }
            else
            {
                if (prev == NULL)
//.........这里部分代码省略.........
开发者ID:carriercomm,项目名称:CrimsonSkies,代码行数:101,代码来源:ban.c


示例14: pmix_ring_out

/* ring_out messages come in from our parent,
 * we process this and send ring_out messages to each of our children:
 *   count - starting rank for our leftmost application process
 *   left  - left value for leftmost application process in our subtree
 *   right - right value for rightmost application process in our subtree */
int pmix_ring_out(int count, char* left, char* right)
{
	int rc = SLURM_SUCCESS;

	debug3("mpi/pmi2: in pmix_ring_out rank=%d count=%d left=%s right=%s",
		pmix_stepd_rank, count, left, right);

	/* our parent will send us a pmix_ring_out message, the count value
	 * contained in this message will be the rank of the first process
	 * in our subtree, the left value will be the left value for the
	 * first process in the subtree, and the right value will be the
	 * right value for the last process in our subtree */

	/* allocate a structure to compute values to send to each child */
	pmix_ring_msg* outmsgs = (pmix_ring_msg*) xmalloc(pmix_ring_children * sizeof(pmix_ring_msg));

        /* initialize messages to all children */
	int i;
	for (i = 0; i < pmix_ring_children; i++) {
		outmsgs[i].count = 0;
		outmsgs[i].left  = NULL;
		outmsgs[i].right = NULL;
	}

	/* iterate over all msgs and set count and left neighbor */
	for (i = 0; i < pmix_ring_children; i++) {
		/* store current count in output message */
		outmsgs[i].count = count;

		/* add count for this child to our running total */
		count += pmix_ring_msgs[i].count;

		/* set left value for this child */
		outmsgs[i].left = left;

		/* get right value from child, if it exists,
		 * it will be the left neighbor of the next child,
		 * otherwise, reuse the current left value */
		char* next = pmix_ring_msgs[i].right;
		if (next != NULL) {
			left = next;
		}
	}

	/* now set all right values (iterate backwards through children) */
	for (i = (pmix_ring_children - 1); i >= 0; i--) {
		/* set right value for this child */
		outmsgs[i].right = right;

		/* get left value from child, if it exists,
		 * it will be the right neighbor of the next child,
		 * otherwise, reuse the current right value */
		char* next = pmix_ring_msgs[i].left;
		if (next != NULL) {
			right = next;
		}
	}

	/* send messages to children in stepd tree,
	 * we do this first to get the message down the tree quickly */
	for (i = 0; i < pmix_stepd_children; i++) {
		/* get pointer to message data for this child */
		int ring_id = pmix_app_children + i;
		pmix_ring_msg* msg = &outmsgs[ring_id];

		/* TODO: do we need hton translation? */

		/* construct message */
		Buf buf = init_buf(1024);
		pack16(TREE_CMD_RING_RESP,    buf); /* specify message type (RING_OUT) */
		pack32((uint32_t) msg->count, buf); /* send count value */
		packstr(msg->left,            buf); /* send left value */
		packstr(msg->right,           buf); /* send right value */

		/* get global rank of our i-th child stepd */
		int rank = pmix_stepd_rank_child(i);

		debug3("mpi/pmi2: rank=%d sending RING_OUT to rank=%d count=%d left=%s right=%s",
			pmix_stepd_rank, rank, msg->count, msg->left, msg->right);

		/* send message to child */
		rc = pmix_stepd_send(get_buf_data(buf), (uint32_t) size_buf(buf), rank);

		/* TODO: use tmp_rc here to catch any failure */

		/* free message */
		free_buf(buf);
	}

	/* now send messages to children app procs,
	 * and set their state back to normal */
	for (i = 0; i < pmix_app_children; i++) {
		/* get pointer to message data for this child */
		pmix_ring_msg* msg = &outmsgs[i];

//.........这里部分代码省略.........
开发者ID:A1ve5,项目名称:slurm,代码行数:101,代码来源:ring.c


示例15: jobacctinfo_getinfo

extern int jobacctinfo_getinfo(
	jobacctinfo_t *jobacct, enum jobacct_data_type type, void *data,
	uint16_t protocol_version)
{
	int rc = SLURM_SUCCESS;
	int *fd = (int *)data;
	uint32_t *uint32 = (uint32_t *) data;
	uint64_t *uint64 = (uint64_t *) data;
	double *dub = (double *) data;
	jobacct_id_t *jobacct_id = (jobacct_id_t *) data;
	struct rusage *rusage = (struct rusage *)data;
	struct jobacctinfo *send = (struct jobacctinfo *) data;

	if (!plugin_polling)
		return SLURM_SUCCESS;

	/* jobacct needs to be allocated before this is called.	*/
	xassert(jobacct);

	switch (type) {
	case JOBACCT_DATA_TOTAL:
		memcpy(send, jobacct, sizeof(struct jobacctinfo));
		break;
	case JOBACCT_DATA_PIPE:
		if (protocol_version >= SLURM_14_03_PROTOCOL_VERSION) {
			char* buf;
			int len;
			Buf buffer;

			safe_read(*fd, &len, sizeof(int));
			buf = xmalloc(len);
			safe_read(*fd, buf, len);
			buffer = create_buf(buf, len);
			jobacctinfo_unpack(&jobacct, protocol_version,
					   PROTOCOL_TYPE_SLURM, buffer, 0);
			free_buf(buffer);
		} else if (protocol_version >= SLURM_2_6_PROTOCOL_VERSION) {
			safe_read(*fd, &jobacct->user_cpu_sec,
				  sizeof(uint32_t));
			safe_read(*fd, &jobacct->user_cpu_usec,
				  sizeof(uint32_t));
			safe_read(*fd, &jobacct->sys_cpu_sec, sizeof(uint32_t));
			safe_read(*fd, &jobacct->sys_cpu_usec,
				  sizeof(uint32_t));
			safe_read(*fd, &jobacct->max_vsize, sizeof(uint32_t));
			safe_read(*fd, &jobacct->tot_vsize, sizeof(uint32_t));
			safe_read(*fd, &jobacct->max_rss, sizeof(uint32_t));
			safe_read(*fd, &jobacct->tot_rss, sizeof(uint32_t));
			safe_read(*fd, &jobacct->max_pages, sizeof(uint32_t));
			safe_read(*fd, &jobacct->tot_pages, sizeof(uint32_t));
			safe_read(*fd, &jobacct->min_cpu, sizeof(uint32_t));
			safe_read(*fd, &jobacct->tot_cpu, sizeof(uint32_t));
			safe_read(*fd, &jobacct->act_cpufreq, sizeof(uint32_t));
			safe_read(*fd, &jobacct->energy.consumed_energy,
				  sizeof(uint32_t));

			safe_read(*fd, &jobacct->max_disk_read, sizeof(double));
			safe_read(*fd, &jobac 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ fromHex函数代码示例发布时间:2022-05-30
下一篇:
C++ free_br函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap