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

parq.c File Reference


Detailed Description

Passive/Active Remote Queuing.

Author:
Jeroen Asselman

Raphael Manfredi

Date:
2003-2005

#include "common.h"
#include "parq.h"
#include "ban.h"
#include "downloads.h"
#include "dmesh.h"
#include "features.h"
#include "guid.h"
#include "http.h"
#include "ioheader.h"
#include "settings.h"
#include "share.h"
#include "sockets.h"
#include "gnet_stats.h"
#include "hosts.h"
#include "if/gnet_property.h"
#include "if/gnet_property_priv.h"
#include "lib/atoms.h"
#include "lib/file.h"
#include "lib/getdate.h"
#include "lib/getline.h"
#include "lib/glib-missing.h"
#include "lib/tm.h"
#include "lib/walloc.h"
#include "lib/override.h"

Data Structures

struct  parq_banned
struct  parq_ul_queue
 Holds status of current queue. More...

struct  parq_ul_queued_by_addr
struct  parq_ul_queued
 Contains the queued upload. More...

struct  parq_dl_queued
 Contains the queued download status. More...

struct  parq_tag
struct  parq_entry_t

Defines

#define PARQ_VERSION_MAJOR   1
#define PARQ_VERSION_MINOR   0
#define PARQ_RETRY_SAFETY   40 /**< 40 seconds before lifetime */
 40 seconds before lifetime

#define PARQ_TIMER_BY_POS   30 /**< 30 seconds for each queue position */
 30 seconds for each queue position

#define GUARDING_TIME   45 /**< Time we keep a slot after disconnect */
 Time we keep a slot after disconnect.

#define MIN_LIFE_TIME   90
#define QUEUE_PERIOD   600 /**< Try to resend a queue every 10 min. */
 Try to resend a queue every 10 min.

#define MAX_QUEUE   144 /**< Max amount of QUEUE we can send */
 Max amount of QUEUE we can send.

#define MAX_QUEUE_REFUSED   2 /**< Max QUEUE they can refuse in a row */
 Max QUEUE they can refuse in a row.

#define MAX_UPLOADS   100 /**< Avoid more than that many uploads */
 Avoid more than that many uploads.

#define MAX_UPLOAD_QSIZE   4000 /**< Size of the PARQ queue */
 Size of the PARQ queue.

#define MEBI   (1024 * 1024)
#define PARQ_UL_LARGE_SIZE   (300 * MEBI)
#define PARQ_UL_MAGIC   0x6a3900a1
#define PARQ_UL_QUEUE   0x00000001 /**< Scheduled for QUEUE sending */
 Scheduled for QUEUE sending.

#define PARQ_UL_NOQUEUE   0x00000002 /**< No IP:port, don't send QUEUE */
 No IP:port, don't send QUEUE.

#define PARQ_UL_QUEUE_SENT   0x00000004 /**< QUEUE message sent */
 QUEUE message sent.

#define PARQ_UL_ID_SENT   0x00000008 /**< We already sent an ID */
 We already sent an ID.

#define PARQ_TAG(x)   { CAT2(PARQ_TAG_,x), STRINGIFY(x) }
#define GET_ITEM(i)   (parq_tag_map[(i)].str)
#define FOUND(i)
#define bs_nop(x)   (x)

Enumerations

enum  parq_tag_t {
  PARQ_TAG_UNKNOWN = 0, PARQ_TAG_ENTERED, PARQ_TAG_EXPIRE, PARQ_TAG_ID,
  PARQ_TAG_IP, PARQ_TAG_NAME, PARQ_TAG_POS, PARQ_TAG_QUEUE,
  PARQ_TAG_SHA1, PARQ_TAG_SIZE, PARQ_TAG_XIP, PARQ_TAG_XPORT,
  PARQ_TAG_QUEUESSENT, PARQ_TAG_SENDNEXTQUEUE, NUM_PARQ_TAGS
}

