Main Page | Modules | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

dh.c File Reference


Detailed Description

Dynamic query hits.

Author:
Raphael Manfredi
Date:
2004

#include "common.h"
#include "dh.h"
#include "nodes.h"
#include "gmsg.h"
#include "mq.h"
#include "gnet_stats.h"
#include "lib/atoms.h"
#include "lib/misc.h"
#include "lib/tm.h"
#include "lib/walloc.h"
#include "if/gnet_property_priv.h"
#include "lib/override.h"

Data Structures

struct  dqhit
 Information about query hits received. More...

struct  pmsg_info
 Information about query messages sent. More...


Defines

#define DH_HALF_LIFE   300 /**< 5 minutes */
 5 minutes

#define DH_MIN_HITS   250 /**< Minimum amount of hits we try to relay */
 Minimum amount of hits we try to relay.

#define DH_POPULAR_HITS   500 /**< Query deemed popular after that many hits */
 Query deemed popular after that many hits.

#define DH_MAX_HITS   1000 /**< Maximum hits after which we heavily drop */
 Maximum hits after which we heavily drop.

#define DH_THRESH_HITS   10 /**< Consider we have no hits if less than that */
 Consider we have no hits if less than that.


Typedefs

typedef dqhit dqhit_t
 Information about query hits received.


Enumerations

enum  dh_drop { DH_FORWARD = 0, DH_DROP_FC, DH_DROP_THROTTLE }
 Drop reasons. More...


Functions

 RCSID ("$Id:dh.c, v 1.15 2005/08/31 21:37:28 rmanfredi Exp $")
gboolean free_muid_true (gpointer key, gpointer value, gpointer unused_udata)
 Hashtable iteration callback to free the MUIDs in the `by_muid' table, and the associated dqhit_t objects.

void dh_table_clear (GHashTable *ht)
 Clear specified hash table.

void dh_table_free (GHashTable *ht)
 Free specified hash table.

dqhit_tdh_locate (const gchar *muid)
 Locate record for query hits for specified MUID.

dqhit_tdh_create (const gchar *muid)
 Create new record for query hits for specified MUID.

void dh_got_results (const gchar *muid, gint count)
 Called every time we successfully parsed a query hit from the network.

void dh_timer (time_t now)
 Periodic heartbeat, to rotate the hash tables every half-life period.

void dh_pmsg_free (pmsg_t *mb, gpointer arg)
 Free routine for query hit message.

enum dh_drop dh_can_forward (dqhit_t *dh, mqueue_t *mq, gboolean test)
 Based on the information we have on the query hits we already seen or enqueued, determine whether we're going to drop this message on the floor or forward it.

void dh_route (gnutella_node_t *src, gnutella_node_t *dest, gint count)
 Route query hits from one node to the other.

gboolean dh_would_route (const gchar *muid, gnutella_node_t *dest)
 If we had to route hits to the specified node destination, would we?

void dh_init (void)
 Initialize dynamic hits.

void dh_close (void)
 Cleanup data structures used by dynamic querying.


Variables

GHashTable * by_muid = NULL
GHashTable * by_muid_old = NULL
time_t last_rotation


Define Documentation

#define DH_HALF_LIFE   300 /**< 5 minutes */
 

5 minutes

#define DH_MAX_HITS   1000 /**< Maximum hits after which we heavily drop */
 

Maximum hits after which we heavily drop.

#define DH_MIN_HITS   250 /**< Minimum amount of hits we try to relay */
 

Minimum amount of hits we try to relay.

#define DH_POPULAR_HITS   500 /**< Query deemed popular after that many hits */
 

Query deemed popular after that many hits.

#define DH_THRESH_HITS   10 /**< Consider we have no hits if less than that */
 

Consider we have no hits if less than that.


Typedef Documentation

typedef struct dqhit dqhit_t
 

Information about query hits received.


Enumeration Type Documentation

enum dh_drop
 

Drop reasons.

Enumeration values:
DH_FORWARD  Don't drop.
DH_DROP_FC  Drop because of flow-control.
DH_DROP_THROTTLE  Drop because of hit throttling.


Function Documentation

enum dh_drop dh_can_forward dqhit_t dh,
mqueue_t mq,
gboolean  test
[static]
 

Based on the information we have on the query hits we already seen or enqueued, determine whether we're going to drop this message on the floor or forward it.

void dh_close void   ) 
 

Cleanup data structures used by dynamic querying.

dqhit_t* dh_create const gchar *  muid  )  [static]
 

Create new record for query hits for specified MUID.

New record is registered in the current table.

void dh_got_results const gchar *  muid,
gint  count
 

Called every time we successfully parsed a query hit from the network.

void dh_init void   ) 
 

Initialize dynamic hits.

dqhit_t* dh_locate const gchar *  muid  )  [static]
 

Locate record for query hits for specified MUID.

Returns:
located record, or NULL if not found.

void dh_pmsg_free pmsg_t mb,
gpointer  arg
[static]
 

Free routine for query hit message.

void dh_route gnutella_node_t src,
gnutella_node_t dest,
gint  count
 

Route query hits from one node to the other.

void dh_table_clear GHashTable *  ht  )  [static]
 

Clear specified hash table.

void dh_table_free GHashTable *  ht  )  [static]
 

Free specified hash table.

void dh_timer time_t  now  ) 
 

Periodic heartbeat, to rotate the hash tables every half-life period.

gboolean dh_would_route const gchar *  muid,
gnutella_node_t dest
 

If we had to route hits to the specified node destination, would we?

gboolean free_muid_true gpointer  key,
gpointer  value,
gpointer  unused_udata
[static]
 

Hashtable iteration callback to free the MUIDs in the `by_muid' table, and the associated dqhit_t objects.

RCSID "$Id:dh.  c,
v 1.15 2005/08/31 21:37:28 rmanfredi Exp $" 
 


Variable Documentation

GHashTable* by_muid = NULL [static]
 

GHashTable* by_muid_old = NULL [static]
 

time_t last_rotation [static]
 


Generated on Sun Feb 12 10:49:59 2006 for Gtk-Gnutella by doxygen 1.3.6