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

parq.h File Reference


Detailed Description

Passive/Active Remote Queuing.

Author:
Jeroen Asselman
Date:
2003

#include "lib/header.h"
#include "downloads.h"
#include "uploads.h"
#include "if/core/parq.h"

Go to the source code of this file.

Defines

#define PARQ_MAX_UL_RETRY_DELAY   1200 /**< 20 minutes retry rate max. */
 20 minutes retry rate max

#define PARQ_GRACE_TIME   90 /**< Grace period after life expired */
 Grace period after life expired.


Functions

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.

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

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'.

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_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.

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.

gboolean parq_download_supports_parq (header_t *header)
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.

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

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

void parq_download_queue_ack (struct gnutella_socket *s)
 parq_download_queue_ack

void parq_upload_timer (time_t now)
 Removes any PARQ uploads which show no activity.

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 flags)
 Adds X-Queued status in the HTTP reply header showing the queue ID for an upload getting a slot.

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 (gnutella_upload_t *u, guint used_slots)
gboolean parq_upload_request_force (gnutella_upload_t *u, gpointer handle, guint used_slots)
 If the download may continue, true is returned.

guint parq_upload_lookup_position (const gnutella_upload_t *u)
const gchar * parq_upload_lookup_id (const gnutella_upload_t *u)
gboolean parq_upload_queue_full (gnutella_upload_t *u)
guint parq_upload_lookup_size (const gnutella_upload_t *u)
gboolean parq_upload_addr_can_proceed (const gnutella_upload_t *u)
 Check that the IP is not already downloading more than is alllowed.

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_eta (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)
gboolean parq_upload_queued (gnutella_upload_t *u)
 Whether the current upload is already queued.

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_collect_stats (const gnutella_upload_t *u)
 Collect running stats about the completed / removed upload.

void parq_upload_upload_got_freed (gnutella_upload_t *u)
 Makes sure parq doesn't keep any internal reference to the upload structure.

void parq_upload_upload_got_cloned (gnutella_upload_t *u, gnutella_upload_t *cu)
void parq_upload_force_remove (gnutella_upload_t *u)
void parq_upload_add (gnutella_upload_t *u)
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_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_conf (gnutella_upload_t *u)
 'Call back' connection was succesfull.

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

time_t parq_banned_source_expire (const host_addr_t addr)


Define Documentation

#define PARQ_GRACE_TIME   90 /**< Grace period after life expired */
 

Grace period after life expired.

#define PARQ_MAX_UL_RETRY_DELAY   1200 /**< 20 minutes retry rate max. */
 

20 minutes retry rate max


Function Documentation

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.

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_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_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_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.

gboolean parq_download_supports_parq header_t header  ) 
 

void parq_init void   ) 
 

Initialises the upload queue for PARQ.

gboolean parq_ul_id_sent const gnutella_upload_t u  ) 
 

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

void parq_upload_add gnutella_upload_t 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.

void parq_upload_force_remove gnutella_upload_t u  ) 
 

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.

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.

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_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_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_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.


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