Functions

 RCSID ("$Id:parq.c, v 1.55 2006/01/10 10:32:57 cbiere Exp $")
void parq_dl_del_id (struct download *d)
 Remove the memory used by the ID string, and removes it from various lists.

void parq_upload_free (struct parq_ul_queued *parq_ul)
 removes an parq_ul from the parq list and frees all its memory.

parq_ul_queuedparq_upload_create (gnutella_upload_t *u)
 Creates a new upload structure and prefills some values.

parq_ul_queueparq_upload_which_queue (gnutella_upload_t *u)
 Looks up in which queue the current upload should be placed and if the queue doesn't exist yet it will be created.

parq_ul_queueparq_upload_new_queue ()
 Creates a new parq_ul_queue structure and places it in the ul_parqs linked list.

void parq_upload_free_queue (struct parq_ul_queue *queue)
 Frees the queue from memory and the ul_parqs linked list.

void parq_upload_update_eta (struct parq_ul_queue *which_ul_queue)
 Updates the ETA of all queued items in the given queue.

parq_ul_queuedparq_upload_find (const gnutella_upload_t *u)
 Finds an upload if available in the upload queue.

gint parq_ul_rel_pos_cmp (gconstpointer a, gconstpointer b)
 Function used to keep the relative position list sorted by relative position.

gboolean parq_upload_continue (struct parq_ul_queued *uq, gint free_slots)
void parq_upload_decrease_all_after (struct parq_ul_queued *cur_parq_ul)
 Decreases the position of all queued items after the given queued item.

void parq_upload_load_queue ()
 Loads the saved queue status back into memory.

void parq_upload_update_relative_position (struct parq_ul_queued *parq_ul)
 Updates the relative position of all queued after the given queued item.

void parq_upload_update_addr_and_name (struct parq_ul_queued *parq_ul, gnutella_upload_t *u)
 Updates the IP and name entry in the queued structure and makes sure the hash table remains in sync.

void parq_upload_register_send_queue (struct parq_ul_queued *parq_ul)
 Possibly register the upload in the list for deferred QUEUE sending.

void parq_upload_send_queue (struct parq_ul_queued *parq_ul)
 Sends a QUEUE to a parq enabled client.

gboolean parq_still_sharing (struct parq_ul_queued *)
 Determine if we are still sharing this file, so that PARQ can determine if it makes sense to keep this file in the queue.

void parq_add_banned_source (const host_addr_t addr, time_t delay)
 Adds an ip to the parq ban list.

void parq_del_banned_source (const host_addr_t addr)
 Removes a banned ip from the parq banned list.

gboolean get_header_version (gchar const *const header, guint *major, guint *minor)
 Get header version.

gchar * get_header_value (gchar *const s, gchar const *const attribute, size_t *length)
 Get header value.

const gchar * get_parq_dl_id (const struct download *d)
 Retrieves the PARQ ID associated with an download.

gint get_parq_dl_position (const struct download *d)
 Retrieves the remote queued position associated with an download.

gint get_parq_dl_queue_length (const struct download *d)
 Retrieves the remote queue size associated with an download.

gint get_parq_dl_eta (const struct download *d)
 Retrieves the estimated time of arival for a queued download.

gint get_parq_dl_retry_delay (const struct download *d)
 Retrieves the retry rate at which a queued download should retry.

void parq_download_retry_active_queued (struct download *d)
 Active queued means we didn't close the http connection on a HTTP 503 busy when the server supports queueing.

guint get_integer (const gchar *buf)
 Convenience wrapper on top of parse_uint32().

void parq_dl_remove (struct download *d)
 Tells the parq logic that a download has been removed.

void parq_dl_free (struct download *d)
 Removes the queue information for a download from memory.

gpointer parq_dl_create (struct download *d)
 Creates a queue structure for a download.

void parq_dl_add_id (struct download *d, const gchar *new_id)
 Assigns an parq ID to a download, and places them in various lists for lookup.

