Esempio n. 1
0
static void add_kmalloc(const char *func, unsigned long long ptr,
			unsigned int req, int alloc)
{
	struct func_descr *funcd;
	struct ptr_descr *ptrd;

	funcd = find_func(func);
	if (!funcd)
		funcd = create_func(func);

	funcd->total_alloc += alloc;
	funcd->total_req += req;
	funcd->current_alloc += alloc;
	funcd->current_req += req;
	if (funcd->current_alloc > funcd->max_alloc)
		funcd->max_alloc = funcd->current_alloc;
	if (funcd->current_req > funcd->max_req)
		funcd->max_req = funcd->current_req;

	ptrd = find_ptr(ptr);
	if (!ptrd)
		ptrd = create_ptr(ptr);

	ptrd->alloc = alloc;
	ptrd->req = req;
	ptrd->func = funcd;
}
Esempio n. 2
0
File: config.cpp Progetto: 4play/xbt
int Cconfig::set(const std::string& name, bool value)
{
	if (t_attribute<bool>* i = find_ptr(m_attributes_bool, name))
		*i->value = value;
	else
		return 1;
	return 0;
}
Esempio n. 3
0
int Cconfig::set(const std::string& name, int value)
{
	if (t_attribute<int>* i = find_ptr(m_attributes_int, name))
		*i->value = value;
	// TorrentPier // listen_port
	else
		return set(name, static_cast<bool>(value));
	return 0;
}
Esempio n. 4
0
File: config.cpp Progetto: 4play/xbt
int Cconfig::set(const std::string& name, int value)
{
	if (t_attribute<int>* i = find_ptr(m_attributes_int, name))
		*i->value = value;
	else if (name == "listen_port")
		m_listen_ports.insert(value);
	else
		return set(name, static_cast<bool>(value));
	return 0;
}
Esempio n. 5
0
int str_add(TSTR_LIST *list,const char *text)
  {
  int count,i;
  TSTR_LIST p;

  count=str_count(*list);
  p=find_ptr(*list,NULL,count);
  i=p-*list;
  str_replace(list,i,text);
  return i;
  }
Esempio n. 6
0
static void handle_nvrm_ioctl_call(struct nvrm_ioctl_call *s, struct mmt_memory_dump *args, int argc)
{
	struct mmt_buf *data = find_ptr(s->ptr, args, argc);
	if (!data)
		return;

	if (s->mthd == NVRM_MTHD_FIFO_IB_OBJECT_INFO || s->mthd == NVRM_MTHD_FIFO_IB_OBJECT_INFO2)
	{
		struct nvrm_mthd_fifo_ib_object_info *s = (void *) data->data;
		pushbuf_add_object_name(s->handle, s->name);
	}
}
Esempio n. 7
0
const char *str_insline(TSTR_LIST *list,int before,const char *text)
  {
  int i,count,punkt;
  TSTR_LIST p;

  count=str_count(*list);
  p=find_ptr(*list,NULL,count);
  punkt=p-*list;
  str_replace(list,punkt,NULL);
  for(i=punkt;i>before;i--) (*list)[i]=(*list)[i-1];
  (*list)[before]=NULL;
  return str_replace(list,before,text);
  }
