3
A brief file description
5
@section license License
7
Licensed to the Apache Software Foundation (ASF) under one
8
or more contributor license agreements. See the NOTICE file
9
distributed with this work for additional information
10
regarding copyright ownership. The ASF licenses this file
11
to you under the Apache License, Version 2.0 (the
12
"License"); you may not use this file except in compliance
13
with the License. You may obtain a copy of the License at
15
http://www.apache.org/licenses/LICENSE-2.0
17
Unless required by applicable law or agreed to in writing, software
18
distributed under the License is distributed on an "AS IS" BASIS,
19
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20
See the License for the specific language governing permissions and
21
limitations under the License.
25
/****************************************************************************
30
****************************************************************************/
37
#define ET_ICP ET_CALL
39
#include "ICPevents.h"
40
#include "ICPProcessor.h"
44
//*********************************************************************
46
//*********************************************************************
50
//*********************************************************************
51
// ICP.h -- Internet Cache Protocol (ICP) related data structures.
53
// Message protocol definitions as defined by RFC 2186
54
// "Internet Cache Protocol (ICP), version 2".
55
//*********************************************************************
56
typedef struct ICPMsgHeader
67
//-----------------------
69
//-----------------------
78
ICP_OP_UNUSED5, // 05 unused
79
ICP_OP_UNUSED6, // 06 unused
80
ICP_OP_UNUSED7, // 07 unused
81
ICP_OP_UNUSED8, // 08 unused
82
ICP_OP_UNUSED9, // 09 unused
87
ICP_OP_UNUSED12, // 12 unused
88
ICP_OP_UNUSED13, // 13 unused
89
ICP_OP_UNUSED14, // 14 unused
90
ICP_OP_UNUSED15, // 15 unused
91
ICP_OP_UNUSED16, // 16 unused
92
ICP_OP_UNUSED17, // 17 unused
93
ICP_OP_UNUSED18, // 18 unused
94
ICP_OP_UNUSED19, // 19 unused
95
ICP_OP_UNUSED20, // 20 unused
97
ICP_OP_MISS_NOFETCH, // 21
100
ICP_OP_END_OF_OPS // 24 mark end of opcodes
103
#define ICP_OP_LAST (ICP_OP_END_OF_OPS - 1)
105
//-----------------------
106
// version definitions
107
//-----------------------
108
#define ICP_VERSION_1 1
109
#define ICP_VERSION_2 2
110
#define ICP_VERSION_3 3
111
#define ICP_VERSION ICP_VERSION_2
113
//--------------------------
114
// optionflags definitions
115
//--------------------------
116
#define ICP_FLAG_HIT_OBJ 0x80000000ul
117
#define ICP_FLAG_SRC_RTT 0x40000000ul
122
#define MAX_ICP_MSGSIZE (16 * 1024)
123
#define MAX_ICP_MSG_PAYLOAD_SIZE (MAX_ICP_MSGSIZE - sizeof(ICPmsgHdr_t))
124
#define MAX_ICP_QUERY_PAYLOAD_SIZE (MAX_ICP_MSG_PAYLOAD_SIZE - sizeof(uint32_t))
125
#define MAX_DEFINED_PEERS 64
126
#define MSG_IOVECS 16
131
typedef struct ICPData
133
char *URL; // null terminated
139
typedef struct ICPQuery
142
char *URL; // null terminated (outgoing)
148
typedef struct ICPHit
150
char *URL; // null terminated
156
typedef struct ICPMiss
158
char *URL; // null terminated
164
typedef struct ICPHitObj
166
char *URL; // null terminated
167
char *p_objsize; // byte aligned uint16_t immediately follows URL null
168
uint16_t objsize; // decoded object size
169
char *data; // object data
172
//------------------------
173
// ICP message descriptor
174
//------------------------
175
typedef struct ICPMsg
188
//******************************************************************
189
// ICP implementation specific data structures.
190
//******************************************************************
194
class ICPPeriodicCont;
195
class ICPHandlerCont;
196
class ICPPeerReadCont;
197
class ICPRequestCont;
208
#if !defined(USE_CAS_FOR_ATOMICLOCK)
219
ProxyMutexPtr _mutex;
222
#else // USE_CAS_FOR_ATOMICLOCK
234
{ UNLOCKED = 0, LOCKED = 1 };
237
#endif // USE_CAS_FOR_ATOMICLOCK
239
//-----------------------------------------------------------------
240
// Class ICPConfigData -- deal with global ICP configuration data
241
//-----------------------------------------------------------------
244
friend class ICPConfiguration;
247
ICPConfigData():_icp_enabled(0), _icp_port(0), _icp_interface(0),
248
_multicast_enabled(0), _icp_query_timeout(0), _cache_lookup_local(0),
249
_stale_lookup(0), _reply_to_unknown_peer(0), _default_reply_port(0)
254
} // Note: _icp_interface freed prior to delete
255
inline int operator==(ICPConfigData &);
256
inline int ICPconfigured()
264
inline char *ICPinterface()
266
return _icp_interface;
268
inline int ICPmulticastConfigured()
270
return _multicast_enabled;
272
inline int ICPqueryTimeout()
274
return _icp_query_timeout;
276
inline int ICPLocalCacheLookup()
278
return _cache_lookup_local;
280
inline int ICPStaleLookup()
282
return _stale_lookup;
284
inline int ICPReplyToUnknownPeer()
286
return _reply_to_unknown_peer;
288
inline int ICPDefaultReplyPort()
290
return _default_reply_port;
294
//---------------------------------------------------------
295
// ICP Configuration data derived from "records.config"
296
//---------------------------------------------------------
297
int _icp_enabled; // see ICP_MODE_XXX defines
299
char *_icp_interface;
300
int _multicast_enabled;
301
int _icp_query_timeout;
302
int _cache_lookup_local;
304
int _reply_to_unknown_peer;
305
int _default_reply_port;
308
//----------------------------------------------------------------
309
// Class PeerConfigData -- deal with peer ICP configuration data
310
//----------------------------------------------------------------
313
friend class ICPConfiguration;
314
friend class ICPProcessor;
318
PeerConfigData(int ctype, struct in_addr *ip_addr, int proxy_port, int icp_port)
319
: _ctype(ctype), _ip_addr(*ip_addr),
320
_proxy_port(proxy_port), _icp_port(icp_port), _mc_member(0), _mc_ttl(0), _my_ip_addr(*ip_addr)
323
_mc_ip_addr.s_addr = 0;
328
bool operator==(PeerConfigData &);
329
inline const char *GetHostname()
333
inline int GetCType()
337
inline struct in_addr *GetIP()
341
inline int GetProxyPort()
345
inline int GetICPPort()
349
inline int MultiCastMember()
353
inline struct in_addr *GetMultiCastIP()
357
inline int GetMultiCastTTL()
362
// Static member functions
363
static PeerType_t CTypeToPeerType_t(int);
364
static int GetHostIPByName(char *, struct in_addr *);
367
{ HOSTNAME_SIZE = 256 };
376
//---------------------------------------------------------
377
// Peer Configuration data derived from "icp.config"
378
//---------------------------------------------------------
379
char _hostname[HOSTNAME_SIZE];
381
struct in_addr _ip_addr;
384
//-------------------
386
//-------------------
388
struct in_addr _mc_ip_addr;
391
//----------------------------------------------
392
// Computed data not subject to "==" test
393
//----------------------------------------------
394
struct in_addr _my_ip_addr;
397
//---------------------------------------------------------------
398
// Class ICPConfigUpdateCont -- Continuation which retries
399
// icp_config_change_callback(). Continuation started
400
// due to manager config callout or failure to acquire lock.
401
//---------------------------------------------------------------
402
class ICPConfigUpdateCont:public Continuation
405
ICPConfigUpdateCont(void *data, void *value);
406
~ICPConfigUpdateCont()
409
int RetryICPconfigUpdate(int, Event *);
412
{ RETRY_INTERVAL = 10 };
419
//------------------------------------------------------------------
420
// Class ICPConfiguration -- Overall management of ICP Config data
421
//------------------------------------------------------------------
422
class ICPConfiguration
427
int GlobalConfigChange();
428
void UpdateGlobalConfig();
429
int PeerConfigChange();
430
void UpdatePeerConfig();
432
inline ICPConfigData *globalConfig()
436
inline PeerConfigData *indexToPeerConfigData(int index)
438
ink_assert(index <= MAX_DEFINED_PEERS);
439
// TODO coverity warning should be addressed with model for ink_assert
440
// coverity[overrun-local]
441
return _peer_cdata[index];
444
// TS configuration management callout for "icp.config".
445
static int mgr_icp_config_change_callback(const char *, RecDataT, RecData, void *);
447
// ICP configuration callout for ET_ICP
448
static void *icp_config_change_callback(void *, void *, int startup = 0);
459
inline int HaveLock()
461
return _l.HaveLock();
464
inline int ICPConfigCallouts()
466
return _icp_config_callouts;
470
// Class data declarations
472
int _icp_config_callouts;
474
// All ICP operation is based on "icp_data" and "peer_cdata".
475
// The "icp_data_current" and "peer_cdata_current" reflect the
476
// current state of the configuration. "icp_data_current" is
477
// updated via configuration callouts. "peer_cdata_current"
478
// is updated by the periodic ICP processor event (ICPPeriodicCont),
479
// when configuration management signals us with a callout on "icp.config".
480
// We merge current to working only after disabling ICP operation and
481
// waiting for pending requests to complete.
483
ICPConfigData *_icp_cdata;
484
ICPConfigData *_icp_cdata_current;
485
PeerConfigData *_peer_cdata[MAX_DEFINED_PEERS + 1];
486
PeerConfigData *_peer_cdata_current[MAX_DEFINED_PEERS + 1];
489
//------------------------------------------------------------------------
490
// Class Peer -- Internal structure representing ICP peers derived from
491
// configuration data (abstract base class).
492
//------------------------------------------------------------------------
495
#define PEER_UP (1 << 0)
496
#define PEER_MULTICAST_COUNT_EVENT (1 << 1) // Member probe event active
497
#define PEER_DYNAMIC (1 << 2) // Dynamically added, not in config
499
struct CacheVConnection;
501
class Peer:public RefCountObj
504
Peer(PeerType_t, ICPProcessor *, bool dynamic_peer = false);
508
void LogRecvMsg(ICPMsg_t *, int);
510
// Pure virtual functions
511
virtual struct in_addr *GetIP() = 0;
512
virtual int GetPort() = 0;
513
virtual Action *SendMsg_re(Continuation *, void *, struct msghdr *, struct sockaddr_in *to) = 0;
514
virtual Action *RecvFrom_re(Continuation *, void *, IOBufferBlock *, int, struct sockaddr *, socklen_t *) = 0;
515
virtual int GetRecvFD() = 0;
516
virtual int GetSendFD() = 0;
517
virtual int ExpectedReplies(BitMap *) = 0;
518
virtual int ValidSender(struct sockaddr_in *) = 0;
519
virtual void LogSendMsg(ICPMsg_t *, struct sockaddr_in *) = 0;
520
virtual int IsOnline() = 0;
521
virtual Connection *GetSendChan() = 0;
522
virtual Connection *GetRecvChan() = 0;
523
virtual int ExtToIntRecvSockAddr(struct sockaddr_in *, struct sockaddr_in *) = 0;
526
{ OFFLINE_THRESHOLD = 20 };
528
inline PeerType_t GetType()
532
inline int GetPeerID()
536
inline void SetPeerID(int newid)
540
inline void SetNext(Peer * p)
544
inline Peer *GetNext()
548
inline bool shouldStartRead()
550
return !notFirstRead;
552
inline void startingRead()
556
inline void cancelRead()
560
inline bool readActive()
562
return (readAction != NULL);
566
return (_state & PEER_UP);
569
// these shouldn't be public
570
// this is for delayed I/O
571
Ptr<IOBufferBlock> buf;
572
struct sockaddr_in fromaddr;
573
socklen_t fromaddrlen;
574
int notFirstRead; // priming the reads
575
Action *readAction; // outstanding read
576
Action *writeAction; // outstanding write
580
int _id; // handle for this peer
582
ICPProcessor *_ICPpr;
589
//-------------------
591
//-------------------
594
ink_hrtime last_send;
595
ink_hrtime last_receive;
596
int sent[ICP_OP_LAST + 1];
597
int recv[ICP_OP_LAST + 1];
600
int dropped_replies; // arrived after timeout
604
//------------------------------------------------
605
// Class ParentSiblingPeer (derived from Peer)
606
//------------------------------------------------
607
class ParentSiblingPeer:public Peer
610
ParentSiblingPeer(PeerType_t, PeerConfigData *, ICPProcessor *, bool dynamic_peer = false);
613
if (_pconfig && (_state & PEER_DYNAMIC))
617
virtual struct in_addr *GetIP();
618
virtual int GetPort();
619
virtual Action *SendMsg_re(Continuation *, void *, struct msghdr *, struct sockaddr_in *to);
620
virtual Action *RecvFrom_re(Continuation *, void *, IOBufferBlock *, int, struct sockaddr *, socklen_t *);
621
virtual int GetRecvFD();
622
virtual int GetSendFD();
623
virtual int ExpectedReplies(BitMap *);
624
virtual int ValidSender(struct sockaddr_in *);
625
virtual void LogSendMsg(ICPMsg_t *, struct sockaddr_in *);
626
virtual int ExtToIntRecvSockAddr(struct sockaddr_in *in, struct sockaddr_in *out);
627
inline virtual int IsOnline()
631
inline virtual Connection *GetSendChan()
635
inline virtual Connection *GetRecvChan()
639
inline PeerConfigData *GetConfig()
643
inline Connection *GetChan()
649
// Class data declarations
650
PeerConfigData * _pconfig; // associated config data
654
//------------------------------------------------
655
// Class MultiCastPeer (derived from Peer)
656
//------------------------------------------------
657
class MultiCastPeer:public Peer
660
MultiCastPeer(struct in_addr *, int, int, ICPProcessor *);
665
int AddMultiCastChild(Peer * P);
666
Peer *FindMultiCastChild(struct in_addr *ip, int port);
668
virtual struct in_addr *GetIP();
669
virtual int GetPort();
670
virtual Action *SendMsg_re(Continuation *, void *, struct msghdr *, struct sockaddr_in *to);
671
virtual Action *RecvFrom_re(Continuation *, void *, IOBufferBlock *, int, struct sockaddr *, socklen_t *);
672
virtual int GetRecvFD();
673
virtual int GetSendFD();
674
virtual int ExpectedReplies(BitMap *);
675
virtual int ValidSender(struct sockaddr_in *);
676
virtual void LogSendMsg(ICPMsg_t *, struct sockaddr_in *);
677
virtual int IsOnline();
678
inline virtual Connection *GetRecvChan()
682
inline virtual Connection *GetSendChan()
686
inline virtual int ExtToIntRecvSockAddr(struct sockaddr_in *in, struct sockaddr_in *out)
688
Peer *P = FindMultiCastChild(&in->sin_addr, 0);
690
out->sin_addr = in->sin_addr;
691
out->sin_port = htons(P->GetPort());
699
// Class data declarations
700
Connection _send_chan;
701
Connection _recv_chan;
702
//---------------------------
703
// Multicast specific data
704
//---------------------------
705
struct sockaddr_in _mc_addr;
707
struct multicast_data
709
double avg_members; // running avg of multicast responders
710
int defined_members; // as specified in icp.config
711
int n_count_events; // responder count events
712
int count_event_reqno; // reqno associated with count event
713
int expected_replies; // current expected responders on multicast
717
//----------------------------------------------------
718
// Class BitMap -- Generic bit map management class
719
//----------------------------------------------------
731
{ STATIC_BITMAP_BYTE_SIZE = 16,
734
char _static_bitmap[STATIC_BITMAP_BYTE_SIZE];
737
int _bitmap_byte_size;
740
//----------------------------------------
741
// ICPProcessor -- ICP External interface
742
//----------------------------------------
745
friend class ICPHandlerCont; // Incoming msg periodic handler
746
friend class ICPPeerReadCont; // Incoming ICP request handler
747
friend class ICPRequestCont; // Outgoing ICP request handler
753
// Exported interfaces for other subsystems
755
Action *ICPQuery(Continuation *, URL *);
757
// Exported interfaces to other ICP classes
764
ReconfigState_t ReconfigureStateMachine(ReconfigState_t, int, int);
766
Peer *FindPeer(struct in_addr *, int);
767
inline Peer *GetLocalPeer()
771
inline Peer *IdToPeer(int id)
773
return _PeerList[id];
775
inline ICPConfiguration *GetConfig()
780
inline int GetFreePeers()
782
return PEER_LIST_SIZE - (_nPeerList + 1);
784
inline int GetFreeSendPeers()
786
return SEND_PEER_LIST_SIZE - (_nSendPeerList + 1);
788
inline int GetFreeRecvPeers()
790
return RECV_PEER_LIST_SIZE - (_nRecvPeerList + 1);
803
inline int HaveLock()
805
return _l->HaveLock();
809
int SetupListenSockets();
810
void ShutdownListenSockets();
811
int Reconfigure(int, int);
812
void InitICPStatCallbacks();
814
inline void DisableICPQueries()
816
_AllowIcpQueries = 0;
818
inline void EnableICPQueries()
820
_AllowIcpQueries = 1;
822
inline int AllowICPQueries()
824
return _AllowIcpQueries;
826
inline int PendingQuery()
828
return _PendingIcpQueries;
830
inline void IncPendingQuery()
832
_PendingIcpQueries++;
834
inline void DecPendingQuery()
836
_PendingIcpQueries--;
839
Peer *GenericFindListPeer(struct in_addr *, int, int, Ptr<Peer> *);
840
Peer *FindSendListPeer(struct in_addr *, int);
841
Peer *FindRecvListPeer(struct in_addr *, int);
843
int AddPeerToSendList(Peer *);
844
int AddPeerToRecvList(Peer *);
845
int AddPeerToParentList(Peer *);
847
inline int GetSendPeers()
849
return _nSendPeerList + 1;
851
inline Peer *GetNthSendPeer(int n, int bias)
853
return _SendPeerList[(bias + n) % (_nSendPeerList + 1)];
856
inline int GetRecvPeers()
858
return _nRecvPeerList + 1;
860
inline Peer *GetNthRecvPeer(int n, int bias)
862
return _RecvPeerList[(bias + n) % (_nRecvPeerList + 1)];
865
inline int GetStartingSendPeerBias()
867
return ++_curSendPeer;
869
inline int GetStartingRecvPeerBias()
871
return ++_curRecvPeer;
874
inline int GetParentPeers()
876
return _nParentPeerList + 1;
878
inline Peer *GetNthParentPeer(int n, int bias)
880
return _ParentPeerList[(bias + n) % (_nParentPeerList + 1)];
882
inline int GetStartingParentPeerBias()
884
return ++_curParentPeer;
887
inline void SetLastRecvPeerBias(int b)
889
_last_recv_peer_bias = b;
891
inline int GetLastRecvPeerBias()
893
return _last_recv_peer_bias;
895
void CancelPendingReads();
896
void DumpICPConfig();
899
// Class data declarations
902
int _AllowIcpQueries;
903
int _PendingIcpQueries;
904
ICPConfiguration *_ICPConfig;
905
ICPPeriodicCont *_ICPPeriodic;
906
ICPHandlerCont *_ICPHandler;
907
ICPHandlerCont *_mcastCB_handler;
908
Event *_PeriodicEvent;
909
Event *_ICPHandlerEvent;
913
PEER_LIST_SIZE = 2 * MAX_DEFINED_PEERS,
914
SEND_PEER_LIST_SIZE = 2 * MAX_DEFINED_PEERS,
915
RECV_PEER_LIST_SIZE = 2 * MAX_DEFINED_PEERS,
916
PARENT_PEER_LIST_SIZE = 2 * MAX_DEFINED_PEERS,
917
PEER_ID_POLL_INDEX_SIZE = 2 * MAX_DEFINED_PEERS
921
int _nPeerList; // valid PeerList[] entries - 1
922
Ptr<Peer> _PeerList[PEER_LIST_SIZE];
923
Ptr<Peer> _LocalPeer;
925
// Peers which are targets of ICP queries
926
int _curSendPeer; // index bias for SendPeerList[]
927
int _nSendPeerList; // valid SendPeerList[] entries - 1
928
Ptr<Peer> _SendPeerList[SEND_PEER_LIST_SIZE];
930
// List of Peers whom we issue reads from
931
int _curRecvPeer; // index bias for RecvPeerList[]
932
int _nRecvPeerList; // valid RecvPeerList[] entries - 1
933
Ptr<Peer> _RecvPeerList[RECV_PEER_LIST_SIZE];
935
// Peers on SendPeerList which are "parent" peers
936
int _curParentPeer; // index bias for ParentPeerList[]
937
int _nParentPeerList; // valid ParentPeerList[] entries - 1
938
Ptr<Peer> _ParentPeerList[PARENT_PEER_LIST_SIZE];
940
// Peer ID to Poll descriptor index map
942
int _PeerIDtoPollIndex[PEER_ID_POLL_INDEX_SIZE];
943
int _last_recv_peer_bias; // bias used to build last poll data
946
//-----------------------------------------------------------------
947
// PeriodicCont -- Abstract base class for periodic ICP processor
949
//-----------------------------------------------------------------
950
class PeriodicCont:public Continuation
953
PeriodicCont(ICPProcessor * p);
954
virtual ~ PeriodicCont();
955
virtual int PeriodicEvent(int, Event *) = 0;
958
ICPProcessor * _ICPpr;
961
//---------------------------------------------------------------
962
// ICPPeriodicCont -- ICPProcessor periodic event continuation.
963
// Periodicly look for ICP configuration updates and if
964
// updates exist schedule ICP reconfiguration.
965
//---------------------------------------------------------------
966
class ICPPeriodicCont:public PeriodicCont
970
{ PERIODIC_INTERVAL = 5000 };
972
{ RETRY_INTERVAL_MSECS = 10 };
973
ICPPeriodicCont(ICPProcessor *);
977
virtual int PeriodicEvent(int, Event *);
978
int DoReconfigAction(int, Event *);
981
int _last_icp_config_callouts;
982
int _global_config_changed;
983
int _peer_config_changed;
986
//-----------------------------------------------------------------
987
// ICPHandlerCont -- Periodic for incoming message processing
988
//-----------------------------------------------------------------
989
class ICPHandlerCont:public PeriodicCont
994
ICP_HANDLER_INTERVAL = 10
996
ICPHandlerCont(ICPProcessor *);
1000
virtual int PeriodicEvent(int, Event *);
1001
virtual int TossEvent(int, Event *);
1005
#define MAX_ICP_HISTORY 20
1013
statehistory _history[MAX_ICP_HISTORY];
1016
#define RECORD_ICP_STATE_CHANGE(peerreaddata,event_,newstate_) \
1017
peerreaddata->_history[peerreaddata->_nhistory].event = event_; \
1018
peerreaddata->_history[peerreaddata->_nhistory].newstate = newstate_; \
1019
peerreaddata->_history[peerreaddata->_nhistory].file = __FILE__; \
1020
peerreaddata->_history[peerreaddata->_nhistory].line = __LINE__; \
1021
peerreaddata->_nhistory = (peerreaddata->_nhistory + 1) % MAX_ICP_HISTORY;
1024
#define RECORD_ICP_STATE_CHANGE(x,y,z)
1027
static int64_t ICPDataBuf_IOBuffer_sizeindex;
1030
//------------------------------------------------------------------
1031
// ICPPeerReadCont -- ICP incoming message processing state machine
1032
//------------------------------------------------------------------
1033
class ICPPeerReadCont:public Continuation
1043
AWAITING_CACHE_LOOKUP_RESPONSE,
1047
GET_ICP_REQUEST_MUTEX,
1049
READ_NOT_ACTIVE_EXIT,
1050
READ_PROCESSING_COMPLETE
1059
void reset(int full_reset = 0);
1061
ink_hrtime _start_time;
1062
ICPPeerReadCont *_mycont;
1064
PeerReadState_t _next_state;
1065
int _cache_lookup_local;
1066
Ptr<IOBufferBlock> _buf; // the buffer with the ICP message in it
1069
struct sockaddr_in _sender; // sender of rICPmsg
1070
URL _cachelookupURL;
1072
ICPRequestCont *_ICPReqCont;
1075
struct msghdr _mhdr;
1076
struct iovec _iov[MSG_IOVECS];
1080
void init(ICPProcessor *, Peer *, int);
1082
void reset(int full_reset = 0);
1083
int ICPPeerReadEvent(int, Event *);
1084
int ICPPeerQueryCont(int, Event *);
1085
int ICPPeerQueryEvent(int, Event *);
1086
int StaleCheck(int, Event *);
1087
int PeerReadStateMachine(PeerReadData *, Event *);
1090
{ RETRY_INTERVAL = 10 };
1092
// Freshness specific data
1093
CacheVConnection *_object_vc;
1094
HTTPInfo *_object_read;
1095
HdrHeapSDKHandle *_cache_req_hdr_heap_handle;
1096
HdrHeapSDKHandle *_cache_resp_hdr_heap_handle;
1100
ICPProcessor * _ICPpr;
1101
PeerReadData *_state;
1102
ink_hrtime _start_time;
1103
int _recursion_depth;
1106
//----------------------------------------------------------------------
1107
// ICPRequestCont -- ICP Request continuation (Outgoing ICP requests)
1108
//----------------------------------------------------------------------
1109
class ICPRequestCont:public Continuation
1111
friend class ICPProcessor;
1114
ICPRequestCont(ICPProcessor * i = 0, Continuation * c = 0, URL * u = 0);
1116
void *operator new(size_t size, void *mem);
1117
void operator delete(void *mem);
1118
inline void SetRequestStartTime()
1120
_start_time = ink_get_hrtime();
1122
inline ink_hrtime GetRequestStartTime()
1126
inline class Action *GetActionPtr()
1132
{ RETRY_INTERVAL = 10 };
1134
{ ICP_REQUEST_HASH_SIZE = 1024 };
1136
//***********************************************************************
1137
// ICPPeerReadCont::PeerReadStateMachine() to
1138
// ICPRequestCont::ICPStateMachine() calling sequence definition.
1140
// ICPRequestEvent(ICP_RESPONSE_MESSAGE, ICPRequestEventArgs_t *)
1142
//***********************************************************************
1143
typedef struct ICPRequestEventArgs
1148
} ICPRequestEventArgs_t;
1149
//***********************************************************************
1150
int ICPRequestEvent(int, Event *);
1151
int NopICPRequestEvent(int, Event *);
1153
// Static member functions
1154
static void NetToHostICPMsg(ICPMsg_t *, ICPMsg_t *);
1155
static int BuildICPMsg(ICPopcode_t op, unsigned int sequence_number,
1156
int optflags, int optdata, int shostid,
1157
void *data, int datalen, struct msghdr *mhdr, struct iovec *iov, ICPMsg_t * icpmsg);
1159
static unsigned int ICPReqSeqNumber();
1160
static int ICPRequestHash(unsigned int);
1161
static int AddICPRequest(unsigned int, ICPRequestCont *);
1162
static ICPRequestCont *FindICPRequest(unsigned int);
1163
static int RemoveICPRequest(unsigned int);
1171
ICP_AWAITING_RESPONSE,
1172
ICP_DEQUEUE_REQUEST,
1173
ICP_POST_COMPLETION,
1174
ICP_WAIT_SEND_COMPLETE,
1175
ICP_REQUEST_NOT_ACTIVE,
1178
int ICPStateMachine(int, void *);
1179
int ICPResponseMessage(int, ICPMsg_t *, int, Peer *);
1180
void remove_from_pendingActions(Action *);
1181
void remove_all_pendingActions();
1184
static uint32_t ICPRequestSeqno;
1186
// Passed request data
1187
Continuation *_cont;
1191
struct sockaddr_in _ret_sockaddr;
1192
ICPreturn_t _ret_status;
1195
// Internal working data
1196
ink_hrtime _start_time;
1197
ICPProcessor *_ICPpr;
1200
// outstanding actions
1201
int npending_actions;
1202
DynArray<Action *>*pendingActions;
1205
struct msghdr _sendMsgHdr;
1206
struct iovec _sendMsgIOV[MSG_IOVECS];
1208
unsigned int _sequence_number;
1209
int _expected_replies;
1210
BitMap _expected_replies_list;
1211
int _received_replies;
1212
ICPstate_t _next_state;
1216
extern ClassAllocator<ICPRequestCont> ICPRequestCont_allocator;
1218
typedef int (*PluginFreshnessCalcFunc) (void *contp);
1219
extern PluginFreshnessCalcFunc pluginFreshnessCalcFunc;
1222
ICPRequestCont::operator
1223
new(size_t size, void *mem)
1225
NOWARN_UNUSED(size);
1230
ICPRequestCont::operator
1233
ICPRequestCont_allocator.free((ICPRequestCont *) mem);
1236
extern struct RecRawStatBlock *icp_rsb;
1241
config_mgmt_callouts_stat,
1242
reconfig_polls_stat,
1243
reconfig_events_stat,
1244
invalid_poll_data_stat,
1247
invalid_sender_stat,
1248
read_not_v2_icp_stat,
1249
icp_remote_query_requests_stat,
1250
icp_remote_responses_stat,
1251
icp_cache_lookup_success_stat,
1252
icp_cache_lookup_fail_stat,
1253
query_response_write_stat,
1254
query_response_partial_write_stat,
1255
no_icp_request_for_response_stat,
1256
icp_response_request_nolock_stat,
1257
icp_start_icpoff_stat,
1258
send_query_partial_write_stat,
1259
icp_queries_no_expected_replies_stat,
1260
icp_query_hits_stat,
1261
icp_query_misses_stat,
1262
invalid_icp_query_response_stat,
1263
icp_query_requests_stat,
1264
total_icp_response_time_stat,
1265
total_udp_send_queries_stat,
1266
total_icp_request_time_stat,
1268
icp_pending_reloads,
1269
icp_reload_start_aborts,
1270
icp_reload_connect_aborts,
1271
icp_reload_read_aborts,
1272
icp_reload_write_aborts,
1273
icp_reload_successes,
1277
#define ICP_EstablishStaticConfigInteger(_ix,_n) \
1278
REC_EstablishStaticConfigInt32(_ix,_n)
1280
#define ICP_EstablishStaticConfigStringAlloc(_ix, n) \
1281
REC_EstablishStaticConfigStringAlloc(_ix, n)
1283
#define ICP_INCREMENT_DYN_STAT(x) \
1284
RecIncrRawStat(icp_rsb, mutex->thread_holding, (int) x, 1)
1285
#define ICP_DECREMENT_DYN_STAT(x) \
1286
RecIncrRawStat(icp_rsb, mutex->thread_holding, (int) x, -1)
1287
#define ICP_SUM_DYN_STAT(x, y) \
1288
RecIncrRawStat(icp_rsb, mutex->thread_holding, (int) x, (y))
1289
#define ICP_READ_DYN_STAT(x, C, S) \
1290
RecGetRawStatCount(icp_rsb, (int) x, &C); \
1291
RecGetRawStatSum(icp_rsb, (int) x, &S);
1293
#define ICP_ReadConfigString REC_ReadConfigString
1294
#define ICP_RegisterConfigUpdateFunc REC_RegisterConfigUpdateFunc