void parq_dl_reparent_id (struct download *d, struct download *cd)
 Called from download_clone to reparent the PARQ ID from the parent `d' to the cloned `cd'.

void parq_dl_update_id (struct download *d, const gchar *temp)
 Updates a parq id if needed.

gboolean parq_download_parse_queue_status (struct download *d, header_t *header)
 Retrieve and parse queueing information.

gboolean parq_download_is_active_queued (struct download *d)
 Whether the download is queued remotely or not.

gboolean parq_download_is_passive_queued (struct download *d)
 Whether the download is queued remotely without keeping the connection or not.

void parq_download_add_header (gchar *buf, size_t len, size_t *rw, struct download *d)
 Needs brief description here.

void parq_download_queue_ack (struct gnutella_socket *s)
 parq_download_queue_ack

parq_ul_queuedhandle_to_queued (gpointer handle)
 Convert a handle to a `parq_ul_queued' structure.

guint32 parq_ul_calc_retry (struct parq_ul_queued *parq_ul)
 Calculates the retry delay for an upload.

parq_ul_queuedparq_upload_find_id (header_t *header)
void parq_upload_timer (time_t now)
 Removes any PARQ uploads which show no activity.

gboolean parq_upload_queue_full (gnutella_upload_t *u)
gboolean parq_upload_queued (gnutella_upload_t *u)
 Whether the current upload is already queued.

parq_ul_queuedparq_upload_get_at (struct parq_ul_queue *queue, int position)
 Get parq structure at specified position.

gboolean parq_upload_addr_can_proceed (const gnutella_upload_t *u)
 Check that the IP is not already downloading more than is alllowed.

gboolean parq_upload_quick_continue (struct parq_ul_queued *uq, gint used_slots)
void parq_upload_upload_got_cloned (gnutella_upload_t *u, gnutella_upload_t *cu)
void parq_upload_upload_got_freed (gnutella_upload_t *u)
 Makes sure parq doesn't keep any internal reference to the upload structure.

gpointer parq_upload_get (gnutella_upload_t *u, header_t *header, gboolean replacing)
 Get a queue slot, either existing or new.

gboolean parq_upload_request_force (gnutella_upload_t *u, gpointer handle, guint used_slots)
 If the download may continue, true is returned.

gboolean parq_upload_request (gnutella_upload_t *u, guint used_slots)
void parq_upload_busy (gnutella_upload_t *u, gpointer handle)
 Mark an upload as really being active instead of just being queued.

void parq_upload_add (gnutella_upload_t *unused_u)
void parq_upload_force_remove (gnutella_upload_t *u)
void parq_upload_collect_stats (const gnutella_upload_t *u)
 Collect running stats about the completed / removed upload.

gboolean parq_upload_remove (gnutella_upload_t *u)
 When an upload is removed this function should be called so parq knows the current upload status of an upload.

void parq_upload_add_header (gchar *buf, gint *retval, gpointer arg, guint32 flags)
 Adds X-Queued status in the HTTP reply header for a queued upload.

void parq_upload_add_header_id (gchar *buf, gint *retval, gpointer arg, guint32 unused_flags)
 Adds X-Queued status in the HTTP reply header showing the queue ID for an upload getting a slot.

gboolean parq_ul_id_sent (const gnutella_upload_t *u)
 Determines whether the PARQ ID was already sent for an upload.

guint parq_upload_lookup_position (const gnutella_upload_t *u)
const gchar * parq_upload_lookup_id (const gnutella_upload_t *u)
guint parq_upload_lookup_eta (const gnutella_upload_t *u)
guint parq_upload_lookup_size (const gnutella_upload_t *u)
time_t parq_upload_lookup_lifetime (const gnutella_upload_t *u)
time_t parq_upload_lookup_retry (const gnutella_upload_t *u)
guint parq_upload_lookup_queue_no (const gnutella_upload_t *u)
gboolean parq_upload_lookup_quick (const gnutella_upload_t *u)
void parq_upload_send_queue_conf (gnutella_upload_t *u)
 'Call back' connection was succesfull.

void parq_store (gpointer data, gpointer file_ptr)
 Saves an individual queued upload to disc.

void parq_upload_save_queue (void)
 Saves all the current queues and their items so it can be restored when the client starts up again.

parq_tag_t parq_string_to_tag (const gchar *s)
time_t parq_banned_source_expire (const host_addr_t addr)
void parq_init (void)
 Initialises the upload queue for PARQ.

void parq_close (void)
 Saves any queueing information and frees all memory used by PARQ.


Variables

GHashTable * dl_all_parq_by_id = NULL
guint parq_max_upload_size = MAX_UPLOAD_QSIZE
guint parq_upload_active_size = 20
 parq_upload_active_size is the maximum number of active upload slots per queue.

guint parq_upload_ban_window = 600
const gchar file_parq_file [] = "parq"
GList * ul_parqs = NULL
 List of all queued uploads.

GList * ul_parq_queue = NULL
 To whom we need to send a QUEUE.

GHashTable * ul_all_parq_by_addr_and_name = NULL
GHashTable * ul_all_parq_by_addr = NULL
GHashTable * ul_all_parq_by_id = NULL
gboolean enable_real_passive = TRUE
 If enable_real_passive is TRUE, a dead upload is only marked dead, if FALZE, a dead upload is really removed and cannot reclaim its position.

GHashTable * ht_banned_source = NULL
GList * parq_banned_sources = NULL
gboolean parq_shutdown = FALSE
const struct parq_tag parq_tag_map []


Define Documentation

#define bs_nop  )     (x)
 

#define FOUND  ) 
 

Value:

G_STMT_START { \
    return parq_tag_map[(i)].tag; \
    /* NOTREACHED */ \
} G_STMT_END

#define GET_ITEM  )     (parq_tag_map[(i)].str)
 

#define GUARDING_TIME   45 /**< Time we keep a slot after disconnect */
 

Time we keep a slot after disconnect.

#define MAX_QUEUE   144 /**< Max amount of QUEUE we can send */
 

Max amount of QUEUE we can send.

#define MAX_QUEUE_REFUSED   2 /**< Max QUEUE they can refuse in a row */
 

Max QUEUE they can refuse in a row.

#define MAX_UPLOAD_QSIZE   4000 /**< Size of the PARQ queue */
 

Size of the PARQ queue.

#define MAX_UPLOADS   100 /**< Avoid more than that many uploads */
 

Avoid more than that many uploads.

#define MEBI   (1024 * 1024)
 

#define MIN_LIFE_TIME   90
 

#define PARQ_RETRY_SAFETY   40 /**< 40 seconds before lifetime */
 

40 seconds before lifetime

#define PARQ_TAG  )     { CAT2(PARQ_TAG_,x), STRINGIFY(x) }
 

#define PARQ_TIMER_BY_POS   30 /**< 30 seconds for each queue position */
 

30 seconds for each queue position

#define PARQ_UL_ID_SENT   0x00000008 /**< We already sent an ID */
 

We already sent an ID.

#define PARQ_UL_LARGE_SIZE   (300 * MEBI)
 

#define PARQ_UL_MAGIC   0x6a3900a1
 

#define PARQ_UL_NOQUEUE   0x00000002 /**< No IP:port, don't send QUEUE */
 

No IP:port, don't send QUEUE.

#define PARQ_UL_QUEUE   0x00000001 /**< Scheduled for QUEUE sending */
 

Scheduled for QUEUE sending.

#define PARQ_UL_QUEUE_SENT   0x00000004 /**< QUEUE message sent */
 

QUEUE message sent.

#define PARQ_VERSION_MAJOR   1
 

#define PARQ_VERSION_MINOR   0
 

#define QUEUE_PERIOD   600 /**< Try to resend a queue every 10 min. */
 

Try to resend a queue every 10 min.


Enumeration Type Documentation

enum parq_tag_t
 

Enumeration values:
PARQ_TAG_UNKNOWN 
PARQ_TAG_ENTERED 
PARQ_TAG_EXPIRE 
PARQ_TAG_ID 
PARQ_TAG_IP 
PARQ_TAG_NAME 
PARQ_TAG_POS 
PARQ_TAG_QUEUE 
PARQ_TAG_SHA1 
PARQ_TAG_SIZE 
PARQ_TAG_XIP 
PARQ_TAG_XPORT 
PARQ_TAG_QUEUESSENT 
PARQ_TAG_SENDNEXTQUEUE 
NUM_PARQ_TAGS 


Function Documentation

gchar* get_header_value gchar *const  s,
gchar const *const  attribute,
size_t *  length
[static]
 

Get header value.

Retrieves a value from a header line. If possible the length (in gchars) is returned for that value.

Parameters:
s is a pointer to the header string that will be parsed.
attribute is the attribute which will be searched in the header string
length is a pointer to a size_t variable which will contain the length of the header value, if parsing was successful.
Returns:
a pointer in the s pointer indicating the start of the header value.

gboolean get_header_version gchar const *const  header,
guint *  major,
guint *  minor
[static]
 

Get header version.

Extract the version from a given header. EG: X-Queue: 1.0 major=1 minor=0

Parameters:
header is a pointer to the header string that will be parsed for the version number
major is a pointer to a gint in which the major version number will be returned on success.
minor is a pointer to a gint in which the minor version number will be returned on success.
Returns:
a boolean which is true when parsing of the header version was successful.

guint get_integer const gchar *  buf  )  [static]
 

Convenience wrapper on top of parse_uint32().

Returns:
parsed integer (base 10), or 0 if none could be found.

gint get_parq_dl_eta const struct download d  ) 
 

Retrieves the estimated time of arival for a queued download.

Returns:
the relative eta or 0 if download is not queued or queuing status is unknown.

const gchar* get_parq_dl_id const struct download d  ) 
 

Retrieves the PARQ ID associated with an download.

Returns:
a gchar pointer to the ID, or NULL if no ID is available.

gint get_parq_dl_position const struct download d  ) 
 

Retrieves the remote queued position associated with an download.

Returns:
the remote queued position or 0 if download is not queued or queuing status is unknown

gint get_parq_dl_queue_length const struct download d  ) 
 

Retrieves the remote queue size associated with an download.

Returns:
the remote queue size or 0 if download is not queued or queueing status is unknown.

gint get_parq_dl_retry_delay const struct download d  ) 
 

Retrieves the retry rate at which a queued download should retry.

Returns:
the retry rate or 0 if download is not queued or queueing status is unknown.

struct parq_ul_queued* handle_to_queued gpointer  handle  )  [inline, static]
 

Convert a handle to a `parq_ul_queued' structure.