Esempio n. 8
0
File: config.cpp Progetto: 4play/xbt
int Cconfig::set(const std::string& name, const std::string& value)
{
	if (t_attribute<std::string>* i = find_ptr(m_attributes_string, name))
		*i->value = value;
	else if (name == "listen_ipa")
	{
		if (value != "*")
			m_listen_ipas.insert(inet_addr(value.c_str()));
	}
	else
		return set(name, atoi(value.c_str()));
	return 0;
}
Esempio n. 9
0
static void handle_nvrm_ioctl_create(uint32_t fd, struct nvrm_ioctl_create *s, struct mmt_memory_dump *args, int argc)
{
	if (s->status != NVRM_STATUS_SUCCESS)
		return;

	uint32_t cid = s->cid;
	uint32_t parent = s->parent;
	uint32_t handle = s->handle;

	struct mmt_buf *data = NULL;
	if (s->ptr)
		data = find_ptr(s->ptr, args, argc);

	if (handle == 0)
	{
		if (!data || data->len < 4)
		{
			mmt_error("\"create cid\" without data - probably because this trace was obtained by old mmt version (before Sep 6 2014)%s\n", "");
			cid_not_found++;
			return;
		}
		cid = parent = handle = ((uint32_t *)data->data)[0];
	}

	check_cid(cid);

	struct gpu_object *obj = nvrm_add_object(fd, cid, parent, handle, s->cls);
	pushbuf_add_object(handle, s->cls, obj);

	if (is_fifo_ib_class(s->cls))
	{
		if (data)
		{
			struct fifo_state *state = get_fifo_state(obj);
			struct nvrm_create_fifo_ib *create_data = (void *)data->data;
			state->ib.addr = create_data->ib_addr;
			state->ib.entries = create_data->ib_entries;
		}
	}
	else if (is_fifo_dma_class(s->cls))
	{
		if (data)
		{
			struct fifo_state *state = get_fifo_state(obj);
			struct nvrm_create_fifo_dma *create_data = (void *)data->data;
			state->user.addr = create_data->user_addr;
		}
	}
}
Esempio n. 10
0
static void remove_kmalloc(unsigned long long ptr)
{
	struct func_descr *funcd;
	struct ptr_descr *ptrd;

	ptrd = find_ptr(ptr);
	if (!ptrd)
		return;

	funcd = ptrd->func;
	funcd->current_alloc -= ptrd->alloc;
	funcd->current_req -= ptrd->req;

	remove_ptr(ptr);
}
Esempio n. 11
0
int Cconfig::set(const std::string& name, const std::string& value)
{
	if (t_attribute<std::string>* i = find_ptr(m_attributes_string, name))
		*i->value = value;
	else if (name == "listen_ipa")

	// TorrentPier begin
		m_listen_ipas.insert(value);
	else if (name == "listen_port")
		m_listen_ports.insert(value);
	// TorrentPier end

	else
		return set(name, atoi(value.c_str()));
	return 0;
}
Esempio n. 12
0
static int
del_ptr(void *mem)
{
    int loc;

    loc = find_ptr(mem);

    if (loc == max_ptr) {
        printf("del_ptr: not on list %p\n", mem);

        return FALSE;
    }

    ptr_list[loc] = NULL;

    return TRUE;
}
Esempio n. 13
0
void		ft_autocomplete(t_data *data)
{
	char		*tmp;

	if (is_empty_border_in_actual_cmd(data->cmd, data->index))
		return ;
	find_list_auto(data);
	if (!data->list_auto)
		return (list_auto_doesnt_exist(data));
	while (data->index > data->index_before_move)
		move_left_without_mod(data);
	exec_tcap("cd");
	tmp = data->cmd;
	data->cmd = ft_strsub(data->cmd, 0, data->index);
	free(tmp);
	tmp = data->list_auto->str +
		ft_strlen(find_ptr(data->absolute_cmd_before_cmd_before_move));
	ft_putstr(tmp);
	ft_autocomplete_2(data, tmp);
}
Esempio n. 14
0
static void handle_nvrm_ioctl_call(struct nvrm_ioctl_call *s, struct mmt_memory_dump *args, int argc)
{
	struct mmt_buf *data = find_ptr(s->ptr, args, argc);
	if (!data)
		return;

	if (s->mthd == NVRM_MTHD_FIFO_IB_OBJECT_INFO || s->mthd == NVRM_MTHD_FIFO_IB_OBJECT_INFO2)
	{
		struct nvrm_mthd_fifo_ib_object_info *mthd_data = (void *) data->data;
		struct gpu_object *obj = gpu_object_find(s->cid, s->handle);
		pushbuf_add_object_name(mthd_data->handle, mthd_data->name, obj);
	}
	else if (s->mthd == NVRM_MTHD_SUBDEVICE_GET_CHIPSET)
	{
		struct nvrm_mthd_subdevice_get_chipset *mthd_data = (void *) data->data;
		struct gpu_object *obj = gpu_object_find(s->cid, s->handle);
		if (obj)
			obj = nvrm_get_device(obj);
		if (obj)
			nvrm_device_set_chipset(obj, mthd_data->major | mthd_data->minor);
	}
}
Esempio n. 15
0
static void handle_nvrm_ioctl_create(struct nvrm_ioctl_create *s, struct mmt_memory_dump *args, int argc)
{
	if (s->status != NVRM_STATUS_SUCCESS)
		return;

	uint32_t cid = s->cid;
	uint32_t parent = s->parent;
	uint32_t handle = s->handle;
	if (handle == 0)
	{
		struct mmt_buf *data = find_ptr(s->ptr, args, argc);
		if (!data || data->len < 4)
		{
			mmt_error("\"create cid\" without data - probably because of old mmt (before Sep 6 2014) was used%s\n", "");
			return;
		}
		cid = parent = handle = ((uint32_t *)data->data)[0];
	}

	pushbuf_add_object(handle, s->cls);
	nvrm_add_object(cid, parent, handle, s->cls);
}
Esempio n. 16
0
void test_announce()
{
	t_user* u = find_ptr(m_users, 1);
	Ctracker_input i;
	i.m_info_hash = "IHIHIHIHIHIHIHIHIHIH";
	memcpy(i.m_peer_id.data(), str_ref("PIPIPIPIPIPIPIPIPIPI"));
	i.m_ipa = htonl(0x7f000063);
	i.m_port = 54321;
	std::cout << srv_insert_peer(i, false, u) << std::endl;
	write_db_torrents();
	write_db_users();
	m_time++;
	i.m_uploaded = 1 << 30;
	i.m_downloaded = 1 << 20;
	std::cout << srv_insert_peer(i, false, u) << std::endl;
	write_db_torrents();
	write_db_users();
	m_time += 3600;
	clean_up();
	write_db_torrents();
	write_db_users();
}
Esempio n. 17
0
const t_torrent* find_torrent(const std::string& id)
{
	return find_ptr(m_torrents, to_array<char, 20>(id));
}
Esempio n. 18
0
string mix_database::get_name(t_game game, int id)
{
	auto i = find_ptr(get_list(game), id);
	return i ? i->name : "";
}
Esempio n. 19
0
string mix_database::get_description(t_game game, int id)
{
	auto i = find_ptr(get_list(game), id);
	return i ? i->description : "";
}
 unsigned index_of(processor* pc) const
 {
     auto it = find_ptr(_container, pc);
     return std::distance(_container.begin(), it);
 }
