| 1 | /********************************************************************** |
|---|
| 2 | * Copyright (c) 2005-2008 David Carter <dcarter@arm4.org> and others. |
|---|
| 3 | * All rights reserved. This program and the accompanying materials |
|---|
| 4 | * are made available under the terms of the Eclipse Public License v1.0 |
|---|
| 5 | * which accompanies this distribution, and is available at |
|---|
| 6 | * http://www.eclipse.org/legal/epl-v10.html |
|---|
| 7 | * |
|---|
| 8 | * Contributors: |
|---|
| 9 | * David Carter - Initial API and implementation |
|---|
| 10 | **********************************************************************/ |
|---|
| 11 | |
|---|
| 12 | #ifndef ARM4_SHM_H |
|---|
| 13 | #define ARM4_SHM_H 1 |
|---|
| 14 | |
|---|
| 15 | #include "config.h" |
|---|
| 16 | |
|---|
| 17 | #ifdef HAVE_PTHREAD_SETPSHARED |
|---|
| 18 | #define USE_POSIX_PROCESS_SEM 1 |
|---|
| 19 | #else |
|---|
| 20 | #undef USE_POSIX_PROCESS_SEM |
|---|
| 21 | #endif |
|---|
| 22 | |
|---|
| 23 | #include <pthread.h> |
|---|
| 24 | #ifndef USE_POSIX_PROCESS_SEM |
|---|
| 25 | #include <semaphore.h> |
|---|
| 26 | #endif /* USE_POSIX_PROCESS_SEM */ |
|---|
| 27 | |
|---|
| 28 | #include <sys/time.h> |
|---|
| 29 | #include <sys/stat.h> |
|---|
| 30 | #include <sys/msg.h> |
|---|
| 31 | #include <sys/types.h> |
|---|
| 32 | |
|---|
| 33 | #include <openssl/md5.h> |
|---|
| 34 | |
|---|
| 35 | #include "arm4.h" |
|---|
| 36 | #include "appdex.h" |
|---|
| 37 | |
|---|
| 38 | /* IPC file definitions */ |
|---|
| 39 | #define SHARED_MEMORY_FILE "arm4.shm" |
|---|
| 40 | #define MQUEUE_FILE "arm4.mq" |
|---|
| 41 | |
|---|
| 42 | /* Forward slash required for Solaris */ |
|---|
| 43 | #define SEM_SEQUENCE_FILE "/arm4_sequence.sem" |
|---|
| 44 | #define SEM_APPLICATION_FILE "/arm4_application.sem" |
|---|
| 45 | #define SEM_TRANSACTION_FILE "/arm4_transaction.sem" |
|---|
| 46 | #define SEM_METRIC_FILE "/arm4_metric.sem" |
|---|
| 47 | #define SEM_UTILITY_FILE "/arm4_utility.sem" |
|---|
| 48 | |
|---|
| 49 | #define SEM_INSTANCE_FILE "arm4_instance.sem" |
|---|
| 50 | |
|---|
| 51 | #define SEM_INSTANCE_APPLICATION 0 |
|---|
| 52 | #define SEM_INSTANCE_TRANSACTION 1 |
|---|
| 53 | #define SEM_INSTANCE_METRIC 2 |
|---|
| 54 | #define SEM_INSTANCE_COUNT 3 |
|---|
| 55 | |
|---|
| 56 | #define ARM4_SHM_MAGIC 0x87654321 |
|---|
| 57 | |
|---|
| 58 | #define ARM4_SHM_SEQUENCE_STEP 100 /* This is the number of sequences the daemon can assume */ |
|---|
| 59 | /* before incrementing the number in the database */ |
|---|
| 60 | |
|---|
| 61 | /* For now, table sizes are hard coded */ |
|---|
| 62 | #define ARM4_SHM_APPLICATION_ENTRIES 32 |
|---|
| 63 | #define ARM4_SHM_TRANSACTION_ENTRIES 64 |
|---|
| 64 | #define ARM4_SHM_METRIC_ENTRIES 64 |
|---|
| 65 | |
|---|
| 66 | #define ARM4_SHM_MESSAGE_APPLICATION 10 |
|---|
| 67 | #define ARM4_SHM_MESSAGE_APPLICATION_GROUP 11 |
|---|
| 68 | #define ARM4_SHM_MESSAGE_APPLICATION_INSTANCE_ID 12 |
|---|
| 69 | #define ARM4_SHM_MESSAGE_APPLICATION_CONTEXT 13 |
|---|
| 70 | #define ARM4_SHM_MESSAGE_APPLICATION_ADDRESS 14 |
|---|
| 71 | #define ARM4_SHM_MESSAGE_TRANSACTION 20 |
|---|
| 72 | #define ARM4_SHM_MESSAGE_TRANSACTION_CONTEXT 21 |
|---|
| 73 | #define ARM4_SHM_MESSAGE_TRANSACTION_URI 22 |
|---|
| 74 | #define ARM4_SHM_MESSAGE_TRANSACTION_METRIC_VALUE 23 |
|---|
| 75 | #define ARM4_SHM_MESSAGE_TRANSACTION_USER 24 |
|---|
| 76 | #define ARM4_SHM_MESSAGE_TRANSACTION_DIAG 25 |
|---|
| 77 | #define ARM4_SHM_MESSAGE_CORRELATOR 30 |
|---|
| 78 | #define ARM4_SHM_MESSAGE_SEQUENCE 31 |
|---|
| 79 | #define ARM4_SHM_MESSAGE_REGISTER_APPLICATION 40 |
|---|
| 80 | #define ARM4_SHM_MESSAGE_REGISTER_APPLICATION_IDENTITY 41 |
|---|
| 81 | #define ARM4_SHM_MESSAGE_REGISTER_APPLICATION_CONTEXT 42 |
|---|
| 82 | #define ARM4_SHM_MESSAGE_REGISTER_TRANSACTION 50 |
|---|
| 83 | #define ARM4_SHM_MESSAGE_REGISTER_TRANSACTION_IDENTITY 51 |
|---|
| 84 | #define ARM4_SHM_MESSAGE_REGISTER_TRANSACTION_CONTEXT 52 |
|---|
| 85 | #define ARM4_SHM_MESSAGE_REGISTER_TRANSACTION_URI 53 |
|---|
| 86 | #define ARM4_SHM_MESSAGE_REGISTER_TRANSACTION_METRIC 54 |
|---|
| 87 | #define ARM4_SHM_MESSAGE_REGISTER_METRIC 60 |
|---|
| 88 | |
|---|
| 89 | #define ARM4_SHM_MESSAGE_UTILITY 1000 |
|---|
| 90 | |
|---|
| 91 | #define ARM4_SHM_COMMAND_STOP 1 |
|---|
| 92 | #define ARM4_SHM_COMMAND_BACKUP 2 |
|---|
| 93 | #define ARM4_SHM_COMMAND_CHECKPOINT 3 |
|---|
| 94 | |
|---|
| 95 | #ifndef HOST_NAME_MAX |
|---|
| 96 | #define HOST_NAME_MAX 255 |
|---|
| 97 | #endif |
|---|
| 98 | |
|---|
| 99 | /* Wrap msgsnd to allow for errors in structure alignment */ |
|---|
| 100 | #define SAFE_SEND(q,message,size,flags) msgsnd(q, message, size - sizeof(long), flags) |
|---|
| 101 | |
|---|
| 102 | /* Wrappers to add stats to pthreads */ |
|---|
| 103 | #ifdef HAVE_PTHREAD_STATS |
|---|
| 104 | #define PTHREAD_STATS(lock_name) \ |
|---|
| 105 | int lock_name ## _pthread_stat_total; \ |
|---|
| 106 | int lock_name ## _pthread_stat_wait; \ |
|---|
| 107 | int lock_name ## _pthread_stat_active; \ |
|---|
| 108 | int lock_name ## _pthread_stat_max_active; |
|---|
| 109 | #else |
|---|
| 110 | #define PTHREAD_STATS(prefix) ; |
|---|
| 111 | #endif |
|---|
| 112 | |
|---|
| 113 | /* Set the library tracing level - each level is cumultative */ |
|---|
| 114 | typedef enum arm4_shm_tracing { |
|---|
| 115 | arm4_shm_trace_none = 0, |
|---|
| 116 | arm4_shm_trace_arm, |
|---|
| 117 | arm4_shm_trace_arm_internal, |
|---|
| 118 | arm4_shm_trace_arm_db, |
|---|
| 119 | arm4_shm_trace_arm_db_internal, |
|---|
| 120 | arm4_shm_trace_arm_shm, |
|---|
| 121 | arm4_shm_trace_arm_shm_internal |
|---|
| 122 | } arm4_shm_tracing_t; |
|---|
| 123 | |
|---|
| 124 | typedef struct timeval arm_time_t; |
|---|
| 125 | typedef arm_int64_t arm4_shm_handle_t; |
|---|
| 126 | |
|---|
| 127 | typedef enum { |
|---|
| 128 | arm4_shm_sequence_application = 0, |
|---|
| 129 | arm4_shm_sequence_transaction, |
|---|
| 130 | arm4_shm_sequence_application_instance, |
|---|
| 131 | arm4_shm_sequence_transaction_instance, |
|---|
| 132 | arm4_shm_sequence_transaction_blocking, |
|---|
| 133 | arm4_shm_sequence_max |
|---|
| 134 | } arm4_shm_sequence_t; |
|---|
| 135 | |
|---|
| 136 | typedef enum { |
|---|
| 137 | /* These values are bit masks */ |
|---|
| 138 | arm4_shm_transaction_trace_all = 1, |
|---|
| 139 | arm4_shm_transaction_trace_n = 2, |
|---|
| 140 | arm4_shm_transaction_trace_interval = 4, |
|---|
| 141 | arm4_shm_transaction_trace_use_default = 8, |
|---|
| 142 | arm4_shm_transaction_trace_honor_request = 16, |
|---|
| 143 | |
|---|
| 144 | /* Used internally */ |
|---|
| 145 | arm4_shm_transaction_trace_next = 32 |
|---|
| 146 | } arm4_shm_transaction_trace_t; |
|---|
| 147 | |
|---|
| 148 | typedef struct arm4_shm_application { |
|---|
| 149 | char md5_digest [MD5_DIGEST_LENGTH]; |
|---|
| 150 | arm_id_t appl_id; |
|---|
| 151 | arm_boolean_t is_new; |
|---|
| 152 | arm4_shm_transaction_trace_t default_trace_flags; |
|---|
| 153 | arm_int64_t default_trace_parameter; |
|---|
| 154 | arm_int64_t default_appdex_threshold; |
|---|
| 155 | } arm4_shm_application_t; |
|---|
| 156 | |
|---|
| 157 | typedef struct arm4_shm_transaction { |
|---|
| 158 | char md5_digest [MD5_DIGEST_LENGTH]; |
|---|
| 159 | arm_id_t tran_id; |
|---|
| 160 | arm_boolean_t is_new; |
|---|
| 161 | arm4_shm_transaction_trace_t trace_flags; |
|---|
| 162 | arm4_appdex_t appdex_flags; |
|---|
| 163 | arm_int64_t trace_parameter; |
|---|
| 164 | arm_int64_t trace_counter; |
|---|
| 165 | arm_int64_t transaction_counter; |
|---|
| 166 | arm_int64_t appdex_threshold; |
|---|
| 167 | arm_int64_t appdex_satisfactory; |
|---|
| 168 | arm_int64_t appdex_tolerable; |
|---|
| 169 | arm_int64_t appdex_frustrating; |
|---|
| 170 | } arm4_shm_transaction_t; |
|---|
| 171 | |
|---|
| 172 | typedef struct arm4_shm_metric { |
|---|
| 173 | char md5_digest [MD5_DIGEST_LENGTH]; |
|---|
| 174 | arm_id_t metric_id; |
|---|
| 175 | } arm4_shm_metric_t; |
|---|
| 176 | |
|---|
| 177 | #if 0 |
|---|
| 178 | typedef struct msghdr arm4_shm_message_header_t; |
|---|
| 179 | #else |
|---|
| 180 | typedef struct arm4_shm_message_header { |
|---|
| 181 | long mtype; |
|---|
| 182 | char message [1]; |
|---|
| 183 | } arm4_shm_message_header_t; |
|---|
| 184 | #endif |
|---|
| 185 | |
|---|
| 186 | typedef struct arm4_shm_property_message { |
|---|
| 187 | arm4_shm_handle_t handle; /* This is the index */ |
|---|
| 188 | arm_char_t property_name [ARM_PROPERTY_VALUE_MAX_LENGTH]; |
|---|
| 189 | } arm4_shm_property_message_t; |
|---|
| 190 | |
|---|
| 191 | typedef struct arm4_shm_property { |
|---|
| 192 | long mtype; |
|---|
| 193 | arm4_shm_property_message_t message; |
|---|
| 194 | } arm4_shm_property_t; |
|---|
| 195 | |
|---|
| 196 | typedef struct arm4_shm_context_property_message { |
|---|
| 197 | arm4_shm_handle_t handle; /* This is the index */ |
|---|
| 198 | int property_index; |
|---|
| 199 | arm_char_t property_name [ARM_PROPERTY_VALUE_MAX_LENGTH]; |
|---|
| 200 | } arm4_shm_context_property_message_t; |
|---|
| 201 | |
|---|
| 202 | typedef struct arm4_shm_context_property { |
|---|
| 203 | long mtype; |
|---|
| 204 | arm4_shm_context_property_message_t message; |
|---|
| 205 | } arm4_shm_context_property_t; |
|---|
| 206 | |
|---|
| 207 | typedef struct arm4_shm_uri_message { |
|---|
| 208 | arm4_shm_handle_t handle; /* This is the index */ |
|---|
| 209 | arm_char_t property_name [ARM_PROPERTY_URI_MAX_LENGTH]; |
|---|
| 210 | } arm4_shm_uri_message_t; |
|---|
| 211 | |
|---|
| 212 | typedef struct arm4_shm_uri { |
|---|
| 213 | long mtype; |
|---|
| 214 | arm4_shm_uri_message_t message; |
|---|
| 215 | } arm4_shm_uri_t; |
|---|
| 216 | |
|---|
| 217 | typedef struct arm4_shm_metric_value_message { |
|---|
| 218 | arm4_shm_handle_t handle; /* This is the index */ |
|---|
| 219 | arm_metric_t value; |
|---|
| 220 | arm_char_t string32 [ARM_METRIC_STRING32_MAX_LENGTH]; |
|---|
| 221 | } arm4_shm_metric_value_message_t; |
|---|
| 222 | |
|---|
| 223 | typedef struct arm4_shm_metric_value { |
|---|
| 224 | long mtype; |
|---|
| 225 | arm4_shm_metric_value_message_t message; |
|---|
| 226 | } arm4_shm_metric_value_t; |
|---|
| 227 | |
|---|
| 228 | typedef struct arm4_shm_user_message { |
|---|
| 229 | arm4_shm_handle_t handle; /* This is the index */ |
|---|
| 230 | char name [ARM_PROPERTY_NAME_MAX_LENGTH]; |
|---|
| 231 | arm_boolean_t id_valid; |
|---|
| 232 | arm_id_t id; |
|---|
| 233 | } arm4_shm_user_message_t; |
|---|
| 234 | |
|---|
| 235 | typedef struct arm4_shm_user { |
|---|
| 236 | long mtype; |
|---|
| 237 | arm4_shm_user_message_t message; |
|---|
| 238 | } arm4_shm_user_t; |
|---|
| 239 | |
|---|
| 240 | typedef struct arm4_shm_diag_message { |
|---|
| 241 | arm4_shm_handle_t handle; /* This is the index */ |
|---|
| 242 | arm_char_t detail [ARM_DIAG_DETAIL_MAX_LENGTH]; |
|---|
| 243 | } arm4_shm_diag_message_t; |
|---|
| 244 | |
|---|
| 245 | typedef struct arm4_shm_diag { |
|---|
| 246 | long mtype; |
|---|
| 247 | arm4_shm_diag_message_t message; |
|---|
| 248 | } arm4_shm_diag_t; |
|---|
| 249 | |
|---|
| 250 | typedef struct arm4_shm_application_instance_message { |
|---|
| 251 | arm_app_start_handle_t app_handle; /* This is the index */ |
|---|
| 252 | arm_id_t appl_id; |
|---|
| 253 | arm_boolean_t active; |
|---|
| 254 | } arm4_shm_application_instance_message_t; |
|---|
| 255 | |
|---|
| 256 | typedef struct arm4_shm_application_instance { |
|---|
| 257 | long mtype; |
|---|
| 258 | arm4_shm_application_instance_message_t message; |
|---|
| 259 | } arm4_shm_application_instance_t; |
|---|
| 260 | |
|---|
| 261 | typedef struct arm4_shm_address_message { |
|---|
| 262 | arm_app_start_handle_t app_handle; /* This is the index */ |
|---|
| 263 | arm_int16_t address_format; |
|---|
| 264 | arm_int16_t address_length; |
|---|
| 265 | arm_uint8_t address [ARM_PROPERTY_URI_MAX_LENGTH]; |
|---|
| 266 | arm_boolean_t id_valid; |
|---|
| 267 | arm_id_t id; |
|---|
| 268 | } arm4_shm_address_message_t; |
|---|
| 269 | |
|---|
| 270 | typedef struct arm4_shm_register_application_address { |
|---|
| 271 | long mtype; |
|---|
| 272 | arm4_shm_address_message_t message; |
|---|
| 273 | } arm4_shm_address_t; |
|---|
| 274 | |
|---|
| 275 | typedef struct arm4_shm_transaction_instance_message { |
|---|
| 276 | arm_tran_start_handle_t tran_handle; /* This is the index */ |
|---|
| 277 | arm_id_t appl_id; |
|---|
| 278 | arm_id_t tran_id; |
|---|
| 279 | arm_app_start_handle_t app_handle; |
|---|
| 280 | arm_time_t arrival_time; |
|---|
| 281 | arm_time_t stop_time; |
|---|
| 282 | arm_time_t response_time; |
|---|
| 283 | arm_time_t blocked_time; |
|---|
| 284 | arm_tran_status_t tran_status; |
|---|
| 285 | arm_boolean_t active; |
|---|
| 286 | } arm4_shm_transaction_instance_message_t; |
|---|
| 287 | |
|---|
| 288 | typedef struct arm4_shm_transaction_instance { |
|---|
| 289 | long mtype; |
|---|
| 290 | arm4_shm_transaction_instance_message_t message; |
|---|
| 291 | } arm4_shm_transaction_instance_t; |
|---|
| 292 | |
|---|
| 293 | typedef struct arm4_shm_correlator_message { |
|---|
| 294 | arm_tran_start_handle_t tran_handle; /* This is the index */ |
|---|
| 295 | arm_correlator_t parent_correlator; |
|---|
| 296 | arm_correlator_t current_correlator; |
|---|
| 297 | } arm4_shm_correlator_message_t; |
|---|
| 298 | |
|---|
| 299 | typedef struct arm4_shm_correlator { |
|---|
| 300 | long mtype; |
|---|
| 301 | arm4_shm_correlator_message_t message; |
|---|
| 302 | } arm4_shm_correlator_t; |
|---|
| 303 | |
|---|
| 304 | typedef struct arm4_shm_db_sequence_message { |
|---|
| 305 | arm4_shm_sequence_t index; |
|---|
| 306 | arm_int64_t sequence; |
|---|
| 307 | } arm4_shm_db_sequence_message_t; |
|---|
| 308 | |
|---|
| 309 | typedef struct arm4_shm_db_sequence { |
|---|
| 310 | long mtype; |
|---|
| 311 | arm4_shm_db_sequence_message_t message; |
|---|
| 312 | } arm4_shm_db_sequence_t; |
|---|
| 313 | |
|---|
| 314 | typedef struct arm4_shm_register_application_message { |
|---|
| 315 | int application_index; |
|---|
| 316 | unsigned char digest [MD5_DIGEST_LENGTH]; |
|---|
| 317 | arm_char_t app_name [ARM_NAME_MAX_LENGTH]; |
|---|
| 318 | arm_charset_t charset; |
|---|
| 319 | } arm4_shm_register_application_message_t; |
|---|
| 320 | |
|---|
| 321 | typedef struct arm4_shm_register_application { |
|---|
| 322 | long mtype; |
|---|
| 323 | arm4_shm_register_application_message_t message; |
|---|
| 324 | } arm4_shm_register_application_t; |
|---|
| 325 | |
|---|
| 326 | typedef struct arm4_shm_register_application_identity_message { |
|---|
| 327 | arm_id_t appid; |
|---|
| 328 | arm_char_t name [ARM_PROPERTY_NAME_MAX_LENGTH]; |
|---|
| 329 | arm_char_t value [ARM_PROPERTY_VALUE_MAX_LENGTH]; |
|---|
| 330 | } arm4_shm_register_application_identity_message_t; |
|---|
| 331 | |
|---|
| 332 | typedef struct arm4_shm_register_application_identity { |
|---|
| 333 | long mtype; |
|---|
| 334 | arm4_shm_register_application_identity_message_t message; |
|---|
| 335 | } arm4_shm_register_application_identity_t; |
|---|
| 336 | |
|---|
| 337 | typedef struct arm4_shm_register_application_context_message { |
|---|
| 338 | arm_id_t appid; |
|---|
| 339 | arm_int32_t index; |
|---|
| 340 | arm_char_t name [ARM_PROPERTY_NAME_MAX_LENGTH]; |
|---|
| 341 | } arm4_shm_register_application_context_message_t; |
|---|
| 342 | |
|---|
| 343 | typedef struct arm4_shm_register_application_context { |
|---|
| 344 | long mtype; |
|---|
| 345 | arm4_shm_register_application_context_message_t message; |
|---|
| 346 | } arm4_shm_register_application_context_t; |
|---|
| 347 | |
|---|
| 348 | typedef struct arm4_shm_register_transaction_message { |
|---|
| 349 | int transaction_index; |
|---|
| 350 | unsigned char digest [MD5_DIGEST_LENGTH]; |
|---|
| 351 | arm_char_t tran_name [ARM_NAME_MAX_LENGTH]; |
|---|
| 352 | arm_id_t app_id; |
|---|
| 353 | } arm4_shm_register_transaction_message_t; |
|---|
| 354 | |
|---|
| 355 | typedef struct arm4_shm_register_transaction { |
|---|
| 356 | long mtype; |
|---|
| 357 | arm4_shm_register_transaction_message_t message; |
|---|
| 358 | } arm4_shm_register_transaction_t; |
|---|
| 359 | |
|---|
| 360 | typedef struct arm4_shm_register_transaction_uri_message { |
|---|
| 361 | arm_id_t tran_id; |
|---|
| 362 | arm_char_t property_name [ARM_PROPERTY_URI_MAX_LENGTH]; |
|---|
| 363 | } arm4_shm_register_transaction_uri_message_t; |
|---|
| 364 | |
|---|
| 365 | typedef struct arm4_shm_register_transaction_uri { |
|---|
| 366 | long mtype; |
|---|
| 367 | arm4_shm_register_transaction_uri_message_t message; |
|---|
| 368 | } arm4_shm_register_transaction_uri_t; |
|---|
| 369 | |
|---|
| 370 | typedef struct arm4_shm_register_transaction_metric_message { |
|---|
| 371 | arm_id_t tran_id; |
|---|
| 372 | arm_metric_slot_t slot; |
|---|
| 373 | arm_id_t id; |
|---|
| 374 | } arm4_shm_register_transaction_metric_message_t; |
|---|
| 375 | |
|---|
| 376 | typedef struct arm4_shm_register_transaction_metric { |
|---|
| 377 | long mtype; |
|---|
| 378 | arm4_shm_register_transaction_metric_message_t message; |
|---|
| 379 | } arm4_shm_register_transaction_metric_t; |
|---|
| 380 | |
|---|
| 381 | typedef struct arm4_shm_register_metric_message { |
|---|
| 382 | int metric_index; |
|---|
| 383 | unsigned char digest [MD5_DIGEST_LENGTH]; |
|---|
| 384 | arm_char_t metric_name [ARM_NAME_MAX_LENGTH]; |
|---|
| 385 | arm_char_t metric_unit [ARM_NAME_MAX_LENGTH]; |
|---|
| 386 | arm_id_t app_id; |
|---|
| 387 | arm_metric_format_t metric_format; |
|---|
| 388 | arm_metric_usage_t metric_usage; |
|---|
| 389 | } arm4_shm_register_metric_message_t; |
|---|
| 390 | |
|---|
| 391 | typedef struct arm4_shm_register_metric { |
|---|
| 392 | long mtype; |
|---|
| 393 | arm4_shm_register_metric_message_t message; |
|---|
| 394 | } arm4_shm_register_metric_t; |
|---|
| 395 | |
|---|
| 396 | typedef struct arm4_shm_utility_message { |
|---|
| 397 | long command; |
|---|
| 398 | } arm4_shm_utility_message_t; |
|---|
| 399 | |
|---|
| 400 | typedef struct arm4_shm_utility { |
|---|
| 401 | long mtype; |
|---|
| 402 | arm4_shm_utility_message_t message; |
|---|
| 403 | } arm4_shm_utility_t; |
|---|
| 404 | |
|---|
| 405 | typedef struct arm4_shm_header { |
|---|
| 406 | arm_uint64_t magic; |
|---|
| 407 | |
|---|
| 408 | /* Sequence numbers */ |
|---|
| 409 | arm_int64_t sequence_table [arm4_shm_sequence_max]; |
|---|
| 410 | #ifdef USE_POSIX_PROCESS_SEM |
|---|
| 411 | pthread_mutex_t sequence_mutex; |
|---|
| 412 | PTHREAD_STATS(sequence_mutex) |
|---|
| 413 | #endif /* USE_POSIX_PROCESS_SEM */ |
|---|
| 414 | |
|---|
| 415 | /* cached application entries */ |
|---|
| 416 | int max_applications; /* Number of entries in the table */ |
|---|
| 417 | int application_count; /* Number of entries in the table */ |
|---|
| 418 | int next_application; /* Next entry to check */ |
|---|
| 419 | #ifdef USE_POSIX_PROCESS_SEM |
|---|
| 420 | pthread_mutex_t application_mutex; |
|---|
| 421 | PTHREAD_STATS(application_mutex) |
|---|
| 422 | #endif /* USE_POSIX_PROCESS_SEM */ |
|---|
| 423 | int application_semaphore; /* Used when waiting for the application ID to be filled in */ |
|---|
| 424 | arm4_shm_application_t application_table [ARM4_SHM_APPLICATION_ENTRIES]; |
|---|
| 425 | |
|---|
| 426 | /* cached application aliases */ |
|---|
| 427 | |
|---|
| 428 | /* cached transaction entries */ |
|---|
| 429 | int max_transactions; /* Number of entries in the table */ |
|---|
| 430 | int transaction_count; /* Number of entries in the table */ |
|---|
| 431 | int next_transaction; /* Next entry to check */ |
|---|
| 432 | #ifdef USE_POSIX_PROCESS_SEM |
|---|
| 433 | pthread_mutex_t transaction_mutex; |
|---|
| 434 | PTHREAD_STATS(transaction_mutex) |
|---|
| 435 | #endif /* USE_POSIX_PROCESS_SEM */ |
|---|
| 436 | arm4_shm_transaction_t transaction_table [ARM4_SHM_TRANSACTION_ENTRIES]; |
|---|
| 437 | |
|---|
| 438 | /* cached transaction entries */ |
|---|
| 439 | int max_metrics; /* Number of entries in the table */ |
|---|
| 440 | int metric_count; /* Number of entries in the table */ |
|---|
| 441 | int next_metric; /* Next entry to check */ |
|---|
| 442 | #ifdef USE_POSIX_PROCESS_SEM |
|---|
| 443 | pthread_mutex_t metric_mutex; |
|---|
| 444 | PTHREAD_STATS(metric_mutex) |
|---|
| 445 | #endif /* USE_POSIX_PROCESS_SEM */ |
|---|
| 446 | arm4_shm_metric_t metric_table [ARM4_SHM_METRIC_ENTRIES]; |
|---|
| 447 | |
|---|
| 448 | /* Global configuration entries */ |
|---|
| 449 | char hostname [HOST_NAME_MAX]; |
|---|
| 450 | arm4_shm_tracing_t trace_level; |
|---|
| 451 | arm_boolean_t null_arm; /* True when no recording is being done */ |
|---|
| 452 | pid_t daemon_instance; /* The process ID of the daemon owning this ARM instance */ |
|---|
| 453 | |
|---|
| 454 | #ifdef USE_POSIX_PROCESS_SEM |
|---|
| 455 | pthread_mutex_t utility_read_mutex; /* Used to signal that an external process is accessing the database */ |
|---|
| 456 | PTHREAD_STATS(utility_read_mutex) |
|---|
| 457 | #endif /* USE_POSIX_PROCESS_SEM */ |
|---|
| 458 | } arm4_shm_header_t; |
|---|
| 459 | |
|---|
| 460 | #endif /* ARM4_SHM_H */ |
|---|