本文整理匯總了C++中GNET_PROPERTY函數的典型用法代碼示例。如果您正苦於以下問題:C++ GNET_PROPERTY函數的具體用法?C++ GNET_PROPERTY怎麽用?C++ GNET_PROPERTY使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了GNET_PROPERTY函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: knode_change_vendor
/**
* Change node's vendor code.
*/
void
knode_change_vendor(knode_t *kn, vendor_code_t vcode)
{
knode_check(kn);
if (GNET_PROPERTY(dht_debug)) {
char vc_old[VENDOR_CODE_BUFLEN];
char vc_new[VENDOR_CODE_BUFLEN];
vendor_code_to_string_buf(kn->vcode.u32, vc_old, sizeof vc_old);
vendor_code_to_string_buf(vcode.u32, vc_new, sizeof vc_new);
g_warning("DHT node %s at %s changed vendor from %s to %s",
kuid_to_hex_string(kn->id),
host_addr_port_to_string(kn->addr, kn->port),
vc_old, vc_new);
}
kn->vcode = vcode;
}
示例2: huge_need_sha1
/**
* Look whether we still need to compute the SHA1 of the given shared file
* by looking into our in-core cache to see whether the entry we have is
* up-to-date.
*
* @param sf the shared file for which we want to compute the SHA1
*
* @return TRUE if the file need SHA1 recomputation.
*/
static bool
huge_need_sha1(shared_file_t *sf)
{
struct sha1_cache_entry *cached;
shared_file_check(sf);
/*
* After a rescan, there might be files in the queue which are
* no longer shared.
*/
if (!shared_file_indexed(sf))
return FALSE;
if G_UNLIKELY(NULL == sha1_cache)
return FALSE; /* Shutdown occurred (processing TEQ event?) */
cached = hikset_lookup(sha1_cache, shared_file_path(sf));
if (cached != NULL) {
filestat_t sb;
if (-1 == stat(shared_file_path(sf), &sb)) {
g_warning("ignoring SHA1 recomputation request for \"%s\": %m",
shared_file_path(sf));
return FALSE;
}
if (
cached->size + (fileoffset_t) 0 == sb.st_size + (filesize_t) 0 &&
cached->mtime == sb.st_mtime
) {
if (GNET_PROPERTY(share_debug) > 1) {
g_warning("ignoring duplicate SHA1 work for \"%s\"",
shared_file_path(sf));
}
return FALSE;
}
}
return TRUE;
}
示例3: keys_reclaim
/**
* Reclaim key info and data.
*
* @param ki the keyinfo to reclaim
* @param can_remove whether to remove from the `keys' set
*/
static void
keys_reclaim(struct keyinfo *ki, bool can_remove)
{
g_assert(ki);
g_assert(0 == ki->values);
if (GNET_PROPERTY(dht_storage_debug) > 2)
g_debug("DHT STORE key %s reclaimed", kuid_to_hex_string(ki->kuid));
dbmw_delete(db_keydata, ki->kuid);
if (can_remove)
hikset_remove(keys, &ki->kuid);
gnet_stats_dec_general(GNR_DHT_KEYS_HELD);
if (ki->flags & DHT_KEY_F_CACHED)
gnet_stats_dec_general(GNR_DHT_CACHED_KEYS_HELD);
kuid_atom_free_null(&ki->kuid);
ki->magic = 0;
WFREE(ki);
}
示例4: keys_periodic_load
/**
* Callout queue periodic event for request load updates.
* Also reclaims dead keys holding no values.
*/
static bool
keys_periodic_load(void *unused_obj)
{
struct load_ctx ctx;
(void) unused_obj;
ctx.values = 0;
ctx.now = tm_time();
hikset_foreach_remove(keys, keys_update_load, &ctx);
g_assert(values_count() == ctx.values);
if (GNET_PROPERTY(dht_storage_debug)) {
size_t keys_count = hikset_count(keys);
g_debug("DHT holding %zu value%s spread over %zu key%s",
ctx.values, plural(ctx.values), keys_count, plural(keys_count));
}
return TRUE; /* Keep calling */
}
示例5: sq_clear
/**
* Clear all queued searches.
*/
void
sq_clear(squeue_t *sq)
{
GList *l;
g_assert(sq);
if (GNET_PROPERTY(sq_debug) > 3)
g_debug("clearing sq node %s (sent=%d, dropped=%d)",
sq->node ? node_addr(sq->node) : "GLOBAL",
sq->n_sent, sq->n_dropped);
for (l = sq->searches; l; l = g_list_next(l)) {
smsg_t *sb = l->data;
smsg_discard(sb);
}
gm_list_free_null(&sq->searches);
sq->count = 0;
}
示例6: natpmp_update
/**
* Update internal information about the NAT-PMP gateway upon reception
* of an RPC reply.
*/
static void
natpmp_update(natpmp_t *np, unsigned sssoe)
{
time_delta_t d;
unsigned conservative_sssoe;
natpmp_check(np);
d = delta_time(tm_time(), np->last_update);
conservative_sssoe = uint_saturate_add(np->sssoe, 7 * d / 8);
if (sssoe < conservative_sssoe && conservative_sssoe - sssoe > 1) {
np->rebooted = TRUE;
if (GNET_PROPERTY(natpmp_debug) > 1) {
g_debug("NATPMP new SSSOE=%u < conservative SSSOE=%u, %s rebooted",
sssoe, conservative_sssoe, host_addr_to_string(np->gateway));
}
}
np->last_update = tm_time();
np->sssoe = sssoe;
}
示例7: guid_add_banned
/**
* Add GUID to the banned list or refresh the fact that we are still seeing
* it as being worth banning.
*/
void
guid_add_banned(const struct guid *guid)
{
struct guiddata *gd;
struct guiddata new_gd;
gd = get_guiddata(guid);
if (NULL == gd) {
gd = &new_gd;
gd->create_time = gd->last_time = tm_time();
gnet_stats_inc_general(GNR_BANNED_GUID_HELD);
if (GNET_PROPERTY(guid_debug)) {
g_debug("GUID banning %s", guid_hex_str(guid));
}
} else {
gd->last_time = tm_time();
}
dbmw_write(db_guid, guid, gd, sizeof *gd);
}
示例8: dump_tx_udp_packet
/**
* Dump locally-emitted message block sent via UDP.
*/
void
dump_tx_udp_packet(const gnet_host_t *to, const pmsg_t *mb)
{
if (GNET_PROPERTY(dump_transmitted_gnutella_packets)) {
struct gnutella_node udp;
g_assert(to != NULL);
g_assert(mb != NULL);
/*
* Fill only the fields which will be perused by
* dump_packet_from_to().
*/
udp.peermode = NODE_P_UDP;
udp.addr = gnet_host_get_addr(to);
udp.port = gnet_host_get_port(to);
dump_packet_from_to(&dump_tx, NULL, &udp, mb);
} else if (dump_tx.initialized) {
dump_disable(&dump_tx);
}
}
示例9: host_cache_allow_bypass
/*
* Avoid nodes being stuck helplessly due to completely stale caches.
* @return TRUE if an UHC may be contact, FALSE if it's not permissable.
*/
static gboolean
host_cache_allow_bypass(void)
{
static time_t last_try;
if (node_count() > 0)
return FALSE;
/* Wait at least 2 minutes after starting up */
if (delta_time(tm_time(), GNET_PROPERTY(start_stamp)) < 2 * 60)
return FALSE;
/*
* Allow again after 12 hours, useful after unexpected network outage
* or downtime.
*/
if (last_try && delta_time(tm_time(), last_try) < 12 * 3600)
return FALSE;
last_try = tm_time();
return TRUE;
}
示例10: ctl_limit
/**
* Are specified flags all set for the country to which the IP address belongs?
*/
bool
ctl_limit(const host_addr_t ha, unsigned flags)
{
uint16 code;
unsigned cflags;
/*
* Early optimization to avoid paying the price of gip_country_safe():
* If no flags are given, or the set of flags requested is not a subset
* of all the flags ever specified for all countries, we can return.
*/
if (0 == flags)
return FALSE;
if ((flags & ctl_all_flags) != flags)
return FALSE;
code = gip_country_safe(ha);
if (ISO3166_INVALID == code)
return FALSE;
if (GNET_PROPERTY(ancient_version))
return FALSE;
cflags = pointer_to_uint(
htable_lookup(ctl_by_country, uint_to_pointer(code)));
if ((cflags & flags) != flags)
return FALSE;
if ((cflags & CTL_D_WHITELIST) && whitelist_check(ha))
return FALSE;
return TRUE;
}
示例11: hsep_notify_shared
void
hsep_notify_shared(uint64 own_files, uint64 own_kibibytes)
{
/* check for change */
if (
own_files != hsep_own[HSEP_IDX_FILES] ||
own_kibibytes != hsep_own[HSEP_IDX_KIB]
) {
if (GNET_PROPERTY(hsep_debug)) {
g_debug("HSEP: Shared files changed to %s (%s KiB)",
uint64_to_string(own_files), uint64_to_string2(own_kibibytes));
}
hsep_own[HSEP_IDX_FILES] = own_files;
hsep_own[HSEP_IDX_KIB] = own_kibibytes;
/*
* We could send a HSEP message to all nodes now, but these changes
* will propagate within at most HSEP_MSG_INTERVAL + HSEP_MSG_SKEW
* seconds anyway.
*/
}
}
示例12: tls_socket_evt_change
/**
* Change the monitoring condition on the socket.
*/
static void
tls_socket_evt_change(struct gnutella_socket *s, inputevt_cond_t cond)
{
socket_check(s);
g_assert(socket_with_tls(s)); /* No USES yet, may not have handshaked */
g_assert(INPUT_EVENT_EXCEPTION != cond);
if (0 == s->gdk_tag)
return;
if (cond != s->tls.cb_cond) {
int saved_errno = errno;
if (GNET_PROPERTY(tls_debug) > 1) {
int fd = socket_evt_fd(s);
g_debug("tls_socket_evt_change: fd=%d, cond=%s -> %s",
fd, inputevt_cond_to_string(s->tls.cb_cond),
inputevt_cond_to_string(cond));
}
inputevt_remove(&s->gdk_tag);
socket_evt_set(s, cond, s->tls.cb_handler, s->tls.cb_data);
errno = saved_errno;
}
}
示例13: stable_init
/**
* Initialize node stability caching.
*/
G_GNUC_COLD void
stable_init(void)
{
dbstore_kv_t kv = { KUID_RAW_SIZE, NULL, sizeof(struct lifedata), 0 };
dbstore_packing_t packing =
{ serialize_lifedata, deserialize_lifedata, NULL };
g_assert(NULL == db_lifedata);
g_assert(NULL == stable_sync_ev);
g_assert(NULL == stable_prune_ev);
db_lifedata = dbstore_open(db_stable_what, settings_dht_db_dir(),
db_stable_base, kv, packing, STABLE_DB_CACHE_SIZE, kuid_hash, kuid_eq,
GNET_PROPERTY(dht_storage_in_memory));
dbmw_set_map_cache(db_lifedata, STABLE_MAP_CACHE_SIZE);
stable_prune_old();
stable_sync_ev = cq_periodic_main_add(STABLE_SYNC_PERIOD,
stable_sync, NULL);
stable_prune_ev = cq_periodic_main_add(STABLE_PRUNE_PERIOD,
stable_periodic_prune, NULL);
}
示例14: gnet_stats_count_dropped_nosize
void
gnet_stats_count_dropped_nosize(
const gnutella_node_t *n, msg_drop_reason_t reason)
{
uint type;
gnet_stats_t *stats;
g_assert(UNSIGNED(reason) < MSG_DROP_REASON_COUNT);
g_assert(thread_is_main());
g_assert(!NODE_TALKS_G2(n));
type = stats_lut[gnutella_header_get_function(&n->header)];
stats = NODE_USES_UDP(n) ? &gnet_udp_stats : &gnet_tcp_stats;
entropy_harvest_small(VARLEN(n->addr), VARLEN(n->port), NULL);
/* Data part of message not read */
DROP_STATS(stats, type, sizeof(n->header));
if (GNET_PROPERTY(log_dropped_gnutella))
gmsg_log_split_dropped(&n->header, n->data, 0,
"from %s: %s", node_infostr(n),
gnet_stats_drop_reason_to_string(reason));
}
示例15: sq_puthere
/**
* Enqueue query message in specified queue.
*/
static void
sq_puthere(squeue_t *sq, gnet_search_t sh, pmsg_t *mb, query_hashvec_t *qhv)
{
smsg_t *sb;
g_assert(sq);
g_assert(mb);
if (sqh_exists(sq, sh)) {
pmsg_free(mb);
if (qhv)
qhvec_free(qhv);
return; /* Search already in queue */
}
sb = smsg_alloc(sh, mb, qhv);
sqh_put(sq, sh);
sq->searches = g_list_prepend(sq->searches, sb);
sq->count++;
if (sq->count > GNET_PROPERTY(search_queue_size))
cap_queue(sq);
}