~ps10gel/ubuntu/xenial/trafficserver/6.2.0

« back to all changes in this revision

Viewing changes to proxy/ICP.h

  • Committer: Bazaar Package Importer
  • Author(s): Arno Toell
  • Date: 2011-01-13 11:49:18 UTC
  • Revision ID: james.westby@ubuntu.com-20110113114918-vu422h8dknrgkj15
Tags: upstream-2.1.5-unstable
ImportĀ upstreamĀ versionĀ 2.1.5-unstable

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/** @file
 
2
 
 
3
  A brief file description
 
4
 
 
5
  @section license License
 
6
 
 
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
 
14
 
 
15
      http://www.apache.org/licenses/LICENSE-2.0
 
16
 
 
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.
 
22
 */
 
23
 
 
24
 
 
25
/****************************************************************************
 
26
 
 
27
  ICP.h
 
28
 
 
29
 
 
30
****************************************************************************/
 
31
 
 
32
#ifndef _ICP_H_
 
33
#define _ICP_H_
 
34
 
 
35
#include "P_Net.h"
 
36
#include "P_Cache.h"
 
37
#define  ET_ICP ET_CALL
 
38
#include "URL.h"
 
39
#include "ICPevents.h"
 
40
#include "ICPProcessor.h"
 
41
#include "DynArray.h"
 
42
 
 
43
 
 
44
//*********************************************************************
 
45
// ICP Configurables
 
46
//*********************************************************************
 
47
#define ICP_DEBUG       1
 
48
 
 
49
 
 
50
//*********************************************************************
 
51
// ICP.h -- Internet Cache Protocol (ICP) related data structures.
 
52
//
 
53
// Message protocol definitions as defined by RFC 2186
 
54
// "Internet Cache Protocol (ICP), version 2".
 
55
//*********************************************************************
 
56
typedef struct ICPMsgHeader
 
57
{
 
58
  uint8_t opcode;
 
59
  uint8_t version;
 
60
  uint16_t msglen;
 
61
  uint32_t requestno;
 
62
  uint32_t optionflags;
 
63
  uint32_t optiondata;
 
64
  uint32_t shostid;
 
65
} ICPMsgHdr_t;
 
66
 
 
67
//-----------------------
 
68
// opcode definitions
 
69
//-----------------------
 
70
typedef enum
 
71
{
 
72
  ICP_OP_INVALID,               // 00
 
73
  ICP_OP_QUERY,                 // 01
 
74
  ICP_OP_HIT,                   // 02
 
75
  ICP_OP_MISS,                  // 03
 
76
  ICP_OP_ERR,                   // 04
 
77
  //
 
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
 
83
  //
 
84
  ICP_OP_SECHO,                 // 10
 
85
  ICP_OP_DECHO,                 // 11
 
86
  //
 
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
 
96
  //
 
97
  ICP_OP_MISS_NOFETCH,          // 21
 
98
  ICP_OP_DENIED,                // 22
 
99
  ICP_OP_HIT_OBJ,               // 23
 
100
  ICP_OP_END_OF_OPS             // 24 mark end of opcodes
 
101
} ICPopcode_t;
 
102
 
 
103
#define ICP_OP_LAST             (ICP_OP_END_OF_OPS - 1)
 
104
 
 
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
 
112
 
 
113
//--------------------------
 
114
// optionflags definitions
 
115
//--------------------------
 
116
#define ICP_FLAG_HIT_OBJ        0x80000000ul
 
117
#define ICP_FLAG_SRC_RTT        0x40000000ul
 
118
 
 
119
//-----------------
 
120
// ICP Constants
 
121
//-----------------
 
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
 
127
 
 
128
//------------
 
129
// ICP Data
 
130
//------------
 
131
typedef struct ICPData
 
132
{
 
133
  char *URL;                    // null terminated
 
134
} ICPData_t;
 
135
 
 
136
//-------------
 
137
// ICP Query
 
138
//-------------
 
139
typedef struct ICPQuery
 
140
{
 
141
  uint32_t rhostid;
 
142
  char *URL;                    // null terminated (outgoing)
 
143
} ICPQuery_t;
 
144
 
 
145
//------------
 
146
// ICP Hit
 
147
//------------
 
148
typedef struct ICPHit
 
149
{
 
150
  char *URL;                    // null terminated
 
151
} ICPHit_t;
 
152
 
 
153
//------------
 
154
// ICP Miss
 
155
//------------
 
156
typedef struct ICPMiss
 
157
{
 
158
  char *URL;                    // null terminated
 
159
} ICPMiss_t;
 
160
 
 
161
//------------------
 
162
// ICP Hit Object
 
163
//------------------
 
164
typedef struct ICPHitObj
 
165
{
 
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
 
170
} ICPHitObj_t;
 
171
 
 
172
//------------------------
 
173
// ICP message descriptor
 
174
//------------------------
 
175
typedef struct ICPMsg
 
