Mercurial > hg > waaad
changeset 137:c680d5590ac6
Some changes in peer structure
author | Sebastien Decugis <sdecugis@nict.go.jp> |
---|---|
date | Wed, 20 Aug 2008 18:04:23 +0900 |
parents | fe4530fc7cbb |
children | 0e1bc3ed0609 |
files | waaad/peer-internal.h |
diffstat | 1 files changed, 11 insertions(+), 26 deletions(-) [+] |
line wrap: on
line diff
--- a/waaad/peer-internal.h Wed Aug 20 18:03:47 2008 +0900 +++ b/waaad/peer-internal.h Wed Aug 20 18:04:23 2008 +0900 @@ -83,36 +83,19 @@ } peer_state_t; -/* List of sent requests to this peer, ordered by hop-by-hop id */ -typedef struct _sent_r { - /* Chaining information */ - struct _sent_r *next; /* The next sent request */ - struct _sent_r *prev; /* The previous sent request */ - - /* Pointer to the message */ - msg_t *msg; - - /* The following two fields are copied from message for faster processing on message reception and failover */ - uint32_t hbh; /* The hop-by-hop value of the message */ - int rtb; /* Is this a routable message? => discarded or requeued on failover */ - -} _sent_req_t; - /* Events that can be sent to the peer and handled by the peer state machine */ typedef enum { PEVENT_SHUTDOWN = 1, /* The daemon requested to shutdown this peer resources */ PEVENT_DISCONNECTED, /* the socket has been disconnected */ + PEVENT_MSGRCVD, /* a message was received */ PEVENT_MAX /* To be continued */ } pevent_t; /* An event element */ -typedef struct _pe { - pevent_t event; /* identifier of this event */ - void *data; /* the data associated to the event, if appropriate */ - struct _pe *next; /* next event in the list */ - struct _pe *prev; /* prev event in the list */ +typedef struct { + uti_list_t list; /* list of events; the "o" field is the event data, if appropriate */ + pevent_t event; /* identifier of this event */ } _pe_t; - /* Flags definitions */ #define PEERFL_DYNAMIC ( 1 << 0 ) /* The peer is not statically configured and will expire */ @@ -122,9 +105,11 @@ /* Peer internal description */ typedef struct _peer { + /* Chaining of the peer in global lists */ - uti_list_t p_global; /* List of peers this peer belongs to */ - uti_list_t p_active; /* Sublist containing only the active peers (in STATE_OPEN) */ + uint32_t p_hash; /* Hash value of the p_diamid */ + uti_list_t p_global; /* Hash table sublist this peer belongs to */ + uti_list_t p_active; /* Hash sublist containing only the active peers (in STATE_OPEN) */ /* For debug */ uint32_t p_eyec; /* An eyecatcher to verify object is valid. Must be PEER_EYEC. */ @@ -132,14 +117,14 @@ /* Peer data */ char *p_diamid; /* The Diameter-Id of this peer, once known */ char *p_realm; /* pointer to the beginning of the realm in the diamid string. */ - uint32_t p_hbh; /* next Hop-by-hop free value */ - pthread_mutex_t p_lock; /* Mutex to protect this object */ + uint32_t p_hbh; /* next Hop-by-hop free value for sending messages */ uint32_t p_flags; /* The PEERFL_* flags */ struct timespec p_expire; /* Lifetime of the peer, for dynamic peers */ /* Peer state */ peer_state_t p_state; /* State of the peer */ pthread_t p_psm; /* The thread handling this peer state machine. */ + pthread_mutex_t p_lock; /* Mutex to protect this object */ pthread_cond_t p_condvar; /* The cond var to be waited in the peer state machine (for timeouts and DWR and events) */ struct timespec p_ts; /* multi-purpose timespec (meaning depends on the state) */ _pe_t p_events; /* queue of events received by the peer */ @@ -149,7 +134,7 @@ pthread_t p_in_th; /* The thread handling messages reception, created by p_psm */ meq_t *p_out_q; /* Outgoing message queue */ pthread_t p_out_th; /* The thread handling messages envoy, created by p_psm */ - _sent_req_t p_sent; /* List of sent requests without answer */ + uti_list_t p_sent; /* List of sent requests without answer (the "o" field is the msg_t *) */ /* Connection information */ int p_sock; /* We use standard Berkeley sockets for both TCP and SCTP connections */