libcouchbase 0.3.3 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/ext/libcouchbase/CMakeLists.txt +6 -8
- data/ext/libcouchbase/README.markdown +2 -2
- data/ext/libcouchbase/RELEASE_NOTES.markdown +229 -2
- data/ext/libcouchbase/cmake/Modules/ConfigureDtrace.cmake +11 -0
- data/ext/libcouchbase/cmake/Modules/GenerateConfigDotH.cmake +18 -0
- data/ext/libcouchbase/cmake/Modules/GetLibcouchbaseFlags.cmake +3 -2
- data/ext/libcouchbase/cmake/Modules/GetVersionInfo.cmake +3 -3
- data/ext/libcouchbase/cmake/config-cmake.h.in +4 -0
- data/ext/libcouchbase/cmake/defs.mk.in +0 -2
- data/ext/libcouchbase/cmake/source_files.cmake +21 -5
- data/ext/libcouchbase/contrib/cJSON/cJSON.c +1 -1
- data/ext/libcouchbase/contrib/cbsasl/src/client.c +2 -0
- data/ext/libcouchbase/example/users/README +48 -0
- data/ext/libcouchbase/example/users/users.c +147 -0
- data/ext/libcouchbase/include/libcouchbase/auth.h +175 -31
- data/ext/libcouchbase/include/libcouchbase/cntl.h +82 -1
- data/ext/libcouchbase/include/libcouchbase/couchbase.h +45 -3
- data/ext/libcouchbase/include/libcouchbase/error.h +19 -1
- data/ext/libcouchbase/include/libcouchbase/iops.h +3 -0
- data/ext/libcouchbase/include/libcouchbase/n1ql.h +31 -1
- data/ext/libcouchbase/include/libcouchbase/plugins/io/bsdio-inl.c +4 -1
- data/ext/libcouchbase/include/libcouchbase/subdoc.h +36 -2
- data/ext/libcouchbase/include/libcouchbase/views.h +7 -1
- data/ext/libcouchbase/include/libcouchbase/visibility.h +1 -0
- data/ext/libcouchbase/include/memcached/protocol_binary.h +24 -1146
- data/ext/libcouchbase/packaging/parse-git-describe.pl +1 -1
- data/ext/libcouchbase/plugins/io/libev/libev_io_opts.h +3 -2
- data/ext/libcouchbase/src/README.md +0 -2
- data/ext/libcouchbase/src/auth-priv.h +23 -4
- data/ext/libcouchbase/src/auth.cc +51 -43
- data/ext/libcouchbase/src/bootstrap.cc +244 -0
- data/ext/libcouchbase/src/bootstrap.h +58 -38
- data/ext/libcouchbase/src/bucketconfig/bc_cccp.cc +120 -158
- data/ext/libcouchbase/src/bucketconfig/bc_file.cc +281 -0
- data/ext/libcouchbase/src/bucketconfig/bc_http.cc +526 -0
- data/ext/libcouchbase/src/bucketconfig/bc_http.h +50 -25
- data/ext/libcouchbase/src/bucketconfig/bc_static.cc +150 -0
- data/ext/libcouchbase/src/bucketconfig/clconfig.h +410 -386
- data/ext/libcouchbase/src/bucketconfig/confmon.cc +393 -0
- data/ext/libcouchbase/src/cbft.cc +22 -27
- data/ext/libcouchbase/src/cntl.cc +56 -22
- data/ext/libcouchbase/src/connspec.cc +47 -6
- data/ext/libcouchbase/src/connspec.h +27 -0
- data/ext/libcouchbase/src/dns-srv.cc +147 -0
- data/ext/libcouchbase/src/dump.cc +3 -3
- data/ext/libcouchbase/src/errmap.cc +173 -0
- data/ext/libcouchbase/src/errmap.h +198 -0
- data/ext/libcouchbase/src/getconfig.cc +7 -33
- data/ext/libcouchbase/src/handler.cc +118 -7
- data/ext/libcouchbase/src/hostlist.cc +0 -36
- data/ext/libcouchbase/src/hostlist.h +44 -62
- data/ext/libcouchbase/src/http/http-priv.h +125 -112
- data/ext/libcouchbase/src/http/http.cc +27 -35
- data/ext/libcouchbase/src/http/http.h +1 -34
- data/ext/libcouchbase/src/http/http_io.cc +28 -36
- data/ext/libcouchbase/src/instance.cc +131 -34
- data/ext/libcouchbase/src/internal.h +58 -26
- data/ext/libcouchbase/src/jsparse/parser.cc +136 -210
- data/ext/libcouchbase/src/jsparse/parser.h +84 -98
- data/ext/libcouchbase/src/lcbht/lcbht.cc +177 -0
- data/ext/libcouchbase/src/lcbht/lcbht.h +174 -163
- data/ext/libcouchbase/src/lcbio/connect.cc +569 -0
- data/ext/libcouchbase/src/lcbio/connect.h +16 -7
- data/ext/libcouchbase/src/lcbio/ctx.c +1 -1
- data/ext/libcouchbase/src/lcbio/iotable.h +101 -16
- data/ext/libcouchbase/src/lcbio/{ioutils.c → ioutils.cc} +30 -51
- data/ext/libcouchbase/src/lcbio/ioutils.h +29 -90
- data/ext/libcouchbase/src/lcbio/manager.cc +543 -0
- data/ext/libcouchbase/src/lcbio/manager.h +133 -96
- data/ext/libcouchbase/src/lcbio/protoctx.c +2 -2
- data/ext/libcouchbase/src/lcbio/timer-cxx.h +87 -0
- data/ext/libcouchbase/src/mc/mcreq.c +11 -2
- data/ext/libcouchbase/src/mc/mcreq.h +9 -2
- data/ext/libcouchbase/src/mcserver/mcserver.cc +175 -43
- data/ext/libcouchbase/src/mcserver/mcserver.h +9 -13
- data/ext/libcouchbase/src/mcserver/negotiate.cc +181 -62
- data/ext/libcouchbase/src/mcserver/negotiate.h +1 -3
- data/ext/libcouchbase/src/mctx-helper.h +51 -0
- data/ext/libcouchbase/src/n1ql/ixmgmt.cc +1 -2
- data/ext/libcouchbase/src/n1ql/n1ql.cc +74 -42
- data/ext/libcouchbase/src/netbuf/netbuf.c +4 -4
- data/ext/libcouchbase/src/newconfig.cc +6 -6
- data/ext/libcouchbase/src/nodeinfo.cc +2 -2
- data/ext/libcouchbase/src/operations/{cbflush.c → cbflush.cc} +7 -15
- data/ext/libcouchbase/src/operations/{counter.c → counter.cc} +0 -0
- data/ext/libcouchbase/src/operations/durability.cc +6 -26
- data/ext/libcouchbase/src/operations/durability_internal.h +6 -3
- data/ext/libcouchbase/src/operations/{get.c → get.cc} +24 -26
- data/ext/libcouchbase/src/operations/{observe.c → observe.cc} +68 -93
- data/ext/libcouchbase/src/operations/{pktfwd.c → pktfwd.cc} +0 -0
- data/ext/libcouchbase/src/operations/{remove.c → remove.cc} +0 -0
- data/ext/libcouchbase/src/operations/stats.cc +3 -8
- data/ext/libcouchbase/src/operations/{store.c → store.cc} +27 -32
- data/ext/libcouchbase/src/operations/subdoc.cc +129 -42
- data/ext/libcouchbase/src/operations/{touch.c → touch.cc} +0 -0
- data/ext/libcouchbase/src/packetutils.h +30 -2
- data/ext/libcouchbase/src/probes.d +1 -1
- data/ext/libcouchbase/src/rdb/rope.c +1 -1
- data/ext/libcouchbase/src/{retrychk.c → retrychk.cc} +2 -3
- data/ext/libcouchbase/src/retryq.cc +52 -14
- data/ext/libcouchbase/src/retryq.h +3 -3
- data/ext/libcouchbase/src/settings.c +5 -0
- data/ext/libcouchbase/src/settings.h +11 -0
- data/ext/libcouchbase/src/ssl/ssl_c.c +1 -0
- data/ext/libcouchbase/src/ssl/ssl_common.c +2 -0
- data/ext/libcouchbase/src/ssl/ssl_e.c +0 -1
- data/ext/libcouchbase/src/strcodecs/strcodecs.h +1 -1
- data/ext/libcouchbase/src/trace.h +4 -4
- data/ext/libcouchbase/src/vbucket/vbucket.c +6 -10
- data/ext/libcouchbase/src/views/{docreq.c → docreq.cc} +48 -54
- data/ext/libcouchbase/src/views/docreq.h +24 -30
- data/ext/libcouchbase/src/views/viewreq.cc +318 -0
- data/ext/libcouchbase/src/views/viewreq.h +43 -13
- data/ext/libcouchbase/tests/basic/t_connstr.cc +88 -50
- data/ext/libcouchbase/tests/basic/t_creds.cc +47 -5
- data/ext/libcouchbase/tests/basic/t_host.cc +67 -75
- data/ext/libcouchbase/tests/basic/t_jsparse.cc +27 -82
- data/ext/libcouchbase/tests/basic/t_misc.cc +1 -1
- data/ext/libcouchbase/tests/basic/t_n1qlstrings.cc +0 -1
- data/ext/libcouchbase/tests/htparse/t_basic.cc +58 -78
- data/ext/libcouchbase/tests/ioserver/connection.cc +1 -1
- data/ext/libcouchbase/tests/ioserver/ioserver.cc +19 -6
- data/ext/libcouchbase/tests/iotests/mock-environment.cc +28 -2
- data/ext/libcouchbase/tests/iotests/mock-environment.h +51 -1
- data/ext/libcouchbase/tests/iotests/t_behavior.cc +1 -7
- data/ext/libcouchbase/tests/iotests/t_confmon.cc +97 -115
- data/ext/libcouchbase/tests/iotests/t_durability.cc +0 -1
- data/ext/libcouchbase/tests/iotests/t_eerrs.cc +119 -0
- data/ext/libcouchbase/tests/iotests/t_errmap.cc +178 -0
- data/ext/libcouchbase/tests/iotests/t_misc.cc +3 -3
- data/ext/libcouchbase/tests/iotests/t_netfail.cc +1 -1
- data/ext/libcouchbase/tests/iotests/t_obseqno.cc +0 -1
- data/ext/libcouchbase/tests/iotests/t_subdoc.cc +18 -11
- data/ext/libcouchbase/tests/mc/t_alloc.cc +9 -9
- data/ext/libcouchbase/tests/socktests/socktest.cc +7 -10
- data/ext/libcouchbase/tests/socktests/socktest.h +2 -3
- data/ext/libcouchbase/tests/socktests/t_basic.cc +6 -6
- data/ext/libcouchbase/tests/socktests/t_manager.cc +5 -6
- data/ext/libcouchbase/tests/socktests/t_ssl.cc +1 -1
- data/ext/libcouchbase/tests/vbucket/confdata/ketama_expected.json +2562 -0
- data/ext/libcouchbase/tests/vbucket/confdata/memd_ketama_config.json +31 -0
- data/ext/libcouchbase/tests/vbucket/t_config.cc +35 -5
- data/ext/libcouchbase/tools/CMakeLists.txt +2 -2
- data/ext/libcouchbase/tools/cbc-handlers.h +128 -0
- data/ext/libcouchbase/tools/cbc-n1qlback.cc +64 -10
- data/ext/libcouchbase/tools/cbc-pillowfight.cc +2 -2
- data/ext/libcouchbase/tools/cbc.cc +143 -10
- data/ext/libcouchbase/tools/docgen/loc.h +1 -1
- data/lib/libcouchbase/connection.rb +4 -3
- data/lib/libcouchbase/version.rb +1 -1
- metadata +37 -28
- data/ext/libcouchbase/include/memcached/vbucket.h +0 -42
- data/ext/libcouchbase/src/bootstrap.c +0 -269
- data/ext/libcouchbase/src/bucketconfig/bc_file.c +0 -347
- data/ext/libcouchbase/src/bucketconfig/bc_http.c +0 -630
- data/ext/libcouchbase/src/bucketconfig/bc_mcraw.c +0 -150
- data/ext/libcouchbase/src/bucketconfig/confmon.c +0 -474
- data/ext/libcouchbase/src/lcbht/lcbht.c +0 -282
- data/ext/libcouchbase/src/lcbio/connect.c +0 -557
- data/ext/libcouchbase/src/lcbio/manager.c +0 -584
- data/ext/libcouchbase/src/packetutils.c +0 -37
- data/ext/libcouchbase/src/simplestring.c +0 -211
- data/ext/libcouchbase/src/simplestring.h +0 -228
- data/ext/libcouchbase/src/ssobuf.h +0 -82
- data/ext/libcouchbase/src/views/viewreq.c +0 -358
- data/ext/libcouchbase/tests/basic/t_string.cc +0 -112
|
@@ -23,9 +23,24 @@
|
|
|
23
23
|
#include "settings.h"
|
|
24
24
|
#include "hostlist.h"
|
|
25
25
|
#ifdef __cplusplus
|
|
26
|
+
namespace lcb {
|
|
27
|
+
namespace io {
|
|
28
|
+
struct Connstart;
|
|
29
|
+
struct PoolRequest;
|
|
30
|
+
class ConnectionRequest;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
typedef lcb::io::ConnectionRequest* lcbio_pCONNSTART;
|
|
34
|
+
typedef lcb::io::ConnectionRequest lcbio_MGRREQ;
|
|
26
35
|
extern "C" {
|
|
36
|
+
#else
|
|
37
|
+
struct lcbio_CONNSTART;
|
|
38
|
+
typedef struct lcbio_CONNSTART* lcbio_pCONNSTART;
|
|
39
|
+
typedef struct lcbio_MGRREQ lcbio_MGRREQ;
|
|
27
40
|
#endif
|
|
28
41
|
|
|
42
|
+
typedef lcbio_MGRREQ* lcbio_pMGRREQ;
|
|
43
|
+
|
|
29
44
|
/**
|
|
30
45
|
* @file
|
|
31
46
|
* This provides the core socket routines
|
|
@@ -39,12 +54,6 @@ extern "C" {
|
|
|
39
54
|
* @{
|
|
40
55
|
*/
|
|
41
56
|
|
|
42
|
-
struct lcbio_CONNSTART;
|
|
43
|
-
struct lcbio_MGRREQ;
|
|
44
|
-
|
|
45
|
-
/** @brief Pending connection request */
|
|
46
|
-
typedef struct lcbio_CONNSTART *lcbio_pCONNSTART;
|
|
47
|
-
typedef struct lcbio_MGRREQ *lcbio_pMGRREQ;
|
|
48
57
|
typedef struct lcbio_TABLE *lcbio_pTABLE;
|
|
49
58
|
typedef struct lcbio_TIMER *lcbio_pTIMER, *lcbio_pASYNC;
|
|
50
59
|
|
|
@@ -266,7 +275,7 @@ lcbio_protoctx_add(lcbio_SOCKET *socket, lcbio_PROTOCTX *proto);
|
|
|
266
275
|
* @return the context, or NULL if not found
|
|
267
276
|
*/
|
|
268
277
|
lcbio_PROTOCTX *
|
|
269
|
-
lcbio_protoctx_get(lcbio_SOCKET *socket, lcbio_PROTOID id);
|
|
278
|
+
lcbio_protoctx_get(const lcbio_SOCKET *socket, lcbio_PROTOID id);
|
|
270
279
|
|
|
271
280
|
/**
|
|
272
281
|
* Remove a protocol context by its ID
|
|
@@ -148,7 +148,7 @@ lcbio_ctx_close_ex(lcbio_CTX *ctx, lcbio_CTXCLOSE_cb cb, void *arg,
|
|
|
148
148
|
}
|
|
149
149
|
|
|
150
150
|
oldrc = ctx->sock->refcount;
|
|
151
|
-
lcb_log(LOGARGS(ctx, DEBUG), CTX_LOGFMT "Destroying.
|
|
151
|
+
lcb_log(LOGARGS(ctx, DEBUG), CTX_LOGFMT "Destroying context. Pending Writes=%d, Entered=%s, Socket Refcount=%d", CTX_LOGID(ctx), (int)ctx->npending, (int)ctx->entered ? "true": "false", oldrc);
|
|
152
152
|
|
|
153
153
|
if (cb) {
|
|
154
154
|
int reusable =
|
|
@@ -37,22 +37,6 @@
|
|
|
37
37
|
extern "C" {
|
|
38
38
|
#endif
|
|
39
39
|
|
|
40
|
-
typedef struct lcbio_TABLE {
|
|
41
|
-
lcb_io_opt_t p;
|
|
42
|
-
lcb_iomodel_t model;
|
|
43
|
-
lcb_timer_procs timer;
|
|
44
|
-
lcb_loop_procs loop;
|
|
45
|
-
|
|
46
|
-
union {
|
|
47
|
-
struct {
|
|
48
|
-
lcb_ev_procs ev;
|
|
49
|
-
lcb_bsd_procs io;
|
|
50
|
-
} v0;
|
|
51
|
-
lcb_completion_procs completion;
|
|
52
|
-
} u_io;
|
|
53
|
-
unsigned refcount;
|
|
54
|
-
void (*dtor)(void *);
|
|
55
|
-
} lcbio_TABLE;
|
|
56
40
|
|
|
57
41
|
/** Whether the underlying model is event-based */
|
|
58
42
|
#define IOT_IS_EVENT(iot) ((iot)->model == LCB_IOMODEL_EVENT)
|
|
@@ -78,6 +62,107 @@ typedef struct lcbio_TABLE {
|
|
|
78
62
|
/** First argument to IO Table */
|
|
79
63
|
#define IOT_ARG(iot) (iot)->p
|
|
80
64
|
|
|
65
|
+
typedef struct lcbio_TABLE {
|
|
66
|
+
lcb_io_opt_t p;
|
|
67
|
+
lcb_iomodel_t model;
|
|
68
|
+
lcb_timer_procs timer;
|
|
69
|
+
lcb_loop_procs loop;
|
|
70
|
+
|
|
71
|
+
union {
|
|
72
|
+
struct {
|
|
73
|
+
lcb_ev_procs ev;
|
|
74
|
+
lcb_bsd_procs io;
|
|
75
|
+
} v0;
|
|
76
|
+
lcb_completion_procs completion;
|
|
77
|
+
} u_io;
|
|
78
|
+
unsigned refcount;
|
|
79
|
+
void (*dtor)(void *);
|
|
80
|
+
|
|
81
|
+
#ifdef __cplusplus
|
|
82
|
+
bool is_E() const { return IOT_IS_EVENT(this); }
|
|
83
|
+
bool is_C() const { return !is_E(); }
|
|
84
|
+
int get_errno() const { return IOT_ERRNO(this); }
|
|
85
|
+
|
|
86
|
+
void run_loop() { IOT_START(this); }
|
|
87
|
+
void stop_loop() { IOT_STOP(this); }
|
|
88
|
+
|
|
89
|
+
int E_connect(lcb_socket_t sock, const sockaddr* saddr, unsigned addrlen) {
|
|
90
|
+
return IOT_V0IO(this).connect0(p, sock, saddr, addrlen);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
lcb_socket_t E_socket(int domain, int type, int protocol) {
|
|
94
|
+
return IOT_V0IO(this).socket0(p, domain, type, protocol);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
lcb_socket_t E_socket(const addrinfo *ai) {
|
|
98
|
+
return E_socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
void E_close(lcb_socket_t sock) {
|
|
102
|
+
IOT_V0IO(this).close(p, sock);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
void *E_event_create() {
|
|
106
|
+
return IOT_V0EV(this).create(p);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
void E_event_watch(lcb_socket_t fd, void *event, short mask, void *arg,
|
|
110
|
+
lcb_ioE_callback cb) {
|
|
111
|
+
IOT_V0EV(this).watch(p, fd, event, mask, arg, cb);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
void E_event_destroy(void *event) {
|
|
115
|
+
IOT_V0EV(this).destroy(p, event);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
void E_event_cancel(lcb_socket_t fd, void *event) {
|
|
119
|
+
IOT_V0EV(this).cancel(p, fd, event);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
int E_check_closed(lcb_socket_t s, int flags) {
|
|
123
|
+
return IOT_V0IO(this).is_closed(p, s, flags);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
int E_cntl(lcb_socket_t s, int mode, int opt, void *val) {
|
|
127
|
+
return IOT_V0IO(this).cntl(p, s, mode, opt, val);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
void C_close(lcb_sockdata_t *sd) {
|
|
131
|
+
IOT_V1(this).close(p, sd);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
int C_connect(lcb_sockdata_t *sd, const sockaddr *addr, unsigned addrlen,
|
|
135
|
+
lcb_io_connect_cb callback) {
|
|
136
|
+
return IOT_V1(this).connect(p, sd, addr, addrlen, callback);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
lcb_sockdata_t* C_socket(int domain, int type, int protocol) {
|
|
140
|
+
return IOT_V1(this).socket(p, domain, type, protocol);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
lcb_sockdata_t* C_socket(const addrinfo *ai) {
|
|
144
|
+
return C_socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
int C_check_closed(lcb_sockdata_t *sock, int flags) {
|
|
148
|
+
return IOT_V1(this).is_closed(p, sock, flags);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
int C_cntl(lcb_sockdata_t *sd, int mode, int opt, void *val) {
|
|
152
|
+
return IOT_V1(this).cntl(p, sd, mode, opt, val) == 0;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
bool has_cntl() {
|
|
156
|
+
if (is_E()) {
|
|
157
|
+
return IOT_V0IO(this).cntl != NULL;
|
|
158
|
+
} else {
|
|
159
|
+
return IOT_V1(this).cntl != NULL;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
#endif
|
|
163
|
+
|
|
164
|
+
} lcbio_TABLE;
|
|
165
|
+
|
|
81
166
|
#ifdef __cplusplus
|
|
82
167
|
}
|
|
83
168
|
#endif
|
|
@@ -100,7 +100,7 @@ ioerr2lcberr(lcbio_OSERR in, const lcb_settings *settings)
|
|
|
100
100
|
case ECONNABORTED:
|
|
101
101
|
return LCB_ECONNRESET;
|
|
102
102
|
default:
|
|
103
|
-
lcb_log(settings, "lcbio", LCB_LOG_WARN, __FILE__, __LINE__, "
|
|
103
|
+
lcb_log(settings, "lcbio", LCB_LOG_WARN, __FILE__, __LINE__, "OS errno %d (%s) does not have a direct client error code equivalent. Using NETWORK_ERROR", in, strerror(in));
|
|
104
104
|
return LCB_NETWORK_ERROR;
|
|
105
105
|
}
|
|
106
106
|
}
|
|
@@ -124,14 +124,12 @@ lcbio_E_ai2sock(lcbio_TABLE *io, struct addrinfo **ai, int *connerr)
|
|
|
124
124
|
*connerr = 0;
|
|
125
125
|
|
|
126
126
|
for (; *ai; *ai = (*ai)->ai_next) {
|
|
127
|
-
ret =
|
|
128
|
-
IOT_ARG(io), (*ai)->ai_family, (*ai)->ai_socktype,
|
|
129
|
-
(*ai)->ai_protocol);
|
|
127
|
+
ret = io->E_socket(*ai);
|
|
130
128
|
|
|
131
129
|
if (ret != INVALID_SOCKET) {
|
|
132
130
|
return ret;
|
|
133
131
|
} else {
|
|
134
|
-
*connerr =
|
|
132
|
+
*connerr = io->get_errno();
|
|
135
133
|
}
|
|
136
134
|
}
|
|
137
135
|
|
|
@@ -143,9 +141,7 @@ lcbio_C_ai2sock(lcbio_TABLE *io, struct addrinfo **ai, int *connerr)
|
|
|
143
141
|
{
|
|
144
142
|
lcb_sockdata_t *ret = NULL;
|
|
145
143
|
for (; *ai; *ai = (*ai)->ai_next) {
|
|
146
|
-
ret =
|
|
147
|
-
IOT_ARG(io), (*ai)->ai_family, (*ai)->ai_socktype,
|
|
148
|
-
(*ai)->ai_protocol);
|
|
144
|
+
ret = io->C_socket(*ai);
|
|
149
145
|
if (ret) {
|
|
150
146
|
return ret;
|
|
151
147
|
} else {
|
|
@@ -254,31 +250,26 @@ lcbio_is_netclosed(lcbio_SOCKET *sock, int flags)
|
|
|
254
250
|
{
|
|
255
251
|
lcbio_pTABLE iot = sock->io;
|
|
256
252
|
|
|
257
|
-
if (
|
|
258
|
-
return
|
|
253
|
+
if (iot->is_E()) {
|
|
254
|
+
return iot->E_check_closed(sock->u.fd, flags);
|
|
259
255
|
} else {
|
|
260
|
-
return
|
|
256
|
+
return iot->C_check_closed(sock->u.sd, flags);
|
|
261
257
|
}
|
|
262
258
|
}
|
|
263
259
|
|
|
264
260
|
lcb_error_t
|
|
265
|
-
|
|
266
|
-
{
|
|
261
|
+
lcbio_enable_sockopt(lcbio_SOCKET *s, int cntl) {
|
|
267
262
|
lcbio_pTABLE iot = s->io;
|
|
268
|
-
int
|
|
269
|
-
int
|
|
270
|
-
(!IOT_IS_EVENT(iot) && IOT_V1(iot).cntl);
|
|
263
|
+
int rv;
|
|
264
|
+
int value = 1;
|
|
271
265
|
|
|
272
|
-
if (!
|
|
266
|
+
if (!iot->has_cntl()) {
|
|
273
267
|
return LCB_NOT_SUPPORTED;
|
|
274
268
|
}
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
rv = IOT_V0IO(iot).cntl(IOT_ARG(iot), s->u.fd, LCB_IO_CNTL_SET,
|
|
278
|
-
LCB_IO_CNTL_TCP_NODELAY, &val);
|
|
269
|
+
if (iot->is_E()) {
|
|
270
|
+
rv = iot->E_cntl(s->u.fd, LCB_IO_CNTL_SET, cntl, &value);
|
|
279
271
|
} else {
|
|
280
|
-
rv =
|
|
281
|
-
LCB_IO_CNTL_TCP_NODELAY, &val);
|
|
272
|
+
rv = iot->C_cntl(s->u.sd, LCB_IO_CNTL_SET, cntl, &value);
|
|
282
273
|
}
|
|
283
274
|
if (rv != 0) {
|
|
284
275
|
return lcbio_mklcberr(IOT_ERRNO(iot), s->settings);
|
|
@@ -287,22 +278,16 @@ lcbio_disable_nagle(lcbio_SOCKET *s)
|
|
|
287
278
|
}
|
|
288
279
|
}
|
|
289
280
|
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
{
|
|
293
|
-
|
|
294
|
-
return;
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
} else if (req->type == LCBIO_CONNREQ_RAW) {
|
|
300
|
-
lcbio_connect_cancel(req->u.cs);
|
|
301
|
-
} else {
|
|
302
|
-
req->dtor(req->u.p_generic);
|
|
281
|
+
const char *
|
|
282
|
+
lcbio_strsockopt(int cntl) {
|
|
283
|
+
switch (cntl) {
|
|
284
|
+
case LCB_IO_CNTL_TCP_KEEPALIVE:
|
|
285
|
+
return "TCP_KEEPALIVE";
|
|
286
|
+
case LCB_IO_CNTL_TCP_NODELAY:
|
|
287
|
+
return "TCP_NODELAY";
|
|
288
|
+
default:
|
|
289
|
+
return "FIXME: Unknown option";
|
|
303
290
|
}
|
|
304
|
-
|
|
305
|
-
req->u.cs = NULL;
|
|
306
291
|
}
|
|
307
292
|
|
|
308
293
|
int
|
|
@@ -316,35 +301,29 @@ lcbio_ssl_supported(void)
|
|
|
316
301
|
}
|
|
317
302
|
|
|
318
303
|
lcbio_pSSLCTX
|
|
319
|
-
lcbio_ssl_new__fallback(const char
|
|
320
|
-
lcb_settings *
|
|
304
|
+
lcbio_ssl_new__fallback(const char *, int, lcb_error_t *errp,
|
|
305
|
+
lcb_settings *)
|
|
321
306
|
{
|
|
322
|
-
(void)ca; (void)noverify; (void)settings;
|
|
323
307
|
if (errp) { *errp = LCB_CLIENT_FEATURE_UNAVAILABLE; }
|
|
324
308
|
return NULL;
|
|
325
309
|
}
|
|
326
310
|
|
|
327
311
|
|
|
328
312
|
#ifdef LCB_NO_SSL
|
|
329
|
-
void lcbio_ssl_free(lcbio_pSSLCTX
|
|
330
|
-
(void)a;
|
|
313
|
+
void lcbio_ssl_free(lcbio_pSSLCTX) {
|
|
331
314
|
}
|
|
332
|
-
lcb_error_t lcbio_ssl_apply(lcbio_SOCKET
|
|
333
|
-
(void)a;(void)b;
|
|
315
|
+
lcb_error_t lcbio_ssl_apply(lcbio_SOCKET*, lcbio_pSSLCTX) {
|
|
334
316
|
return LCB_CLIENT_FEATURE_UNAVAILABLE;
|
|
335
317
|
}
|
|
336
|
-
int lcbio_ssl_check(lcbio_SOCKET
|
|
337
|
-
(void)s;
|
|
318
|
+
int lcbio_ssl_check(lcbio_SOCKET*) {
|
|
338
319
|
return 0;
|
|
339
320
|
}
|
|
340
|
-
lcb_error_t lcbio_ssl_get_error(lcbio_SOCKET *
|
|
341
|
-
(void)s;
|
|
321
|
+
lcb_error_t lcbio_ssl_get_error(lcbio_SOCKET *) {
|
|
342
322
|
return LCB_SUCCESS;
|
|
343
323
|
}
|
|
344
324
|
void lcbio_ssl_global_init(void) {
|
|
345
325
|
}
|
|
346
|
-
lcb_error_t lcbio_sslify_if_needed(lcbio_SOCKET
|
|
347
|
-
(void)s;(void)st;
|
|
326
|
+
lcb_error_t lcbio_sslify_if_needed(lcbio_SOCKET *, lcb_settings *) {
|
|
348
327
|
return LCB_SUCCESS;
|
|
349
328
|
}
|
|
350
329
|
#endif
|
|
@@ -92,9 +92,17 @@ lcbio_get_nameinfo(lcbio_SOCKET *sock, struct lcbio_NAMEINFO *nistrs);
|
|
|
92
92
|
int
|
|
93
93
|
lcbio_is_netclosed(lcbio_SOCKET *sock, int flags);
|
|
94
94
|
|
|
95
|
-
/**
|
|
95
|
+
/**
|
|
96
|
+
* Enable an option on a socket
|
|
97
|
+
* @param sock The socket
|
|
98
|
+
* @param cntl The option (LCB_IO_CNTL_xxx)
|
|
99
|
+
* @return
|
|
100
|
+
*/
|
|
96
101
|
lcb_error_t
|
|
97
|
-
|
|
102
|
+
lcbio_enable_sockopt(lcbio_SOCKET *sock, int cntl);
|
|
103
|
+
|
|
104
|
+
const char *
|
|
105
|
+
lcbio_strsockopt(int cntl);
|
|
98
106
|
|
|
99
107
|
void
|
|
100
108
|
lcbio__load_socknames(lcbio_SOCKET *sock);
|
|
@@ -105,99 +113,30 @@ lcbio__load_socknames(lcbio_SOCKET *sock);
|
|
|
105
113
|
#define lcbio_syserrno errno
|
|
106
114
|
#endif
|
|
107
115
|
|
|
116
|
+
#ifdef __cplusplus
|
|
117
|
+
}
|
|
108
118
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
* @{
|
|
112
|
-
*
|
|
113
|
-
* @name Pending Requests
|
|
114
|
-
* @{
|
|
115
|
-
*
|
|
116
|
-
* The lcbio_CONNREQ structure may contain various forms of pending requests
|
|
117
|
-
* which are _cancellable_. This is useful to act as an abstraction over the
|
|
118
|
-
* various helper functions which may be employed to initiate a new connection
|
|
119
|
-
* or negotiate an existing one.
|
|
120
|
-
*
|
|
121
|
-
* The semantics of a _cancellable_ request are:
|
|
122
|
-
*
|
|
123
|
-
* <ul>
|
|
124
|
-
* <li>They represent a pending operation</li>
|
|
125
|
-
* <li>When cancelled, the pending operation is invalidated. This means that
|
|
126
|
-
* any callbacks scheduled as a result of the operation will not be invoked.
|
|
127
|
-
* </li>
|
|
128
|
-
*
|
|
129
|
-
* <li>If the pending operation has completed, the request is invalidated. This
|
|
130
|
-
* means the pointer for the request is considered invalid once the operation
|
|
131
|
-
* has completed
|
|
132
|
-
* </li>
|
|
133
|
-
* </ul>
|
|
134
|
-
*/
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* @brief Container object for various forms of cancellable requests.
|
|
138
|
-
*/
|
|
139
|
-
typedef struct {
|
|
140
|
-
int type; /**< One of the LCBIO_CONNREQ_* constants */
|
|
141
|
-
#define LCBIO_CONNREQ_RAW 1
|
|
142
|
-
#define LCBIO_CONNREQ_POOLED 2
|
|
143
|
-
#define LCBIO_CONNREQ_GENERIC 3
|
|
144
|
-
union {
|
|
145
|
-
struct lcbio_CONNSTART *cs; /**< from lcbio_connect() */
|
|
146
|
-
struct lcbio_MGRREQ *preq; /**< from lcbio_mgr_get() */
|
|
147
|
-
void *p_generic; /**< Generic pointer. Destroyed via the dtor field */
|
|
148
|
-
} u;
|
|
149
|
-
void (*dtor)(void *);
|
|
150
|
-
} lcbio_CONNREQ;
|
|
151
|
-
|
|
152
|
-
/** @brief Clear an existing request, setting the pointer to NULL */
|
|
153
|
-
#define LCBIO_CONNREQ_CLEAR(req) (req)->u.p_generic = NULL
|
|
154
|
-
|
|
155
|
-
/**
|
|
156
|
-
* @brief Initialize a connreq with an lcbio_pCONNSTART handle
|
|
157
|
-
* @param req the request to initialize
|
|
158
|
-
* @param cs the lcbio_pCONNSTART returned by lcbio_connect()
|
|
159
|
-
*/
|
|
160
|
-
#define LCBIO_CONNREQ_MKRAW(req, cs) do { \
|
|
161
|
-
(req)->u.cs = cs; \
|
|
162
|
-
(req)->type = LCBIO_CONNREQ_RAW; \
|
|
163
|
-
} while (0);
|
|
164
|
-
|
|
165
|
-
/**
|
|
166
|
-
* @brief Initialize a connreq with an lcbio_pMGRREQ
|
|
167
|
-
* @param req The request to initialize
|
|
168
|
-
* @param sreq the lcbio_pMGRREQ returned by lcbio_mgr_get()
|
|
169
|
-
*/
|
|
170
|
-
#define LCBIO_CONNREQ_MKPOOLED(req, sreq) do { \
|
|
171
|
-
(req)->u.preq = sreq; \
|
|
172
|
-
(req)->type = LCBIO_CONNREQ_POOLED; \
|
|
173
|
-
} while (0);
|
|
119
|
+
namespace lcb {
|
|
120
|
+
namespace io {
|
|
174
121
|
|
|
175
122
|
/**
|
|
176
|
-
*
|
|
177
|
-
*
|
|
178
|
-
* @param p the pointer representing the request
|
|
179
|
-
* @param dtorcb a callback invoked with `p` when the request has been cancelled
|
|
123
|
+
* This interface defines a pending connection request. It may be
|
|
124
|
+
* cancelled.
|
|
180
125
|
*/
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
(
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
* @param req The request to cancel
|
|
193
|
-
*/
|
|
194
|
-
void
|
|
195
|
-
lcbio_connreq_cancel(lcbio_CONNREQ *req);
|
|
196
|
-
|
|
197
|
-
/**@}*/
|
|
198
|
-
/**@}*/
|
|
126
|
+
class ConnectionRequest {
|
|
127
|
+
public:
|
|
128
|
+
virtual void cancel() = 0;
|
|
129
|
+
virtual ~ConnectionRequest() {}
|
|
130
|
+
static void cancel(ConnectionRequest **pp) {
|
|
131
|
+
if (*pp) {
|
|
132
|
+
(*pp)->cancel();
|
|
133
|
+
*pp = NULL;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
};
|
|
199
137
|
|
|
200
|
-
#ifdef __cplusplus
|
|
201
138
|
}
|
|
139
|
+
}
|
|
140
|
+
|
|
202
141
|
#endif
|
|
203
142
|
#endif
|