blob: 559bebadb58e52fdf4d9dd63ec049a15fd81bb40 [file] [log] [blame]
William Lallemand24a7a752017-10-09 14:17:39 +02001#ifndef __TYPES_SHCTX
2#define __TYPES_SHCTX
3
William Lallemand24a7a752017-10-09 14:17:39 +02004#ifndef SHSESS_BLOCK_MIN_SIZE
5#define SHSESS_BLOCK_MIN_SIZE 128
6#endif
7
8#ifndef SHSESS_MAX_DATA_LEN
9#define SHSESS_MAX_DATA_LEN 4096
10#endif
11
12#ifndef SHCTX_APPNAME
13#define SHCTX_APPNAME "haproxy"
14#endif
15
16#define SHCTX_E_ALLOC_CACHE -1
17#define SHCTX_E_INIT_LOCK -2
18
William Lallemand4f45bb92017-10-30 20:08:51 +010019#define SHCTX_F_REMOVING 0x1 /* Removing flag, does not accept new */
William Lallemand24a7a752017-10-09 14:17:39 +020020
William Lallemand4f45bb92017-10-30 20:08:51 +010021/* generic shctx struct */
William Lallemand24a7a752017-10-09 14:17:39 +020022struct shared_block {
William Lallemand4f45bb92017-10-30 20:08:51 +010023 struct list list;
William Lallemand111bfef2017-11-21 20:01:25 +010024 unsigned int len; /* data length for the row */
25 unsigned int block_count; /* number of blocks */
William Lallemand4f45bb92017-10-30 20:08:51 +010026 unsigned int refcount;
27 unsigned char data[0];
William Lallemand24a7a752017-10-09 14:17:39 +020028};
29
30struct shared_context {
31#ifndef USE_PRIVATE_CACHE
32#ifdef USE_PTHREAD_PSHARED
33 pthread_mutex_t mutex;
34#else
35 unsigned int waiters;
36#endif
37#endif
William Lallemand4f45bb92017-10-30 20:08:51 +010038 struct list avail; /* list for active and free blocks */
39 struct list hot; /* list for locked blocks */
40 unsigned int nbav; /* number of available blocks */
41 void (*free_block)(struct shared_block *first, struct shared_block *block);
42 short int block_size;
43 unsigned char data[0];
William Lallemand24a7a752017-10-09 14:17:39 +020044};
45
William Lallemand24a7a752017-10-09 14:17:39 +020046#endif