[0001] [0002] [0003] [0004] [0005] [0006] [0007] [0008] [0009] [0010] [0011] [0012] [0013] [0014] [0015] [0016] [0017] [0018] [0019] [0020] [0021] [0022] [0023] [0024] [0025] [0026] [0027] [0028] [0029] [0030] [0031] [0032] [0033] [0034] [0035] [0036] [0037] [0038] [0039] [0040] [0041] [0042] [0043] [0044] [0045] [0046] [0047] [0048] [0049] [0050] [0051] [0052] [0053] [0054] [0055] [0056] [0057] [0058] [0059] [0060] [0061] [0062] [0063] [0064] [0065] [0066] [0067] [0068] [0069] [0070] [0071] [0072] [0073] [0074] [0075] [0076] [0077] [0078] [0079] [0080] [0081] [0082] [0083] [0084] [0085] [0086] [0087] [0088] [0089] [0090] [0091] [0092] [0093] [0094] [0095] [0096] [0097] [0098] [0099] [0100] [0101] [0102] [0103] [0104] [0105] [0106] [0107] [0108] [0109] [0110] [0111] [0112] [0113] [0114] [0115] [0116] [0117] [0118] [0119] [0120] [0121] [0122] [0123] [0124] [0125] [0126] [0127] [0128] [0129] [0130] [0131] [0132] [0133] [0134] [0135] [0136] [0137] [0138] [0139] [0140] [0141] [0142] [0143] [0144] [0145] [0146] [0147] [0148] [0149] [0150] [0151] [0152] [0153] [0154] [0155] [0156] [0157] [0158] [0159] [0160] [0161] [0162] [0163] [0164] [0165] [0166] [0167] [0168] [0169] [0170] [0171] [0172] [0173] [0174] [0175] [0176] [0177] [0178] [0179] [0180] [0181] [0182] [0183] [0184] [0185] [0186] [0187] [0188] [0189] [0190] [0191] [0192] [0193] [0194] [0195] [0196] [0197] [0198] [0199] [0200] [0201] [0202] [0203] [0204] [0205] [0206] [0207] [0208] [0209] [0210] [0211] [0212] [0213] [0214] [0215] [0216] [0217] [0218] [0219] [0220] [0221] [0222] [0223]
/*****************************************************************************/ /* Instance.h */ /*****************************************************************************/ #ifndef INSTANCE_H_LOADED #define INSTANCE_H_LOADED 1 #include "wasd.h" /* these must be sequential from 1 to whatever (used as array indices) */ #define INSTANCE_CLUSTER 0x01 /* join cluster instance */ #define INSTANCE_CLUSTER_DO 0x02 /* distributes cluster directive */ #define INSTANCE_CLUSTER_NOTIFY 0x03 /* locks notifications */ #define INSTANCE_CLUSTER_PROXYMAINT 0x04 /* locks proxy cache maintainance */ #define INSTANCE_CLUSTER_STATUS 0x05 /* distributes instance status */ #define INSTANCE_CLUSTER_LOCK_COUNT 5 /* DON'T FORGET TO ADJUST! */ #define INSTANCE_NODE 0x06 /* join node instance */ #define INSTANCE_NODE_DO 0x07 /* distributes node directive */ #define INSTANCE_NODE_WATCH 0x08 /* WATCH is in use */ #define INSTANCE_NODE_SINGLE 0x09 /* starting config of one instance */ #define INSTANCE_NODE_JOINING 0x0a /* instance is joining the node */ #define INSTANCE_NODE_READY 0x0b /* instance is ready for requests */ #define INSTANCE_NODE_SUPERVISOR 0x0c /* delegates per-node supervisor */ #define INSTANCE_NODE_SOCKET 0x0d /* lock socket allocation */ #define INSTANCE_NODE_LOCK_COUNT 8 /* DITTO! */ /* AND ADJUST CODES BELOW!! */ #define INSTANCE_LOCK_CODES 0x00, \ 0x01,0x02,0x03,0x04, \ 0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d #define INSTANCE_LOCK_USES "", \ "cluster", "do", "notify", "proxy-maint", "status", \ "node", "do", "watch", "single", "join", "ready", "super", "socket" #define INSTANCE_LOCK_COUNT INSTANCE_CLUSTER_LOCK_COUNT + \ INSTANCE_NODE_LOCK_COUNT /* must remain below INSTANCE_LOCK_PRINTABLE */ #define INSTANCE_NODE_SOCKIP4 0x14 /* distributes IPv4 socket BG: */ #define INSTANCE_NODE_SOCKIP6 0x16 /* distributes IPv6 socket BG: */ #define INSTANCE_LOCK_PRINTABLE 0x20 /* (space) */ #define INSTANCE_MUTEX_HTTPD 1 /* main global section */ #define INSTANCE_MUTEX_ACTIVITY 2 /* actvitity stats global section */ #define INSTANCE_MUTEX_AUTH_CACHE 3 /* authorization cache */ #define INSTANCE_MUTEX_AUTH_TOKEN 4 /* auth token cache */ #define INSTANCE_MUTEX_PROXY_VERIFY 5 /* proxy verify records */ #define INSTANCE_MUTEX_SSL_CACHE 6 /* SSL session cache */ #define INSTANCE_MUTEX_COUNT 6 /* DON'T FORGET TO ADJUST! */ #define INSTANCE_MUTEX_DESCR \ { NULL, "MUTEX_HTTPD", "MUTEX_ACTIVITY", \ "MUTEX_AUTH_CACHE", "MUTEX_AUTH_TOKEN", \ "MUTEX_PROXY_VERIFY", "MUTEX_SSL_CACHE" } /* ditto!! */ /* maximum number of (WASD) processes per node */ #define INSTANCE_MAX 8 /* maximum number of (WASD) nodes per cluster */ #define INSTANCE_CLUSTER_MAX 8 /* maximum number of sockets that can be shared between per-node instances */ #define INSTANCE_LOCK_SOCKET_MAX 64 /* maximum number of locks that can be $GETLKI()ed at the one time */ #define INSTANCE_REPORT_LOCK_MAX 256 /* minimum seconds between node supervisor polls */ #define INSTANCE_SUPERVISOR_POLL 15 /* maximum seconds before we commence a rolling restart */ #define INSTANCE_RESTART_SECONDS 3600 /* number of seconds we'll wait before considering it a lost cause */ #define INSTANCE_MUTEX_WAIT 300 /* a sentinal to indicate as many instances as CPUs should be created */ #define INSTANCE_PER_CPU -999 /* default environment number is one */ #define INSTANCE_ENV_NUMBER_DEFAULT 1 /* maximum /INSTANCE=<integer> allowed (4 bits) */ #define INSTANCE_ENV_NUMBER_MAX 15 /* number of seconds to wait to deliver joining message */ #define INSTANCE_JOINING_WAIT_SECS 30 /* number of seconds to wait to deliver new SSL ticket */ #define INSTANCE_TICKET_WAIT_SECS 10 /* retry ten times (over ten minutes) to deliver ticket */ #define INSTANCE_REFRESH_TICKET_RETRY 10 /* maximum number of status entries per cluster */ #define INSTANCE_STATUS_TABLE_MAX (INSTANCE_MAX * INSTANCE_CLUSTER_MAX) /* e.g. "KLAATU::WASD1:65000\0" */ #define INSTANCE_STATUS_NAME_SIZE (8+12) /* e.g. "11.2.0a\0" */ #define INSTANCE_STATUS_VERSION_SIZE 8 /* number of seconds to wait for instance status lock */ #define INSTANCE_STATUS_UPDATE_WAIT_SECS 1 /* retry an update every second for thirty seconds */ #define INSTANCE_STATUS_UPDATE_RETRIES 20 /* minutes before an entry is considered stale */ #define INSTANCE_STATUS_STALE_MINS 3 /*******************/ /* data structures */ /*******************/ #pragma member_alignment __save #pragma member_alignment typedef struct InstanceLockStruct INSTANCE_LOCK; struct InstanceLockStruct { BOOL InUse; int NameLength; char Name [32]; struct dsc$descriptor_s NameDsc; struct lksb Lksb; CALL_BACK AstFunction; }; typedef struct InstanceSocketLockStruct INSTANCE_SOCKET_LOCK; struct InstanceSocketLockStruct { char Name [32]; struct lksb Lksb; }; typedef struct InstanceStatusStruct INSTANCE_STATUS; /* squeeze all of this into a 64 byte lock value block */ struct InstanceStatusStruct { char InstanceName [INSTANCE_STATUS_NAME_SIZE], HttpdVersion [INSTANCE_STATUS_VERSION_SIZE]; ushort MinuteCount, /* number of requests in the past minute */ StartupCount; /* something seriously amiss if > 65535 */ ulong ExitStatus, HourCount; /* number of requests in the past hour */ int64 ExitTime64, StartTime64, UpdateTime64; }; typedef struct InstanceNodeStruct INSTANCE_NODE_DATA; /* used to store per-instance data for a single node */ struct InstanceNodeStruct { BOOL SupervisorUpdate; char InstanceName [INSTANCE_STATUS_NAME_SIZE]; ulong ExitStatus, StartupCount; int64 ExitTime64, StartTime64; /* 60 minutes of per-minute request count */ ushort RequestCount [60]; }; #pragma member_alignment __restore /***********************/ /* function prototypes */ /***********************/ void InstanceExit (); InstanceGblSecDecrLong (long*); InstanceGblSecIncrLong (long*); InstanceGblSecSetLong (long*, long); InstanceFinalInit (); InstanceLock (int); int InstanceLockControl (); int InstanceLockInit (); int InstanceLockList (int, char*, char**); int InstanceLockNoWait (int); InstanceLockReport (REQUEST_STRUCT*); InstanceLockReportData (REQUEST_STRUCT*, unsigned long*); InstanceMutexLock (); InstanceMutexUnLock (); InstanceNodeSupervisorAst (int); InstanceNodeJoiningAst (); int InstanceNotifyNow (int, void*); int InstanceNotifySet (int, CALL_BACK); int InstanceNotifySetAst (int); int InstanceNotifyWait (int, void*, int); char* InstanceParseLockName (char*); InstanceProcessName (); InstanceServerInit (); int InstanceSessionTicketKey (uchar*); int InstanceSocketAdmin (short); int InstanceSocketForAdmin (char*, short*); char* InstanceSocket (IPADDRESS*, short, char*); void InstanceStatusAdminReport (REQUEST_STRUCT*); void InstanceStatusCliReport (REQUEST_STRUCT*); void InstanceStatusExit (int); INSTANCE_STATUS* InstanceStatusFind (char*); void InstanceStatusNow (); void InstanceStatusPurge (); void InstanceStatusReset (); void InstanceStatusUpdate (struct lksb*); BOOL InstanceSupervisor (); int InstanceUnLock (int); InstanceLockUnlockControl (); int InstanceUseConfig (); #endif /* INSTANCE_H_LOADED */ /*****************************************************************************/