176
{
 
177
  ICPMsgHdr_t h;
 
178
  union
 
179
  {
 
180
    ICPData_t data;
 
181
    ICPQuery_t query;
 
182
    ICPHit_t hit;
 
183
    ICPMiss_t miss;
 
184
    ICPHitObj_t hitobj;
 
185
  } un;
 
186
} ICPMsg_t;
 
187
 
 
188
//******************************************************************
 
189
// ICP implementation specific data structures.
 
190
//******************************************************************
 
191
 
 
192
class BitMap;
 
193
class ICPProcessor;
 
194
class ICPPeriodicCont;
 
195
class ICPHandlerCont;
 
196
class ICPPeerReadCont;
 
197
class ICPRequestCont;
 
198
 
 
199
typedef enum
 
200
{
 
201
  PEER_NONE = 0,
 
202
  PEER_PARENT = 1,
 
203
  PEER_SIBLING = 2,
 
204
  PEER_LOCAL = 3,
 
205
  PEER_MULTICAST = 4
 
206
} PeerType_t;
 
207
 
 
208
#if !defined(USE_CAS_FOR_ATOMICLOCK)
 
209
class AtomicLock
 
210
{
 
211
public:
 
212
  AtomicLock();
 
213
  ~AtomicLock();
 
214
  int Lock();
 
215
  int HaveLock();
 
216
  void Unlock();
 
217
 
 
218
private:
 
219
    ProxyMutexPtr _mutex;
 
220
};
 
221
 
 
222
#else // USE_CAS_FOR_ATOMICLOCK
 
223
class AtomicLock
 
224
{
 
225
public:
 
226
  AtomicLock();
 
227
  ~AtomicLock();
 
228
  int Lock();
 
229
  int HaveLock();
 
230
  void Unlock();
 
231
 
 
232
private:
 
233
  enum
 
234
  { UNLOCKED = 0, LOCKED = 1 };
 
235
  int32_t _lock_word;
 
236
};
 
237
#endif // USE_CAS_FOR_ATOMICLOCK
 
238
 
 
239
//-----------------------------------------------------------------
 
240
// Class ICPConfigData -- deal with global ICP configuration data
 
241
//-----------------------------------------------------------------
 
242
class ICPConfigData
 
243
{
 
244
  friend class ICPConfiguration;
 
245
 
 
246
public:
 
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)
 
250
  {
 
251
  }
 
252
   ~ICPConfigData()
 
253
  {
 
254
  }                             // Note: _icp_interface freed prior to delete
 
255
  inline int operator==(ICPConfigData &);
 
256
  inline int ICPconfigured()
 
257
  {
 
258
    return _icp_enabled;
 
259
  }
 
260
  inline int ICPport()
 
261
  {
 
262
    return _icp_port;
 
263
  }
 
264
  inline char *ICPinterface()
 
265
  {
 
266
    return _icp_interface;
 
267
  }
 
268
  inline int ICPmulticastConfigured()
 
269
  {
 
270
    return _multicast_enabled;
 
271
  }
 
272
  inline int ICPqueryTimeout()
 
273
  {
 
274
    return _icp_query_timeout;
 
275
  }
 
276
  inline int ICPLocalCacheLookup()
 
277
  {
 
278
    return _cache_lookup_local;
 
279
  }
 
280
  inline int ICPStaleLookup()
 
281
  {
 
282
    return _stale_lookup;
 
283
  }
 
284
  inline int ICPReplyToUnknownPeer()
 
285
  {
 
286
    return _reply_to_unknown_peer;
 
287
  }
 
288
  inline int ICPDefaultReplyPort()
 
289
  {
 
290
    return _default_reply_port;
 
291
  }
 
292
 
 
293
private:
 
294
  //---------------------------------------------------------
 
295
  // ICP Configuration data derived from "records.config"
 
296
  //---------------------------------------------------------
 
297
  int _icp_enabled;             // see ICP_MODE_XXX defines
 
298
  int _icp_port;
 
299
  char *_icp_interface;
 
300
  int _multicast_enabled;
 
301
  int _icp_query_timeout;
 
302
  int _cache_lookup_local;
 
303
  int _stale_lookup;
 
304
  int _reply_to_unknown_peer;
 
305
  int _default_reply_port;
 
306
};
 
307
 
 
308
//----------------------------------------------------------------
 
309
// Class PeerConfigData -- deal with peer ICP configuration data
 
310
//----------------------------------------------------------------
 
311
class PeerConfigData
 
312
{
 
313
  friend class ICPConfiguration;
 
314
  friend class ICPProcessor;
 
315
 
 
316
public:
 
317
    PeerConfigData();
 
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)
 
321
  {
 
322
    _hostname[0] = 0;
 
323
    _mc_ip_addr.s_addr = 0;
 
324
  }
 
325
   ~PeerConfigData()
 
326
  {
 
327
  }
 
328
  bool operator==(PeerConfigData &);
 
329
  inline const char *GetHostname()
 