void parq_add_banned_source const host_addr_t  addr,
time_t  delay
 

Adds an ip to the parq ban list.

This list is used to deny connections from such a host. Sources will only make it in this list when they ignore our delay Retry-After header twice.

time_t parq_banned_source_expire const host_addr_t  addr  ) 
 

Returns:
expiration timestamp if source is banned, or 0 if it isn't banned.

void parq_close void   ) 
 

Saves any queueing information and frees all memory used by PARQ.

void parq_del_banned_source const host_addr_t  addr  ) 
 

Removes a banned ip from the parq banned list.

void parq_dl_add_id struct download d,
const gchar *  new_id
 

Assigns an parq ID to a download, and places them in various lists for lookup.

gpointer parq_dl_create struct download d  ) 
 

Creates a queue structure for a download.

Returns:
a parq_dl_queued pointer to the newly created structure.

void parq_dl_del_id struct download d  ) 
 

Remove the memory used by the ID string, and removes it from various lists.

void parq_dl_free struct download d  ) 
 

Removes the queue information for a download from memory.

void parq_dl_remove struct download d  ) 
 

Tells the parq logic that a download has been removed.

If parq has associated a queue structure with this download it will be freed.

void parq_dl_reparent_id struct download d,
struct download cd
 

Called from download_clone to reparent the PARQ ID from the parent `d' to the cloned `cd'.

