blob: 9c384d90fb547d334d0581e294918ebcdd96eeb2 [file] [log] [blame]
William Lallemand24a7a752017-10-09 14:17:39 +02001#ifndef __TYPES_SHCTX
2#define __TYPES_SHCTX
3
4#include <openssl/ssl.h> /* shared session depend of openssl */
5
6#ifndef SHSESS_BLOCK_MIN_SIZE
7#define SHSESS_BLOCK_MIN_SIZE 128
8#endif
9
10#ifndef SHSESS_MAX_DATA_LEN
11#define SHSESS_MAX_DATA_LEN 4096
12#endif
13
14#ifndef SHCTX_APPNAME
15#define SHCTX_APPNAME "haproxy"
16#endif
17
18#define SHCTX_E_ALLOC_CACHE -1
19#define SHCTX_E_INIT_LOCK -2
20
21struct shared_session {
22 struct ebmb_node key;
23 unsigned char key_data[SSL_MAX_SSL_SESSION_ID_LENGTH];
24 unsigned char data[SHSESS_BLOCK_MIN_SIZE];
25};
26
27struct shared_block {
28 union {
29 struct shared_session session;
30 unsigned char data[sizeof(struct shared_session)];
31 } data;
32 short int data_len;
33 struct shared_block *p;
34 struct shared_block *n;
35};
36
37struct shared_context {
38#ifndef USE_PRIVATE_CACHE
39#ifdef USE_PTHREAD_PSHARED
40 pthread_mutex_t mutex;
41#else
42 unsigned int waiters;
43#endif
44#endif
45 struct shared_block active;
46 struct shared_block free;
47};
48
49extern struct shared_context *shctx;
50
51#endif