Esempio n. 21
0
std::string srv_insert_peer(const Ctracker_input& v, bool udp, t_user* user)
{
	if (m_use_sql && m_config.m_log_announce)
	{
		m_announce_log_buffer += Csql_query(m_database, "(?,?,?,?,?,?,?,?,?,?),")
			(ntohl(v.m_ipa))
			(ntohs(v.m_port))
			(v.m_event)
			(v.m_info_hash)
			(v.m_peer_id)
			(v.m_downloaded)
			(v.m_left)
			(v.m_uploaded)
			(user ? user->uid : 0)
			(srv_time())
			.read();
	}
	if (!m_config.m_offline_message.empty())
		return m_config.m_offline_message;
	if (0)
		return bts_banned_client;
	if (!m_config.m_anonymous_announce && !user)
		return bts_unregistered_torrent_pass;
	if (!m_config.m_auto_register && !find_torrent(v.m_info_hash))
		return bts_unregistered_torrent;
	if (v.m_left && user && !user->can_leech)
		return bts_can_not_leech;
	t_torrent& file = m_torrents[to_array<char, 20>(v.m_info_hash)];
	if (!file.ctime)
		file.ctime = srv_time();
	if (v.m_left && user && user->wait_time && file.ctime + user->wait_time > srv_time())
		return bts_wait_time;
	peer_key_c peer_key(v.m_ipa, user ? user->uid : 0);
	t_peer* i = find_ptr(file.peers, peer_key);
	if (i)
		(i->left ? file.leechers : file.seeders)--;
	else if (v.m_left && user && user->peers_limit)
	{
		int c = 0;
		for (auto& j : file.peers)
			c += j.second.left && j.second.uid == user->uid;
		if (c >= user->peers_limit)
			return bts_peers_limit_reached;
	}
	if (m_use_sql && user && file.fid)
	{
		long long downloaded = 0;
		long long uploaded = 0;
		if (i
			&& i->uid == user->uid
			&& boost::equals(i->peer_id, v.m_peer_id)
			&& v.m_downloaded >= i->downloaded
			&& v.m_uploaded >= i->uploaded)
		{
			downloaded = v.m_downloaded - i->downloaded;
			uploaded = v.m_uploaded - i->uploaded;
		}
		m_torrents_users_updates_buffer += Csql_query(m_database, "(?,1,?,?,?,?,?,?,?),")
			(v.m_event != Ctracker_input::e_stopped)
			(v.m_event == Ctracker_input::e_completed)
			(downloaded)
			(v.m_left)
			(uploaded)
			(srv_time())
			(file.fid)
			(user->uid)
			.read();
		if (downloaded || uploaded)
			m_users_updates_buffer += Csql_query(m_database, "(?,?,?),")(downloaded)(uploaded)(user->uid).read();
		if (m_torrents_users_updates_buffer.size() > 255 << 10)
			write_db_users();
	}
	if (v.m_event == Ctracker_input::e_stopped)
		file.peers.erase(peer_key);
	else
	{
		t_peer& peer = i ? *i : file.peers[peer_key];
		peer.downloaded = v.m_downloaded;
		peer.left = v.m_left;
		peer.peer_id = v.m_peer_id;
		peer.port = v.m_port;
		peer.uid = user ? user->uid : 0;
		peer.uploaded = v.m_uploaded;
		(peer.left ? file.leechers : file.seeders)++;
		peer.mtime = srv_time();
	}
	if (v.m_event == Ctracker_input::e_completed)
		file.completed++;
	(udp ? m_stats.announced_udp : m_stats.announced_http)++;
	file.dirty = true;
	return std::string();
}
Esempio n. 22
0
t_user* find_user_by_uid(int v)
{
	return find_ptr(m_users, v);
}
Esempio n. 23
0
const std::string& Cdatabase::name(const std::string& v) const
{
	const std::string* i = find_ptr(m_names, v);
	assert(i);
	return i ? *i : v;
}