void parq_dl_update_id struct download d,
const gchar *  temp
[static]
 

Updates a parq id if needed.

void parq_download_add_header gchar *  buf,
size_t  len,
size_t *  rw,
struct download d
 

Needs brief description here.

Adds an:

  • X-Queue: 1.0
  • X-Queued: position=x; ID=xxxxx

to the HTTP GET request.

gboolean parq_download_is_active_queued struct download d  ) 
 

Whether the download is queued remotely or not.

gboolean parq_download_is_passive_queued struct download d  ) 
 

Whether the download is queued remotely without keeping the connection or not.

gboolean parq_download_parse_queue_status struct download d,
header_t header
 

Retrieve and parse queueing information.

Returns:
TRUE if we parsed it OK, FALSE on error.

void parq_download_queue_ack struct gnutella_socket s  ) 
 

parq_download_queue_ack

PARQ enabled servers send a 'QUEUE' command when the lifetime of the download (upload from the servers point of view) is about to expire, or if the download has retrieved an download slot (upload slot from the servers point of view). This function looksup the ID associated with the QUEUE command and prepares the download to continue.

void parq_download_retry_active_queued struct download d  ) 
 

Active queued means we didn't close the http connection on a HTTP 503 busy when the server supports queueing.

So prepare the download structure for a 'valid' segment. And re-request the segment.