330
  {
 
331
    return _hostname;
 
332
  }
 
333
  inline int GetCType()
 
334
  {
 
335
    return _ctype;
 
336
  }
 
337
  inline struct in_addr *GetIP()
 
338
  {
 
339
    return &_my_ip_addr;
 
340
  }
 
341
  inline int GetProxyPort()
 
342
  {
 
343
    return _proxy_port;
 
344
  }
 
345
  inline int GetICPPort()
 
346
  {
 
347
    return _icp_port;
 
348
  }
 
349
  inline int MultiCastMember()
 
350
  {
 
351
    return _mc_member;
 
352
  }
 
353
  inline struct in_addr *GetMultiCastIP()
 
354
  {
 
355
    return &_mc_ip_addr;
 
356
  }
 
357
  inline int GetMultiCastTTL()
 
358
  {
 
359
    return _mc_ttl;
 
360
  }
 
361
 
 
362
  // Static member functions
 
363
  static PeerType_t CTypeToPeerType_t(int);
 
364
  static int GetHostIPByName(char *, struct in_addr *);
 
365
 
 
366
  enum
 
367
  { HOSTNAME_SIZE = 256 };
 
368
  enum
 
369
  { CTYPE_NONE = 0,
 
370
    CTYPE_PARENT = 1,
 
371
    CTYPE_SIBLING = 2,
 
372
    CTYPE_LOCAL = 3
 
373
  };
 
374
 
 
375
private:
 
376
  //---------------------------------------------------------
 
377
  // Peer Configuration data derived from "icp.config"
 
378
  //---------------------------------------------------------
 
379
  char _hostname[HOSTNAME_SIZE];
 
380
  int _ctype;
 
381
  struct in_addr _ip_addr;
 
382
  int _proxy_port;
 
383
  int _icp_port;
 
384
  //-------------------
 
385
  // MultiCast data
 
386
  //-------------------
 
387
  int _mc_member;
 
388
  struct in_addr _mc_ip_addr;
 
389
  int _mc_ttl;
 
390
 
 
391
  //----------------------------------------------
 
392
  // Computed data not subject to "==" test
 
393
  //----------------------------------------------
 
394
  struct in_addr _my_ip_addr;
 
395
};
 
396
 
 
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
 
403
{
 
404
public:
 
405
  ICPConfigUpdateCont(void *data, void *value);
 
406
   ~ICPConfigUpdateCont()
 
407
  {
 
408
  }
 
409
  int RetryICPconfigUpdate(int, Event *);
 
410
 
 
411
  enum
 
412
  { RETRY_INTERVAL = 10 };
 
413
 
 
414
private:
 
415
  void *_data;
 
416
  void *_value;
 
417
};
 
418
 
 
419
//------------------------------------------------------------------
 
420
// Class ICPConfiguration -- Overall management of ICP Config data
 
421
//------------------------------------------------------------------
 
422
class ICPConfiguration
 
423
{
 
424
public:
 
425
  ICPConfiguration();
 
426
  ~ICPConfiguration();
 
427
  int GlobalConfigChange();
 
428
  void UpdateGlobalConfig();
 
429
  int PeerConfigChange();
 
430
  void UpdatePeerConfig();
 
431
 
 
432
  inline ICPConfigData *globalConfig()
 
433
  {
 
434
    return _icp_cdata;
 
435
  }
 
436
  inline PeerConfigData *indexToPeerConfigData(int index)
 
437
  {
 
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];
 
442
  }
 
443
 
 
444
  // TS configuration management callout for "icp.config".
 
445
  static int mgr_icp_config_change_callback(const char *, RecDataT, RecData, void *);
 
446
 
 
447
  // ICP configuration callout for ET_ICP
 
448
  static void *icp_config_change_callback(void *, void *, int startup = 0);
 
449
 
 
450
  inline int Lock()
 
451
  {
 
452
    return _l.Lock();
 
453
  }
 
454
  inline void Unlock()
 
455
  {
 
456
    _l.Unlock();
 
457
    return;
 
458
  }
 
459
  inline int HaveLock()
 
460
  {
 
461
    return _l.HaveLock();
 
462
  }
 
463
 
 
464
  inline int ICPConfigCallouts()
 
465
  {
 
466
    return _icp_config_callouts;
 
467
  }
 
468
 
 
469
private:
 
470
  // Class data declarations
 
471
  AtomicLock _l;
 
472
  int _icp_config_callouts;
 
473
 
 
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.
 
482
  //
 
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];
 
487
};
 
488
 
 
489
//------------------------------------------------------------------------
 
490
// Class Peer -- Internal structure representing ICP peers derived from
 
491
//               configuration data (abstract base class).
 
492
//------------------------------------------------------------------------
 
493
 
 
494
// Peer state
 
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
 
498
 
 
499
struct CacheVConnection;
 
500
 
 
501
class Peer:public RefCountObj
 
