e3ff9e76bc09235c92a05321da5fecb876555eeb
[m6w6/libmemcached] / include / libmemcached-1.0 / struct / server.h
1 /*
2 +--------------------------------------------------------------------+
3 | libmemcached - C/C++ Client Library for memcached |
4 +--------------------------------------------------------------------+
5 | Redistribution and use in source and binary forms, with or without |
6 | modification, are permitted under the terms of the BSD license. |
7 | You should have received a copy of the license in a bundled file |
8 | named LICENSE; in case you did not receive a copy you can review |
9 | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
10 +--------------------------------------------------------------------+
11 | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
12 | Copyright (c) 2020 Michael Wallner <mike@php.net> |
13 +--------------------------------------------------------------------+
14 */
15
16 #pragma once
17
18 #ifdef HAVE_NETDB_H
19 # include <netdb.h>
20 #endif
21
22 #ifdef NI_MAXHOST
23 # define MEMCACHED_NI_MAXHOST NI_MAXHOST
24 #else
25 # define MEMCACHED_NI_MAXHOST 1025
26 #endif
27
28 #ifdef NI_MAXSERV
29 # define MEMCACHED_NI_MAXSERV NI_MAXSERV
30 #else
31 # define MEMCACHED_NI_MAXSERV 32
32 #endif
33
34 enum memcached_server_state_t {
35 MEMCACHED_SERVER_STATE_NEW, // fd == -1, no address lookup has been done
36 MEMCACHED_SERVER_STATE_ADDRINFO, // ADDRRESS information has been gathered
37 MEMCACHED_SERVER_STATE_IN_PROGRESS,
38 MEMCACHED_SERVER_STATE_CONNECTED,
39 MEMCACHED_SERVER_STATE_IN_TIMEOUT,
40 MEMCACHED_SERVER_STATE_DISABLED
41 };
42
43 struct memcached_server_st {
44 struct {
45 bool is_allocated : 1;
46 bool is_initialized : 1;
47 bool is_shutting_down : 1;
48 bool is_dead : 1;
49 } options;
50 uint32_t number_of_hosts;
51 uint32_t cursor_active;
52 in_port_t port;
53 uint32_t io_bytes_sent; /* # bytes sent since last read */
54 uint32_t request_id;
55 uint32_t server_failure_counter;
56 uint64_t server_failure_counter_query_id;
57 uint32_t server_timeout_counter;
58 uint64_t server_timeout_counter_query_id;
59 uint32_t weight;
60 uint32_t version;
61 enum memcached_server_state_t state;
62 struct {
63 uint32_t read;
64 uint32_t write;
65 uint32_t timeouts;
66 size_t _bytes_read;
67 } io_wait_count;
68 uint8_t major_version; // Default definition of UINT8_MAX means that it has not been set.
69 uint8_t micro_version; // ditto, and note that this is the third, not second version bit
70 uint8_t minor_version; // ditto
71 memcached_connection_t type;
72 time_t next_retry;
73 struct memcached_st *root;
74 uint64_t limit_maxbytes;
75 struct memcached_error_t *error_messages;
76 char hostname[MEMCACHED_NI_MAXHOST];
77 };