summaryrefslogtreecommitdiffstats
path: root/include/haproxy/shctx-t.h
blob: 493024af81cdf0509f0c37be728bb146606cf8a3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/*
 * include/haproxy/shctx-t.h - shared context management functions for SSL
 *
 * Copyright (C) 2011-2012 EXCELIANCE
 *
 * Author: Emeric Brun - emeric@exceliance.fr
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version
 * 2 of the License, or (at your option) any later version.
 */

#ifndef __HAPROXY_SHCTX_T_H
#define __HAPROXY_SHCTX_T_H

#include <haproxy/api-t.h>
#include <haproxy/thread-t.h>

#ifndef SHSESS_BLOCK_MIN_SIZE
#define SHSESS_BLOCK_MIN_SIZE 128
#endif

#ifndef SHSESS_MAX_DATA_LEN
#define SHSESS_MAX_DATA_LEN 4096
#endif

#ifndef SHCTX_APPNAME
#define SHCTX_APPNAME "haproxy"
#endif

#define SHCTX_E_ALLOC_CACHE -1
#define SHCTX_E_INIT_LOCK   -2

#define SHCTX_F_REMOVING 0x1      /* Removing flag, does not accept new */

/* generic shctx struct */
struct shared_block {
	struct list list;
	unsigned int len;          /* data length for the row */
	unsigned int block_count;  /* number of blocks */
	unsigned int refcount;
	struct shared_block *last_reserved;
	struct shared_block *last_append;
	unsigned char data[VAR_ARRAY];
};

struct shared_context {
	__decl_thread(HA_RWLOCK_T lock);
	struct list avail;  /* list for active and free blocks */
	unsigned int nbav;  /* number of available blocks */
	unsigned int max_obj_size;   /* maximum object size (in bytes). */
	void (*free_block)(struct shared_block *first, void *data);
	void (*reserve_finish)(struct shared_context *shctx);
	void *cb_data;
	short int block_size;
	ALWAYS_ALIGN(64);  /* The following member needs to be aligned to 64 in the
			      cache's case because the cache struct contains an explicitly
			      aligned member (struct cache_tree). */
	unsigned char data[VAR_ARRAY];
};

#endif /* __HAPROXY_SHCTX_T_H */