void parq_init void   ) 
 

Initialises the upload queue for PARQ.

gboolean parq_still_sharing struct parq_ul_queued parq_ul  )  [static]
 

Determine if we are still sharing this file, so that PARQ can determine if it makes sense to keep this file in the queue.

Returns:
FALSE if the file is no longer shared, or TRUE if the file is shared or if we don't know, e.g. if the library is being rebuilt.

void parq_store gpointer  data,
gpointer  file_ptr
[inline, static]
 

Saves an individual queued upload to disc.

This is the callback function used by g_list_foreach() in function parq_upload_save_queue().

parq_tag_t parq_string_to_tag const gchar *  s  )  [static]
 

guint32 parq_ul_calc_retry struct parq_ul_queued parq_ul  ) 
 

Calculates the retry delay for an upload.

Returns:
the recommended retry delay.

gboolean parq_ul_id_sent const gnutella_upload_t u  ) 
 

Determines whether the PARQ ID was already sent for an upload.

gint parq_ul_rel_pos_cmp gconstpointer  a,
gconstpointer  b
[static]
 

Function used to keep the relative position list sorted by relative position.

It should never be possible for 2 downloads to have the same relative position in the same queue.

void parq_upload_add gnutella_upload_t unused_u  ) 
 

void parq_upload_add_header gchar *  buf,
gint *  retval,
gpointer  arg,
guint32  flags
 

Adds X-Queued status in the HTTP reply header for a queued upload.

Parameters:
`buf' is the start of the buffer where the headers are to be added.
`retval' contains the length of the buffer initially, and is filled with the amount of data written.
`arg' no brief description.
`flags' no brief description.
Attention:
NB: Adds a Retry-After field for servents that will not understand PARQ, to make sure they do not re-request too soon.

void parq_upload_add_header_id gchar *  buf,
gint *  retval,
gpointer  arg,
guint32  unused_flags
 

Adds X-Queued status in the HTTP reply header showing the queue ID for an upload getting a slot.

`buf' is the start of the buffer where the headers are to be added. `retval' contains the length of the buffer initially, and is filled with the amount of data written.