502
{
 
503
public:
 
504
  Peer(PeerType_t, ICPProcessor *, bool dynamic_peer = false);
 
505
  virtual ~ Peer()
 
506
  {
 
507
  }
 
508
  void LogRecvMsg(ICPMsg_t *, int);
 
509
 
 
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;
 
524
 
 
525
  enum
 
526
  { OFFLINE_THRESHOLD = 20 };
 
527
 
 
528
  inline PeerType_t GetType()
 
529
  {
 
530
    return _type;
 
531
  }
 
532
  inline int GetPeerID()
 
533
  {
 
534
    return _id;
 
535
  }
 
536
  inline void SetPeerID(int newid)
 
537
  {
 
538
    _id = newid;
 
539
  }
 
540
  inline void SetNext(Peer * p)
 
541
  {
 
542
    _next = p;
 
543
  }
 
544
  inline Peer *GetNext()
 
545
  {
 
546
    return _next;
 
547
  }
 
548
  inline bool shouldStartRead()
 
549
  {
 
550
    return !notFirstRead;
 
551
  }
 
552
  inline void startingRead()
 
553
  {
 
554
    notFirstRead = 1;
 
555
  }
 
556
  inline void cancelRead()
 
557
  {
 
558
    notFirstRead = 0;
 
559
  }
 
560
  inline bool readActive()
 
561
  {
 
562
    return (readAction != NULL);
 
563
  }
 
564
  inline bool isUp()
 
565
  {
 
566
    return (_state & PEER_UP);
 
567
  }
 
568
 
 
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
 
577
 
 
578
protected:
 
579
  PeerType_t _type;
 
580
  int _id;                      // handle for this peer
 
581
  Peer *_next;
 
582
  ICPProcessor *_ICPpr;
 
583
 
 
584
  //--------------
 
585
  // State data
 
586
  //--------------
 
587
  int _state;
 
588
 
 
589
  //-------------------
 
590
  // Peer Statistics
 
591
  //-------------------
 
592
  struct PeerStats
 
593
  {
 
594
    ink_hrtime last_send;
 
595
    ink_hrtime last_receive;
 
596
    int sent[ICP_OP_LAST + 1];
 
597
    int recv[ICP_OP_LAST + 1];
 
598
    int total_sent;
 
599
    int total_received;
 
600
    int dropped_replies;        // arrived after timeout
 
601
  } _stats;
 
602
};
 
603
 
 
604
//------------------------------------------------
 
605
// Class ParentSiblingPeer (derived from Peer)
 
606
//------------------------------------------------
 
607
class ParentSiblingPeer:public Peer
 
608
{
 
609
public:
 
610
  ParentSiblingPeer(PeerType_t, PeerConfigData *, ICPProcessor *, bool dynamic_peer = false);
 
611
  ~ParentSiblingPeer()
 
612
  {
 
613
    if (_pconfig && (_state & PEER_DYNAMIC))
 
614
      delete _pconfig;
 
615
  }
 
616
  int GetProxyPort();
 
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()
 
628
  {
 
629
    return 1;
 
630
  }
 
631
  inline virtual Connection *GetSendChan()
 
632
  {
 
633
    return &_chan;
 
634
  }
 
635
  inline virtual Connection *GetRecvChan()
 
636
  {
 
637
    return &_chan;
 
638
  }
 
639
  inline PeerConfigData *GetConfig()
 
640
  {
 
641
    return _pconfig;
 
642
  }
 
643
  inline Connection *GetChan()
 
644
  {
 
645
    return &_chan;
 
646
  }
 
647
 
 
648
private:
 
649
  // Class data declarations
 
650
  PeerConfigData * _pconfig;    // associated config data
 
651
  Connection _chan;
 
652
};
 
653
 
 
654
//------------------------------------------------
 
655
// Class MultiCastPeer (derived from Peer)
 
656
//------------------------------------------------
 
657
class MultiCastPeer:public Peer
 
658
{
 
659
public:
 
660
  MultiCastPeer(struct in_addr *, int, int, ICPProcessor *);
 
661
  ~MultiCastPeer()
 
662
  {
 
663
  }
 
664
  int GetTTL();
 
665
  int AddMultiCastChild(Peer * P);
 
666
  Peer *FindMultiCastChild(struct in_addr *ip, int port);
 
667
 
 
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()
 
679
  {
 
680
    return &_recv_chan;
 
681
  }
 
682
  inline virtual Connection *GetSendChan()
 
683
  {
 
684
    return &_send_chan;
 
685
  }
 
686
  inline virtual int ExtToIntRecvSockAddr(struct sockaddr_in *in, struct sockaddr_in *out)
 
687
  {
 
688
    Peer *P = FindMultiCastChild(&in->sin_addr, 0);
 
689
    if (P) {
 
690
      out->sin_addr = in->sin_addr;
 
691
      out->sin_port = htons(P->GetPort());
 
692
      return 1;
 
693
    } else {
 
694
      return 0;
 
695
    }
 
696
  }
 
697
 
 
698
private:
 
699
  // Class data declarations
 
700
  Connection _send_chan;
 
701
  Connection _recv_chan;
 
702
  //---------------------------
 
703
  // Multicast specific data
 
704
  //---------------------------
 
705
  struct sockaddr_in _mc_addr;
 
706
  int _mc_ttl;
 
707
  struct multicast_data
 
708
  {
 
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
 
714
  } _mc;
 
715
};
 
