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

mq.c File Reference


Detailed Description

Message queues, common code between TCP and UDP sending stacks.

Author:
Raphael Manfredi
Date:
2002-2003

#include "common.h"
#include "nodes.h"
#include "mq.h"
#include "pmsg.h"
#include "gmsg.h"
#include "gnet_stats.h"
#include "lib/walloc.h"
#include "lib/cq.h"
#include "if/gnet_property_priv.h"
#include "lib/override.h"

Defines

#define MQ_PUTQ(o, m)   ((o)->ops->putq((o), (m)))

Functions

 RCSID ("$Id:mq.c, v 1.12 2005/08/07 22:32:09 cbiere Exp $")
void qlink_free (mqueue_t *q)
 Free the `qlink' sorted array of queued items.

void mq_update_flowc (mqueue_t *q)
 Update flow-control indication for queue.

gboolean make_room_header (mqueue_t *q, gchar *header, guint prio, gint needed, gint *offset)
 Same as make_room(), but we are not given a "pmsg_t" as a comparison point but a Gnutella header and a message priority explicitly.

void mq_swift_timer (cqueue_t *cq, gpointer obj)
 Callout queue callback: periodic "swift" mode timer.

void mq_free (mqueue_t *q)
 Free queue and all enqueued messages.

GList * mq_rmlink_prev (mqueue_t *q, GList *l, gint size)
 Remove link from message queue and return the previous item.

void mq_swift_checkpoint (mqueue_t *q, gboolean initial)
 A "swift" checkpoint was reached.

void mq_enter_swift (cqueue_t *unused_cq, gpointer obj)
 Callout queue callback invoked when the queue must enter "swift" mode.

void mq_enter_flowc (mqueue_t *q)
 Called when the message queue first enters flow-control.

void mq_leave_flowc (mqueue_t *q)
 Leaving flow-control state.

void mq_clear (mqueue_t *q)
 Remove all unsent messages from the queue.

void mq_discard (mqueue_t *q)
 Forbid further writes to the queue.

void mq_shutdown (mqueue_t *q)
 Disable all further writes from the queue.

gint qlink_cmp (const void *lp1, const void *lp2)
 Compare two pointers to links based on their relative priorities, then based on their held Gnutella messages.

void qlink_create (mqueue_t *q)
 Create the `qlink' sorted array of queued items.

void qlink_insert_before (mqueue_t *q, gint hint, GList *l)
 Insert linkable `l' within the sorted qlink array of linkables for the queue, before the position indicated by `hint'.

void qlink_insert (mqueue_t *q, GList *l)
 Insert linkable `l' within the sorted qlink array of linkables.

void qlink_remove (mqueue_t *q, GList *l)
 Remove the entry in the `qlink' linkable array.

gboolean make_room (mqueue_t *q, pmsg_t *mb, gint needed, gint *offset)
 Remove from the queue enough messages that are less prioritary than the current one, so as to make sure we can enqueue it.

void mq_puthere (mqueue_t *q, pmsg_t *mb, gint msize)
 Put message in this queue.

void mq_putq (mqueue_t *q, pmsg_t *mb)
 Enqueue message, which becomes owned by the queue.

const struct mq_copsmq_get_cops (void)
 Get common operations.


Variables

const struct mq_cops mq_cops


Define Documentation

#define MQ_PUTQ o,
 )     ((o)->ops->putq((o), (m)))
 


Function Documentation

gboolean make_room mqueue_t q,
pmsg_t mb,
gint  needed,
gint *  offset
[static]
 

Remove from the queue enough messages that are less prioritary than the current one, so as to make sure we can enqueue it.

If `offset' is not null, it may be set with the offset within qlink where the message immediately more prioritary than `mb' can be found. It is up to the caller to initialize it with -1 and check whether it has been set.

Returns:
TRUE if we were able to make enough room.

gboolean make_room_header mqueue_t q,
gchar *  header,
guint  prio,
gint  needed,
gint *  offset
[static]
 

Same as make_room(), but we are not given a "pmsg_t" as a comparison point but a Gnutella header and a message priority explicitly.

void mq_clear mqueue_t q  ) 
 

Remove all unsent messages from the queue.

void mq_discard mqueue_t q  ) 
 

Forbid further writes to the queue.

void mq_enter_flowc mqueue_t q  )  [static]
 

Called when the message queue first enters flow-control.

void mq_enter_swift cqueue_t unused_cq,
gpointer  obj
[static]
 

Callout queue callback invoked when the queue must enter "swift" mode.

void mq_free mqueue_t q  ) 
 

Free queue and all enqueued messages.

Since the message queue is the top of the network TX stack, calling mq_free() recursively requests freeing to lower layers.

const struct mq_cops* mq_get_cops void   ) 
 

Get common operations.

void mq_leave_flowc mqueue_t q  )  [static]
 

Leaving flow-control state.

void mq_puthere mqueue_t q,
pmsg_t mb,
gint  msize
[static]
 

Put message in this queue.

void mq_putq mqueue_t q,
pmsg_t mb
 

Enqueue message, which becomes owned by the queue.

GList* mq_rmlink_prev mqueue_t q,
GList *  l,
gint  size
[static]
 

Remove link from message queue and return the previous item.

The `size' parameter refers to the size of the removed message.

The underlying message is freed and the size information on the queue is updated, but not the flow-control information.

void mq_shutdown mqueue_t q  ) 
 

Disable all further writes from the queue.

void mq_swift_checkpoint mqueue_t q,
gboolean  initial
[static]
 

A "swift" checkpoint was reached.

void mq_swift_timer cqueue_t unused_cq,
gpointer  obj
[static]
 

Callout queue callback: periodic "swift" mode timer.

void mq_update_flowc mqueue_t q  )  [static]
 

Update flow-control indication for queue.

Invoke node "callbacks" when crossing a watermark boundary.

We define three levels: no flow-control, in warn zone, in flow-control.

gint qlink_cmp const void *  lp1,
const void *  lp2
[static]
 

Compare two pointers to links based on their relative priorities, then based on their held Gnutella messages.

-- qsort() callback

void qlink_create mqueue_t q  )  [static]
 

Create the `qlink' sorted array of queued items.

void qlink_free mqueue_t q  )  [static]
 

Free the `qlink' sorted array of queued items.

void qlink_insert mqueue_t q,
GList *  l
[static]
 

Insert linkable `l' within the sorted qlink array of linkables.

void qlink_insert_before mqueue_t q,
gint  hint,
GList *  l
[static]
 

Insert linkable `l' within the sorted qlink array of linkables for the queue, before the position indicated by `hint'.

void qlink_remove mqueue_t q,
GList *  l
[static]
 

Remove the entry in the `qlink' linkable array.

RCSID "$Id:mq.  c,
v 1.12 2005/08/07 22:32:09 cbiere Exp $" 
 


Variable Documentation

const struct mq_cops mq_cops [static]
 

Initial value:

 {
    mq_puthere,             
    qlink_remove,           
    mq_rmlink_prev,         
    mq_update_flowc,        
}


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