gboolean parq_upload_addr_can_proceed const gnutella_upload_t u  ) 
 

Check that the IP is not already downloading more than is alllowed.

Returns:
TRUE if it is OK for that IP to download from us.

void parq_upload_busy gnutella_upload_t u,
gpointer  handle
 

Mark an upload as really being active instead of just being queued.

void parq_upload_collect_stats const gnutella_upload_t u  ) 
 

Collect running stats about the completed / removed upload.

gboolean parq_upload_continue struct parq_ul_queued uq,
gint  used_slots
[static]
 

Returns:
TRUE if the current upload is allowed to get an upload slot.

struct parq_ul_queued * parq_upload_create gnutella_upload_t u  )  [static]
 

Creates a new upload structure and prefills some values.

Returns a pointer to the newly created ul_queued structure.

void parq_upload_decrease_all_after struct parq_ul_queued cur_parq_ul  )  [static]
 

Decreases the position of all queued items after the given queued item.

struct parq_ul_queued * parq_upload_find const gnutella_upload_t u  )  [inline, static]
 

Finds an upload if available in the upload queue.

Returns:
NULL if upload could not be found.

struct parq_ul_queued* parq_upload_find_id header_t header  )  [static]
 

void parq_upload_force_remove gnutella_upload_t u  ) 
 

void parq_upload_free struct parq_ul_queued parq_ul  )  [static]
 

removes an parq_ul from the parq list and frees all its memory.

void parq_upload_free_queue struct parq_ul_queue queue  )  [static]
 

Frees the queue from memory and the ul_parqs linked list.

gpointer parq_upload_get gnutella_upload_t u,
header_t header,
gboolean  replacing
 

Get a queue slot, either existing or new.