716
 
 
717
//----------------------------------------------------
 
718
// Class BitMap -- Generic bit map management class
 
719
//----------------------------------------------------
 
720
class BitMap
 
721
{
 
722
public:
 
723
  BitMap(int);
 
724
   ~BitMap();
 
725
  void SetBit(int);
 
726
  void ClearBit(int);
 
727
  int IsBitSet(int);
 
728
 
 
729
private:
 
730
  enum
 
731
  { STATIC_BITMAP_BYTE_SIZE = 16,
 
732
    BITS_PER_BYTE = 8
 
733
  };
 
734
  char _static_bitmap[STATIC_BITMAP_BYTE_SIZE];
 
735
  char *_bitmap;
 
736
  int _bitmap_size;
 
737
  int _bitmap_byte_size;
 
738
};
 
739
 
 
740
//----------------------------------------
 
741
// ICPProcessor -- ICP External interface
 
742
//----------------------------------------
 
743
class ICPProcessor
 
744
{
 
745
  friend class ICPHandlerCont;  // Incoming msg periodic handler
 
746
  friend class ICPPeerReadCont; // Incoming ICP request handler
 
747
  friend class ICPRequestCont;  // Outgoing ICP request handler
 
748
 
 
749
public:
 
750
    ICPProcessor();
 
751
   ~ICPProcessor();
 
752
 
 
753
  // Exported interfaces for other subsystems
 
754
  void start();
 
755
  Action *ICPQuery(Continuation *, URL *);
 
756
 
 
757
  // Exported interfaces to other ICP classes
 
758
  typedef enum
 
759
  {
 
760
    RC_RECONFIG,
 
761
    RC_ENABLE_ICP,
 
762
    RC_DONE
 
763
  } ReconfigState_t;
 
764
  ReconfigState_t ReconfigureStateMachine(ReconfigState_t, int, int);
 
765
 
 
766
  Peer *FindPeer(struct in_addr *, int);
 
767
  inline Peer *GetLocalPeer()
 
768
  {
 
769
    return _LocalPeer;
 
770
  }
 
771
  inline Peer *IdToPeer(int id)
 
772
  {
 
773
    return _PeerList[id];
 
774
  }
 
775
  inline ICPConfiguration *GetConfig()
 
776
  {
 
777
    return _ICPConfig;
 
778
  }
 
779
 
 
780
  inline int GetFreePeers()
 
781
  {
 
782
    return PEER_LIST_SIZE - (_nPeerList + 1);
 
783
  }
 
784
  inline int GetFreeSendPeers()
 
785
  {
 
786
    return SEND_PEER_LIST_SIZE - (_nSendPeerList + 1);
 
787
  }
 
788
  inline int GetFreeRecvPeers()
 
789
  {
 
790
    return RECV_PEER_LIST_SIZE - (_nRecvPeerList + 1);
 
791
  }
 
792
 
 
793
private:
 
794
  inline int Lock()
 
795
  {
 
796
    return _l->Lock();
 
797
  }
 
798
  inline void Unlock()
 
799
  {
 
800
    _l->Unlock();
 
801
    return;
 
802
  }
 
803
  inline int HaveLock()
 
804
  {
 
805
    return _l->HaveLock();
 
806
  }
 
807
  int BuildPeerList();
 
808
  void FreePeerList();
 
809
  int SetupListenSockets();
 
810
  void ShutdownListenSockets();
 
811
  int Reconfigure(int, int);
 
812
  void InitICPStatCallbacks();
 
813
 
 
814
  inline void DisableICPQueries()
 
815
  {
 
816
    _AllowIcpQueries = 0;
 
817
  }
 
818
  inline void EnableICPQueries()
 
819
  {
 
820
    _AllowIcpQueries = 1;
 
821
  }
 
822
  inline int AllowICPQueries()
 
823
  {
 
824
    return _AllowIcpQueries;
 
825
  }
 
826
  inline int PendingQuery()
 
827
  {
 
828
    return _PendingIcpQueries;
 
829
  }
 
830
  inline void IncPendingQuery()
 
831
  {
 
832
    _PendingIcpQueries++;
 
833
  }
 
834
  inline void DecPendingQuery()
 
835
  {
 
836
    _PendingIcpQueries--;
 
837
  }
 
838
 
 
839
  Peer *GenericFindListPeer(struct in_addr *, int, int, Ptr<Peer> *);
 
840
  Peer *FindSendListPeer(struct in_addr *, int);
 
841
  Peer *FindRecvListPeer(struct in_addr *, int);
 
842
  int AddPeer(Peer *);
 
843
  int AddPeerToSendList(Peer *);
 
844
  int AddPeerToRecvList(Peer *);
 
845
  int AddPeerToParentList(Peer *);
 
846
 
 
847
  inline int GetSendPeers()
 
848
  {
 
849
    return _nSendPeerList + 1;
 
850
  }
 
851
  inline Peer *GetNthSendPeer(int n, int bias)
 
852
  {
 
853
    return _SendPeerList[(bias + n) % (_nSendPeerList + 1)];
 
854
  }
 
855
 
 
856
  inline int GetRecvPeers()
 
857
  {
 
858
    return _nRecvPeerList + 1;
 
859
  }
 
860
  inline Peer *GetNthRecvPeer(int n, int bias)
 
861
  {
 
862
    return _RecvPeerList[(bias + n) % (_nRecvPeerList + 1)];
 
863
  }
 
864
 
 
865
  inline int GetStartingSendPeerBias()
 
866
  {
 
867
    return ++_curSendPeer;
 
868
  }
 
869
  inline int GetStartingRecvPeerBias()
 
870
  {
 
871
    return ++_curRecvPeer;
 
872
  }
 
873
 
 
874
  inline int GetParentPeers()
 
875
  {
 
876
    return _nParentPeerList + 1;
 
877
  }
 
878
  inline Peer *GetNthParentPeer(int n, int bias)
 
879
  {
 
880
    return _ParentPeerList[(bias + n) % (_nParentPeerList + 1)];
 
881
  }
 
882
  inline int GetStartingParentPeerBias()
 
883
  {
 
884
    return ++_curParentPeer;
 
885
  }
 
886
 
 
887
  inline void SetLastRecvPeerBias(int b)
 
888
  {
 
889
    _last_recv_peer_bias = b;
 
890
  }
 
891
  inline int GetLastRecvPeerBias()
 
892
  {
 
893
    return _last_recv_peer_bias;
 
894
  }
 
895
  void CancelPendingReads();
 
896
  void DumpICPConfig();
 
897
 
 
898
private:
 
899
  // Class data declarations
 
900
  AtomicLock * _l;
 
901
  int _Initialized;
 
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;
 
910
 
 
911
  enum
 
912
  {
 
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
 
918
  };
 
919
 
 
920
  // All Peer elements
 
921
  int _nPeerList;               // valid PeerList[] entries - 1
 
922
  Ptr<Peer> _PeerList[PEER_LIST_SIZE];
 
923
  Ptr<Peer> _LocalPeer;
 
924
 
 
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];
 
929
 
 
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];
 
934
 
 
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];
 
939
 
 
940
  // Peer ID to Poll descriptor index map
 
941
  int _ValidPollData;
 
942
  int _PeerIDtoPollIndex[PEER_ID_POLL_INDEX_SIZE];
 
943
  int _last_recv_peer_bias;     // bias used to build last poll data
 
944
};
 
945
 
 
946
//-----------------------------------------------------------------
 
947
// PeriodicCont -- Abstract base class for periodic ICP processor
 
948
//                 continuations
 
949
//-----------------------------------------------------------------
 
950
class PeriodicCont:public Continuation
 
951
{
 
952
public:
 
953
  PeriodicCont(ICPProcessor * p);
 
954
  virtual ~ PeriodicCont();
 
955
  virtual int PeriodicEvent(int, Event *) = 0;
 
956
 
 
957
protected:
 
958
    ICPProcessor * _ICPpr;
 
959
};
 
960
 
 
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
 
967
{
 
968
public:
 
969
  enum
 
970
  { PERIODIC_INTERVAL = 5000 };
 
971
  enum
 
972
  { RETRY_INTERVAL_MSECS = 10 };
 
973
    ICPPeriodicCont(ICPProcessor *);
 
974
   ~ICPPeriodicCont()
 
975
  {
 
976
  }
 
977
  virtual int PeriodicEvent(int, Event *);
 
978
  int DoReconfigAction(int, Event *);
 
979
 
 
980
private:
 
981
  int _last_icp_config_callouts;
 
982
  int _global_config_changed;
 
983
  int _peer_config_changed;
 
984
};
 
985
 
 
986
//-----------------------------------------------------------------
 
987
// ICPHandlerCont -- Periodic for incoming message processing
 
988
//-----------------------------------------------------------------
 
989
class ICPHandlerCont:public PeriodicCont
 