When `replacing' is TRUE, they issued a new request for a possibly stalling entry, which was killed anyway, so give them a slot!

Returns:
slot as an opaque handle, NULL if slot cannot be created.

struct parq_ul_queued* parq_upload_get_at struct parq_ul_queue queue,
int  position
 

Get parq structure at specified position.

void parq_upload_load_queue void   )  [static]
 

Loads the saved queue status back into memory.

guint parq_upload_lookup_eta const gnutella_upload_t u  ) 
 

Returns:
the Estimated Time of Arrival for an upload slot for a given upload.

const gchar* parq_upload_lookup_id const gnutella_upload_t u  ) 
 

Returns:
the current ID of the upload.

time_t parq_upload_lookup_lifetime const gnutella_upload_t u  ) 
 

Returns:
the lifetime of a queued upload.

guint parq_upload_lookup_position const gnutella_upload_t u  ) 
 

Returns:
the current queueing position of an upload. Returns a value of (guint) -1 if not found.

guint parq_upload_lookup_queue_no const gnutella_upload_t u  ) 
 

Returns:
the queue number the current upload is queued in.

gboolean parq_upload_lookup_quick const gnutella_upload_t u  ) 
 

Returns:
TRUE if the upload was allowed quickly by PARQ.

time_t parq_upload_lookup_retry const gnutella_upload_t u  ) 
 

Returns:
the time_t at which the next retry is expected.

guint parq_upload_lookup_size const gnutella_upload_t u  ) 
 

Returns:
the current upload queue size of alive uploads.

struct parq_ul_queue * parq_upload_new_queue void   )  [static]
 

Creates a new parq_ul_queue structure and places it in the ul_parqs linked list.

gboolean parq_upload_queue_full gnutella_upload_t u  ) 
 

Returns:
TRUE if parq cannot hold any more uploads.

gboolean parq_upload_queued gnutella_upload_t u  ) 
 

Whether the current upload is already queued.

gboolean parq_upload_quick_continue struct parq_ul_queued uq,
gint  used_slots
[static]
 

Returns:
TRUE if the current upload will finish quickly enough and actually scheduling would only cost more resources then it would save.

void parq_upload_register_send_queue struct parq_ul_queued parq_ul  )  [static]
 

Possibly register the upload in the list for deferred QUEUE sending.

gboolean parq_upload_remove gnutella_upload_t u  ) 
 

When an upload is removed this function should be called so parq knows the current upload status of an upload.

Returns:
TRUE if the download was totally removed. And the associated memory was cleared. FALSE if the parq structure still exists.

gboolean parq_upload_request gnutella_upload_t u,
guint  used_slots
 

Returns:
If the download may continue, TRUE is returned. FALSE otherwise (which probably means the upload is queued).

gboolean parq_upload_request_force gnutella_upload_t u,
gpointer  handle,
guint  used_slots
 

If the download may continue, true is returned.

False otherwise (which probably means the upload is queued). Where parq_upload_request honours the number of upload slots, this one is used for dynamic slot allocation. This function expects that the upload was checked with parq_upload_request first.

void parq_upload_save_queue void   ) 
 

Saves all the current queues and their items so it can be restored when the client starts up again.

void parq_upload_send_queue struct parq_ul_queued parq_ul  )  [static]
 

Sends a QUEUE to a parq enabled client.

void parq_upload_send_queue_conf gnutella_upload_t u  ) 
 

'Call back' connection was succesfull.

So prepare to send headers

void parq_upload_timer time_t  now  ) 
 

Removes any PARQ uploads which show no activity.

void parq_upload_update_addr_and_name struct parq_ul_queued parq_ul,
gnutella_upload_t u
[static]
 

Updates the IP and name entry in the queued structure and makes sure the hash table remains in sync.

void parq_upload_update_eta struct parq_ul_queue which_ul_queue  )  [static]
 

Updates the ETA of all queued items in the given queue.

void parq_upload_update_relative_position struct parq_ul_queued cur_parq_ul  )  [static]
 

Updates the relative position of all queued after the given queued item.

void parq_upload_upload_got_cloned gnutella_upload_t u,
gnutella_upload_t cu
 

void parq_upload_upload_got_freed gnutella_upload_t u  ) 
 

Makes sure parq doesn't keep any internal reference to the upload structure.

struct parq_ul_queue * parq_upload_which_queue gnutella_upload_t u  )  [static]
 

Looks up in which queue the current upload should be placed and if the queue doesn't exist yet it will be created.

Returns:
a pointer to the queue in which the upload should be queued.

RCSID "$Id:parq.  c,
v 1.55 2006/01/10 10:32:57 cbiere Exp $" 
 


Variable Documentation

GHashTable* dl_all_parq_by_id = NULL [static]
 

gboolean enable_real_passive = TRUE [static]
 

If enable_real_passive is TRUE, a dead upload is only marked dead, if FALZE, a dead upload is really removed and cannot reclaim its position.

const gchar file_parq_file[] = "parq" [static]
 

GHashTable* ht_banned_source = NULL [static]
 

GList* parq_banned_sources = NULL [static]
 

guint parq_max_upload_size = MAX_UPLOAD_QSIZE [static]
 

gboolean parq_shutdown = FALSE [static]
 

const struct parq_tag parq_tag_map[] [static]
 

guint parq_upload_active_size = 20 [static]
 

parq_upload_active_size is the maximum number of active upload slots per queue.

This limit will only be reached when all requests are QUEUE, push or the number of upload slots is also large.

guint parq_upload_ban_window = 600 [static]
 

GHashTable* ul_all_parq_by_addr = NULL [static]
 

GHashTable* ul_all_parq_by_addr_and_name = NULL [static]
 

GHashTable* ul_all_parq_by_id = NULL [static]
 

GList* ul_parq_queue = NULL [static]
 

To whom we need to send a QUEUE.

GList* ul_parqs = NULL [static]
 

List of all queued uploads.


Generated on Sun Feb 12 10:50:05 2006 for Gtk-Gnutella by doxygen 1.3.6