990
{
 
991
public:
 
992
  enum
 
993
  {
 
994
    ICP_HANDLER_INTERVAL = 10
 
995
  };
 
996
    ICPHandlerCont(ICPProcessor *);
 
997
   ~ICPHandlerCont()
 
998
  {
 
999
  }
 
1000
  virtual int PeriodicEvent(int, Event *);
 
1001
  virtual int TossEvent(int, Event *);
 
1002
 
 
1003
#ifdef DEBUG_ICP
 
1004
  // state history
 
1005
#define MAX_ICP_HISTORY 20
 
1006
  struct statehistory
 
1007
  {
 
1008
    int event;
 
1009
    int newstate;
 
1010
    char *file;
 
1011
    int line;
 
1012
  };
 
1013
  statehistory _history[MAX_ICP_HISTORY];
 
1014
  int _nhistory;
 
1015
 
 
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;
 
1022
 
 
1023
#else
 
1024
#define RECORD_ICP_STATE_CHANGE(x,y,z)
 
1025
#endif
 
1026
 
 
1027
  static int64_t ICPDataBuf_IOBuffer_sizeindex;
 
1028
};
 
1029
 
 
1030
//------------------------------------------------------------------
 
1031
// ICPPeerReadCont -- ICP incoming message processing state machine
 
1032
//------------------------------------------------------------------
 
1033
class ICPPeerReadCont:public Continuation
 
1034
{
 
1035
public:
 
1036
  typedef enum
 
1037
  {
 
1038
    READ_ACTIVE,
 
1039
    READ_DATA,
 
1040
    READ_DATA_DONE,
 
1041
    PROCESS_READ_DATA,
 
1042
    ADD_PEER,
 
1043
    AWAITING_CACHE_LOOKUP_RESPONSE,
 
1044
    SEND_REPLY,
 
1045
    WRITE_DONE,
 
1046
    GET_ICP_REQUEST,
 
1047
    GET_ICP_REQUEST_MUTEX,
 
1048
    READ_NOT_ACTIVE,
 
1049
    READ_NOT_ACTIVE_EXIT,
 
1050
    READ_PROCESSING_COMPLETE
 
1051
  } PeerReadState_t;
 
1052
 
 
1053
  class PeerReadData
 
1054
  {
 
1055
  public:
 
1056
    PeerReadData();
 
1057
    void init();
 
1058
     ~PeerReadData();
 
1059
    void reset(int full_reset = 0);
 
1060
 
 
1061
    ink_hrtime _start_time;
 
1062
    ICPPeerReadCont *_mycont;
 
1063
      Ptr<Peer> _peer;
 
1064
    PeerReadState_t _next_state;
 
1065
    int _cache_lookup_local;
 
1066
      Ptr<IOBufferBlock> _buf;       // the buffer with the ICP message in it
 
1067
    ICPMsg_t *_rICPmsg;
 
1068
    int _rICPmsg_len;
 
1069
    struct sockaddr_in _sender; // sender of rICPmsg
 
1070
    URL _cachelookupURL;
 
1071
    int _queryResult;
 
1072
    ICPRequestCont *_ICPReqCont;
 
1073
    int _bytesReceived;
 
1074
    // response data
 
1075
    struct msghdr _mhdr;
 
1076
    struct iovec _iov[MSG_IOVECS];
 
1077
  };
 
1078
 
 
1079
    ICPPeerReadCont();
 
1080
  void init(ICPProcessor *, Peer *, int);
 
1081
   ~ICPPeerReadCont();
 
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 *);
 
1088
 
 
1089
  enum
 
1090
  { RETRY_INTERVAL = 10 };
 
1091
 
 
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;
 
1097
 
 
1098
private:
 
1099
  // Class data
 
1100
    ICPProcessor * _ICPpr;
 
1101
  PeerReadData *_state;
 
1102
  ink_hrtime _start_time;
 
1103
  int _recursion_depth;
 
1104
};
 
1105
 
 
1106
//----------------------------------------------------------------------
 
1107
// ICPRequestCont -- ICP Request continuation  (Outgoing ICP requests)
 
1108
//----------------------------------------------------------------------
 
1109
class ICPRequestCont:public Continuation
 
1110
{
 
1111
  friend class ICPProcessor;
 
1112
 
 
1113
public:
 
1114
    ICPRequestCont(ICPProcessor * i = 0, Continuation * c = 0, URL * u = 0);
 
1115
   ~ICPRequestCont();
 
1116
  void *operator  new(size_t size, void *mem);
 
1117
  void operator  delete(void *mem);
 
1118
  inline void SetRequestStartTime()
 
1119
  {
 
1120
    _start_time = ink_get_hrtime();
 
1121
  }
 
1122
  inline ink_hrtime GetRequestStartTime()
 
1123
  {
 
1124
    return _start_time;
 
1125
  }
 
1126
  inline class Action *GetActionPtr()
 
1127
  {
 
1128
    return &_act;
 
1129
  }
 
1130
 
 
1131
  enum
 
1132
  { RETRY_INTERVAL = 10 };
 
1133
  enum
 
1134
  { ICP_REQUEST_HASH_SIZE = 1024 };
 
1135
 
 
1136
  //***********************************************************************
 
1137
  // ICPPeerReadCont::PeerReadStateMachine() to
 
1138
  // ICPRequestCont::ICPStateMachine() calling sequence definition.
 
1139
  //
 
1140
  //     ICPRequestEvent(ICP_RESPONSE_MESSAGE, ICPRequestEventArgs_t *)
 
1141
  //
 
1142
  //***********************************************************************
 
1143
  typedef struct ICPRequestEventArgs
 
1144
  {
 
1145
    ICPMsg_t *rICPmsg;
 
1146
    int rICPmsg_len;
 
1147
    Peer *peer;
 
1148
  } ICPRequestEventArgs_t;
 
1149
  //***********************************************************************
 
1150
  int ICPRequestEvent(int, Event *);
 
1151
  int NopICPRequestEvent(int, Event *);
 
1152
 
 
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);
 
1158
 
 
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);
 
1164
 
 
1165
private:
 
1166
  typedef enum
 
1167
  {
 
1168
    ICP_START,
 
1169
    ICP_OFF_TERMINATE,
 
1170
    ICP_QUEUE_REQUEST,
 
1171
    ICP_AWAITING_RESPONSE,
 
1172
    ICP_DEQUEUE_REQUEST,
 
1173
    ICP_POST_COMPLETION,
 
1174
    ICP_WAIT_SEND_COMPLETE,
 
1175
    ICP_REQUEST_NOT_ACTIVE,
 
1176
    ICP_DONE
 
1177
  } ICPstate_t;
 
1178
  int ICPStateMachine(int, void *);
 
1179
  int ICPResponseMessage(int, ICPMsg_t *, int, Peer *);
 
1180
  void remove_from_pendingActions(Action *);
 
1181
  void remove_all_pendingActions();
 
1182
 
 
1183
  // Static data
 
1184
  static uint32_t ICPRequestSeqno;
 
1185
 
 
1186
  // Passed request data
 
1187
  Continuation *_cont;
 
1188
  URL *_url;
 
1189
 
 
1190
  // Return data
 
1191
  struct sockaddr_in _ret_sockaddr;
 
1192
  ICPreturn_t _ret_status;
 
1193
  class Action _act;
 
1194
 
 
1195
  // Internal working data
 
1196
  ink_hrtime _start_time;
 
1197
  ICPProcessor *_ICPpr;
 
1198
  Event *_timeout;
 
1199
 
 
1200
  // outstanding actions
 
1201
  int npending_actions;
 
1202
  DynArray<Action *>*pendingActions;
 
1203
 
 
1204
  ICPMsg_t _ICPmsg;
 
1205
  struct msghdr _sendMsgHdr;
 
1206
  struct iovec _sendMsgIOV[MSG_IOVECS];
 
1207
 
 
1208
  unsigned int _sequence_number;
 
1209
  int _expected_replies;
 
1210
  BitMap _expected_replies_list;
 
1211
  int _received_replies;
 
1212
  ICPstate_t _next_state;
 
1213
};
 
1214
 
 
1215
 
 
1216
extern ClassAllocator<ICPRequestCont> ICPRequestCont_allocator;
 
1217
 
 
1218
typedef int (*PluginFreshnessCalcFunc) (void *contp);
 
1219
extern PluginFreshnessCalcFunc pluginFreshnessCalcFunc;
 
1220
 
 
1221
inline void *
 
1222
ICPRequestCont::operator
 
1223
new(size_t size, void *mem)
 
1224
{
 
1225
  NOWARN_UNUSED(size);
 
1226
  return mem;
 
1227
}
 
1228
 
 
1229
inline void
 
1230
ICPRequestCont::operator
 
1231
delete(void *mem)
 
1232
{
 
1233
  ICPRequestCont_allocator.free((ICPRequestCont *) mem);
 
1234
}
 
1235
 
 
1236
extern struct RecRawStatBlock *icp_rsb;
 
1237
 
 
1238
enum
 
1239
{
 
1240
  icp_stat_def,
 
1241
  config_mgmt_callouts_stat,
 
1242
  reconfig_polls_stat,
 
1243
  reconfig_events_stat,
 
1244
  invalid_poll_data_stat,
 
1245
  no_data_read_stat,
 
1246
  short_read_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,
 
1267
  icp_total_reloads,
 
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,
 
1274
  icp_stat_count
 
1275
};
 
1276
 
 
1277
#define ICP_EstablishStaticConfigInteger(_ix,_n) \
 
1278
        REC_EstablishStaticConfigInt32(_ix,_n)
 
1279
 
 
1280
#define ICP_EstablishStaticConfigStringAlloc(_ix, n) \
 
1281
        REC_EstablishStaticConfigStringAlloc(_ix, n)
 
1282
 
 
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);
 
1292
 
 
1293
#define ICP_ReadConfigString          REC_ReadConfigString
 
1294
#define ICP_RegisterConfigUpdateFunc  REC_RegisterConfigUpdateFunc
 
1295
 
 
1296
 
 
1297
// End of ICP.h
 
1298
 
 
1299
#endif // _ICP_H_