Skip to content
Browse files

Make IO struct versioned

Change-Id: I99ade581752c4f11750fdb614870cfd5a1363c77
Reviewed-on: http://review.couchbase.org/21453
Tested-by: Sergey Avseyev <sergey.avseyev@gmail.com>
Reviewed-by: Trond Norbye <trond.norbye@gmail.com>
  • Loading branch information...
1 parent 290a0ca commit 74f59f61a47ee77e2e1ef373a28869b340e1f279 @avsej avsej committed with trondn Oct 9, 2012
View
8 example/yajl/couchview.c
@@ -314,7 +314,7 @@ static void data_callback(lcb_http_request_t request,
unsigned char *str = yajl_get_error(c->parser, 1, bytes, nbytes);
fprintf(stderr, "%s", (const char *) str);
yajl_free_error(c->parser, str);
- c->io->stop_event_loop(c->io);
+ c->io->v.v0.stop_event_loop(c->io);
}
} else { /* end of response */
st = yajl_complete_parse(c->parser);
@@ -329,7 +329,7 @@ static void data_callback(lcb_http_request_t request,
fwrite(buf, 1, len, output);
yajl_gen_clear(c->gen);
}
- c->io->stop_event_loop(c->io);
+ c->io->v.v0.stop_event_loop(c->io);
}
(void)request;
(void)instance;
@@ -375,7 +375,7 @@ static void complete_callback(lcb_http_request_t request,
error, lcb_strerror(instance, error), resp->v.v0.status);
fwrite(bytes, nbytes, 1, output);
}
- c->io->stop_event_loop(c->io);
+ c->io->v.v0.stop_event_loop(c->io);
(void)request;
(void)instance;
}
@@ -479,7 +479,7 @@ int main(int argc, char **argv)
/* Start the event loop and let it run until request will be completed
* with success or failure (see view callbacks) */
- cookie.io->run_event_loop(cookie.io);
+ cookie.io->v.v0.run_event_loop(cookie.io);
yajl_free(cookie.parser);
yajl_gen_free(cookie.gen);
View
148 include/libcouchbase/types.h
@@ -233,84 +233,76 @@ extern "C" {
};
struct lcb_io_opt_st {
- lcb_uint64_t version;
- void *cookie;
- int error;
-
- void (*destructor)(struct lcb_io_opt_st *iops);
-
- /**
- * Create a non-blocking socket.
- */
- lcb_socket_t (*socket)(struct lcb_io_opt_st *iops,
- int domain,
- int type,
- int protocol);
- int (*connect)(struct lcb_io_opt_st *iops,
- lcb_socket_t sock,
- const struct sockaddr *name,
- unsigned int namelen);
-
- lcb_ssize_t (*recv)(struct lcb_io_opt_st *iops,
- lcb_socket_t sock,
- void *buffer,
- lcb_size_t len,
- int flags);
- lcb_ssize_t (*send)(struct lcb_io_opt_st *iops,
- lcb_socket_t sock,
- const void *msg,
- lcb_size_t len,
- int flags);
-
- lcb_ssize_t (*recvv)(struct lcb_io_opt_st *iops,
- lcb_socket_t sock,
- struct lcb_iovec_st *iov,
- lcb_size_t niov);
-
- lcb_ssize_t (*sendv)(struct lcb_io_opt_st *iops,
- lcb_socket_t sock,
- struct lcb_iovec_st *iov,
- lcb_size_t niov);
-
-
- void (*close)(struct lcb_io_opt_st *iops,
- lcb_socket_t sock);
-
- void *(*create_timer)(struct lcb_io_opt_st *iops);
- void (*destroy_timer)(struct lcb_io_opt_st *iops,
- void *timer);
- void (*delete_timer)(struct lcb_io_opt_st *iops,
- void *timer);
- int (*update_timer)(struct lcb_io_opt_st *iops,
- void *timer,
- lcb_uint32_t usec,
- void *cb_data,
- void (*handler)(lcb_socket_t sock,
- short which,
- void *cb_data));
-
- void *(*create_event)(struct lcb_io_opt_st *iops);
- void (*destroy_event)(struct lcb_io_opt_st *iops,
- void *event);
-
- int (*update_event)(struct lcb_io_opt_st *iops,
- lcb_socket_t sock,
- void *event,
- short flags,
- void *cb_data,
- void (*handler)(lcb_socket_t sock,
- short which,
- void *cb_data));
-
- void (*delete_event)(struct lcb_io_opt_st *iops,
- lcb_socket_t sock,
- void *event);
-
- void (*stop_event_loop)(struct lcb_io_opt_st *iops);
- void (*run_event_loop)(struct lcb_io_opt_st *iops);
-
- /* Version 1 of the struct also includes the following members */
- void *dlhandle;
+ int version;
+ union {
+ struct {
+ void *cookie;
+ int error;
+ void *dlhandle;
+
+ void (*destructor)(struct lcb_io_opt_st *iops);
+
+ /**
+ * Create a non-blocking socket.
+ */
+ lcb_socket_t (*socket)(struct lcb_io_opt_st *iops,
+ int domain,
+ int type,
+ int protocol);
+ int (*connect)(struct lcb_io_opt_st *iops,
+ lcb_socket_t sock,
+ const struct sockaddr *name,
+ unsigned int namelen);
+ lcb_ssize_t (*recv)(struct lcb_io_opt_st *iops,
+ lcb_socket_t sock,
+ void *buffer,
+ lcb_size_t len,
+ int flags);
+ lcb_ssize_t (*send)(struct lcb_io_opt_st *iops,
+ lcb_socket_t sock,
+ const void *msg,
+ lcb_size_t len,
+ int flags);
+ lcb_ssize_t (*recvv)(struct lcb_io_opt_st *iops,
+ lcb_socket_t sock,
+ struct lcb_iovec_st *iov,
+ lcb_size_t niov);
+ lcb_ssize_t (*sendv)(struct lcb_io_opt_st *iops,
+ lcb_socket_t sock,
+ struct lcb_iovec_st *iov,
+ lcb_size_t niov);
+ void (*close)(struct lcb_io_opt_st *iops,
+ lcb_socket_t sock);
+ void *(*create_timer)(struct lcb_io_opt_st *iops);
+ void (*destroy_timer)(struct lcb_io_opt_st *iops,
+ void *timer);
+ void (*delete_timer)(struct lcb_io_opt_st *iops,
+ void *timer);
+ int (*update_timer)(struct lcb_io_opt_st *iops,
+ void *timer,
+ lcb_uint32_t usec,
+ void *cb_data,
+ void (*handler)(lcb_socket_t sock,
+ short which,
+ void *cb_data));
+ void *(*create_event)(struct lcb_io_opt_st *iops);
+ void (*destroy_event)(struct lcb_io_opt_st *iops,
+ void *event);
+ int (*update_event)(struct lcb_io_opt_st *iops,
+ lcb_socket_t sock,
+ void *event,
+ short flags,
+ void *cb_data,
+ void (*handler)(lcb_socket_t sock,
+ short which,
+ void *cb_data));
+ void (*delete_event)(struct lcb_io_opt_st *iops,
+ lcb_socket_t sock,
+ void *event);
+ void (*stop_event_loop)(struct lcb_io_opt_st *iops);
+ void (*run_event_loop)(struct lcb_io_opt_st *iops);
+ } v0;
+ } v;
};
typedef struct lcb_io_opt_st *lcb_io_opt_t;
View
76 plugins/io/libev/plugin-libev.c
@@ -39,7 +39,7 @@ static lcb_ssize_t lcb_io_recv(struct lcb_io_opt_st *iops,
{
lcb_ssize_t ret = recv(sock, buffer, len, flags);
if (ret < 0) {
- iops->error = errno;
+ iops->v.v0.error = errno;
}
return ret;
}
@@ -66,7 +66,7 @@ static lcb_ssize_t lcb_io_recvv(struct lcb_io_opt_st *iops,
ret = recvmsg(sock, &msg, 0);
if (ret < 0) {
- iops->error = errno;
+ iops->v.v0.error = errno;
}
return ret;
@@ -80,7 +80,7 @@ static lcb_ssize_t lcb_io_send(struct lcb_io_opt_st *iops,
{
lcb_ssize_t ret = send(sock, msg, len, flags);
if (ret < 0) {
- iops->error = errno;
+ iops->v.v0.error = errno;
}
return ret;
}
@@ -107,7 +107,7 @@ static lcb_ssize_t lcb_io_sendv(struct lcb_io_opt_st *iops,
ret = sendmsg(sock, &msg, 0);
if (ret < 0) {
- iops->error = errno;
+ iops->v.v0.error = errno;
}
return ret;
}
@@ -148,12 +148,12 @@ static lcb_socket_t lcb_io_socket(struct lcb_io_opt_st *iops,
{
lcb_socket_t sock = socket(domain, type, protocol);
if (sock == INVALID_SOCKET) {
- iops->error = errno;
+ iops->v.v0.error = errno;
} else {
if (make_socket_nonblocking(sock) != 0) {
int error = errno;
- iops->close(iops, sock);
- iops->error = error;
+ iops->v.v0.close(iops, sock);
+ iops->v.v0.error = error;
sock = INVALID_SOCKET;
}
}
@@ -175,7 +175,7 @@ static int lcb_io_connect(struct lcb_io_opt_st *iops,
{
int ret = connect(sock, name, (socklen_t)namelen);
if (ret < 0) {
- iops->error = errno;
+ iops->v.v0.error = errno;
}
return ret;
}
@@ -221,7 +221,7 @@ static int lcb_io_update_event(struct lcb_io_opt_st *iops,
short which,
void *cb_data))
{
- struct libev_cookie *io_cookie = iops->cookie;
+ struct libev_cookie *io_cookie = iops->v.v0.cookie;
struct libev_event *evt = event;
int events = EV_NONE;
@@ -251,7 +251,7 @@ static void lcb_io_delete_event(struct lcb_io_opt_st *iops,
lcb_socket_t sock,
void *event)
{
- struct libev_cookie *io_cookie = iops->cookie;
+ struct libev_cookie *io_cookie = iops->v.v0.cookie;
struct libev_event *evt = event;
ev_io_stop(io_cookie->loop, &evt->ev.io);
(void)sock;
@@ -272,7 +272,7 @@ static int lcb_io_update_timer(struct lcb_io_opt_st *iops,
short which,
void *cb_data))
{
- struct libev_cookie *io_cookie = iops->cookie;
+ struct libev_cookie *io_cookie = iops->v.v0.cookie;
struct libev_event *evt = timer;
#ifdef HAVE_LIBEV4
@@ -295,7 +295,7 @@ static int lcb_io_update_timer(struct lcb_io_opt_st *iops,
static void lcb_io_delete_timer(struct lcb_io_opt_st *iops,
void *event)
{
- struct libev_cookie *io_cookie = iops->cookie;
+ struct libev_cookie *io_cookie = iops->v.v0.cookie;
struct libev_event *evt = event;
ev_timer_stop(io_cookie->loop, &evt->ev.timer);
}
@@ -309,7 +309,7 @@ static void lcb_io_destroy_timer(struct lcb_io_opt_st *iops,
static void lcb_io_stop_event_loop(struct lcb_io_opt_st *iops)
{
- struct libev_cookie *io_cookie = iops->cookie;
+ struct libev_cookie *io_cookie = iops->v.v0.cookie;
#ifdef HAVE_LIBEV4
ev_break(io_cookie->loop, EVBREAK_ONE);
#else
@@ -319,7 +319,7 @@ static void lcb_io_stop_event_loop(struct lcb_io_opt_st *iops)
static void lcb_io_run_event_loop(struct lcb_io_opt_st *iops)
{
- struct libev_cookie *io_cookie = iops->cookie;
+ struct libev_cookie *io_cookie = iops->v.v0.cookie;
#ifdef HAVE_LIBEV4
ev_run(io_cookie->loop, 0);
#else
@@ -329,7 +329,7 @@ static void lcb_io_run_event_loop(struct lcb_io_opt_st *iops)
static void lcb_destroy_io_opts(struct lcb_io_opt_st *iops)
{
- struct libev_cookie *io_cookie = iops->cookie;
+ struct libev_cookie *io_cookie = iops->v.v0.cookie;
if (io_cookie->allocated) {
ev_loop_destroy(io_cookie->loop);
}
@@ -349,28 +349,28 @@ lcb_error_t lcb_create_libev_io_opts(lcb_io_opt_t *io, struct ev_loop *loop)
}
/* setup io iops! */
- ret->version = 1;
- ret->dlhandle = NULL;
- ret->recv = lcb_io_recv;
- ret->send = lcb_io_send;
- ret->recvv = lcb_io_recvv;
- ret->sendv = lcb_io_sendv;
- ret->socket = lcb_io_socket;
- ret->close = lcb_io_close;
- ret->connect = lcb_io_connect;
- ret->delete_event = lcb_io_delete_event;
- ret->destroy_event = lcb_io_destroy_event;
- ret->create_event = lcb_io_create_event;
- ret->update_event = lcb_io_update_event;
-
- ret->delete_timer = lcb_io_delete_timer;
- ret->destroy_timer = lcb_io_destroy_timer;
- ret->create_timer = lcb_io_create_event;
- ret->update_timer = lcb_io_update_timer;
-
- ret->run_event_loop = lcb_io_run_event_loop;
- ret->stop_event_loop = lcb_io_stop_event_loop;
- ret->destructor = lcb_destroy_io_opts;
+ ret->version = 0;
+ ret->v.v0.dlhandle = NULL;
+ ret->v.v0.recv = lcb_io_recv;
+ ret->v.v0.send = lcb_io_send;
+ ret->v.v0.recvv = lcb_io_recvv;
+ ret->v.v0.sendv = lcb_io_sendv;
+ ret->v.v0.socket = lcb_io_socket;
+ ret->v.v0.close = lcb_io_close;
+ ret->v.v0.connect = lcb_io_connect;
+ ret->v.v0.delete_event = lcb_io_delete_event;
+ ret->v.v0.destroy_event = lcb_io_destroy_event;
+ ret->v.v0.create_event = lcb_io_create_event;
+ ret->v.v0.update_event = lcb_io_update_event;
+
+ ret->v.v0.delete_timer = lcb_io_delete_timer;
+ ret->v.v0.destroy_timer = lcb_io_destroy_timer;
+ ret->v.v0.create_timer = lcb_io_create_event;
+ ret->v.v0.update_timer = lcb_io_update_timer;
+
+ ret->v.v0.run_event_loop = lcb_io_run_event_loop;
+ ret->v.v0.stop_event_loop = lcb_io_stop_event_loop;
+ ret->v.v0.destructor = lcb_destroy_io_opts;
if (loop == NULL) {
if ((cookie->loop = ev_loop_new(EVFLAG_AUTO | EVFLAG_NOENV)) == NULL) {
@@ -383,7 +383,7 @@ lcb_error_t lcb_create_libev_io_opts(lcb_io_opt_t *io, struct ev_loop *loop)
cookie->loop = loop;
cookie->allocated = 0;
}
- ret->cookie = cookie;
+ ret->v.v0.cookie = cookie;
*io = ret;
return LCB_SUCCESS;
View
86 plugins/io/libevent/plugin-libevent.c
@@ -108,7 +108,7 @@ static lcb_ssize_t lcb_io_recv(struct lcb_io_opt_st *iops,
{
lcb_ssize_t ret = recv(sock, buffer, len, flags);
if (ret < 0) {
- iops->error = errno;
+ iops->v.v0.error = errno;
}
return ret;
}
@@ -135,7 +135,7 @@ static lcb_ssize_t lcb_io_recvv(struct lcb_io_opt_st *iops,
ret = recvmsg(sock, &msg, 0);
if (ret < 0) {
- iops->error = errno;
+ iops->v.v0.error = errno;
}
return ret;
@@ -149,7 +149,7 @@ static lcb_ssize_t lcb_io_send(struct lcb_io_opt_st *iops,
{
lcb_ssize_t ret = send(sock, msg, len, flags);
if (ret < 0) {
- iops->error = errno;
+ iops->v.v0.error = errno;
}
return ret;
}
@@ -176,7 +176,7 @@ static lcb_ssize_t lcb_io_sendv(struct lcb_io_opt_st *iops,
ret = sendmsg(sock, &msg, 0);
if (ret < 0) {
- iops->error = errno;
+ iops->v.v0.error = errno;
}
return ret;
}
@@ -188,12 +188,12 @@ static lcb_socket_t lcb_io_socket(struct lcb_io_opt_st *iops,
{
lcb_socket_t sock = socket(domain, type, protocol);
if (sock == INVALID_SOCKET) {
- iops->error = errno;
+ iops->v.v0.error = errno;
} else {
if (evutil_make_socket_nonblocking(sock) != 0) {
int error = errno;
- iops->close(iops, sock);
- iops->error = error;
+ iops->v.v0.close(iops, sock);
+ iops->v.v0.error = error;
sock = INVALID_SOCKET;
}
}
@@ -215,14 +215,14 @@ static int lcb_io_connect(struct lcb_io_opt_st *iops,
{
int ret = connect(sock, name, (socklen_t)namelen);
if (ret < 0) {
- iops->error = errno;
+ iops->v.v0.error = errno;
}
return ret;
}
static void *lcb_io_create_event(struct lcb_io_opt_st *iops)
{
- return event_new(((struct libevent_cookie *)iops->cookie)->base,
+ return event_new(((struct libevent_cookie *)iops->v.v0.cookie)->base,
INVALID_SOCKET, 0, NULL, NULL);
}
@@ -246,7 +246,7 @@ static int lcb_io_update_event(struct lcb_io_opt_st *iops,
event_del(event);
}
- event_assign(event, ((struct libevent_cookie *)iops->cookie)->base, sock, flags, handler, cb_data);
+ event_assign(event, ((struct libevent_cookie *)iops->v.v0.cookie)->base, sock, flags, handler, cb_data);
return event_add(event, NULL);
}
@@ -256,9 +256,9 @@ static void lcb_io_delete_timer(struct lcb_io_opt_st *iops,
{
(void)iops;
if (event_pending(event, EV_TIMEOUT, 0) != 0 && event_del(event) == -1) {
- iops->error = EINVAL;
+ iops->v.v0.error = EINVAL;
}
- event_assign(event, ((struct libevent_cookie *)iops->cookie)->base, -1, 0, NULL, NULL);
+ event_assign(event, ((struct libevent_cookie *)iops->v.v0.cookie)->base, -1, 0, NULL, NULL);
}
static int lcb_io_update_timer(struct lcb_io_opt_st *iops,
@@ -281,7 +281,7 @@ static int lcb_io_update_timer(struct lcb_io_opt_st *iops,
event_del(timer);
}
- event_assign(timer, ((struct libevent_cookie *)iops->cookie)->base, -1, flags, handler, cb_data);
+ event_assign(timer, ((struct libevent_cookie *)iops->v.v0.cookie)->base, -1, flags, handler, cb_data);
tmo.tv_sec = usec / 1000000;
tmo.tv_usec = usec % 1000000;
return event_add(timer, &tmo);
@@ -304,27 +304,27 @@ static void lcb_io_delete_event(struct lcb_io_opt_st *iops,
(void)iops;
(void)sock;
if (event_del(event) == -1) {
- iops->error = EINVAL;
+ iops->v.v0.error = EINVAL;
}
- event_assign(event, ((struct libevent_cookie *)iops->cookie)->base, -1, 0, NULL, NULL);
+ event_assign(event, ((struct libevent_cookie *)iops->v.v0.cookie)->base, -1, 0, NULL, NULL);
}
static void lcb_io_stop_event_loop(struct lcb_io_opt_st *iops)
{
- event_base_loopbreak(((struct libevent_cookie *)iops->cookie)->base);
+ event_base_loopbreak(((struct libevent_cookie *)iops->v.v0.cookie)->base);
}
static void lcb_io_run_event_loop(struct lcb_io_opt_st *iops)
{
- event_base_loop(((struct libevent_cookie *)iops->cookie)->base, 0);
+ event_base_loop(((struct libevent_cookie *)iops->v.v0.cookie)->base, 0);
}
static void lcb_destroy_io_opts(struct lcb_io_opt_st *iops)
{
- if (((struct libevent_cookie *)iops->cookie)->allocated) {
- event_base_free(((struct libevent_cookie *)iops->cookie)->base);
+ if (((struct libevent_cookie *)iops->v.v0.cookie)->allocated) {
+ event_base_free(((struct libevent_cookie *)iops->v.v0.cookie)->base);
}
- free(iops->cookie);
+ free(iops->v.v0.cookie);
free(iops);
}
@@ -340,28 +340,28 @@ lcb_error_t lcb_create_libevent_io_opts(lcb_io_opt_t *io, struct event_base *bas
}
/* setup io iops! */
- ret->version = 1;
- ret->dlhandle = NULL;
- ret->recv = lcb_io_recv;
- ret->send = lcb_io_send;
- ret->recvv = lcb_io_recvv;
- ret->sendv = lcb_io_sendv;
- ret->socket = lcb_io_socket;
- ret->close = lcb_io_close;
- ret->connect = lcb_io_connect;
- ret->delete_event = lcb_io_delete_event;
- ret->destroy_event = lcb_io_destroy_event;
- ret->create_event = lcb_io_create_event;
- ret->update_event = lcb_io_update_event;
-
- ret->delete_timer = lcb_io_delete_timer;
- ret->destroy_timer = lcb_io_destroy_event;
- ret->create_timer = lcb_io_create_event;
- ret->update_timer = lcb_io_update_timer;
-
- ret->run_event_loop = lcb_io_run_event_loop;
- ret->stop_event_loop = lcb_io_stop_event_loop;
- ret->destructor = lcb_destroy_io_opts;
+ ret->version = 0;
+ ret->v.v0.dlhandle = NULL;
+ ret->v.v0.recv = lcb_io_recv;
+ ret->v.v0.send = lcb_io_send;
+ ret->v.v0.recvv = lcb_io_recvv;
+ ret->v.v0.sendv = lcb_io_sendv;
+ ret->v.v0.socket = lcb_io_socket;
+ ret->v.v0.close = lcb_io_close;
+ ret->v.v0.connect = lcb_io_connect;
+ ret->v.v0.delete_event = lcb_io_delete_event;
+ ret->v.v0.destroy_event = lcb_io_destroy_event;
+ ret->v.v0.create_event = lcb_io_create_event;
+ ret->v.v0.update_event = lcb_io_update_event;
+
+ ret->v.v0.delete_timer = lcb_io_delete_timer;
+ ret->v.v0.destroy_timer = lcb_io_destroy_event;
+ ret->v.v0.create_timer = lcb_io_create_event;
+ ret->v.v0.update_timer = lcb_io_update_timer;
+
+ ret->v.v0.run_event_loop = lcb_io_run_event_loop;
+ ret->v.v0.stop_event_loop = lcb_io_stop_event_loop;
+ ret->v.v0.destructor = lcb_destroy_io_opts;
if (base == NULL) {
if ((cookie->base = event_base_new()) == NULL) {
@@ -374,7 +374,7 @@ lcb_error_t lcb_create_libevent_io_opts(lcb_io_opt_t *io, struct event_base *bas
cookie->base = base;
cookie->allocated = 0;
}
- ret->cookie = cookie;
+ ret->v.v0.cookie = cookie;
*io = ret;
return LCB_SUCCESS;
View
22 src/event.c
@@ -35,9 +35,9 @@ static int do_fill_input_buffer(lcb_server_t *c)
ringbuffer_get_iov(&c->input, RINGBUFFER_WRITE, iov);
- nr = c->instance->io->recvv(c->instance->io, c->sock, iov, 2);
+ nr = c->instance->io->v.v0.recvv(c->instance->io, c->sock, iov, 2);
if (nr == -1) {
- switch (c->instance->io->error) {
+ switch (c->instance->io->v.v0.error) {
case EINTR:
break;
case EWOULDBLOCK:
@@ -253,9 +253,9 @@ static int do_send_data(lcb_server_t *c)
struct lcb_iovec_st iov[2];
lcb_ssize_t nw;
ringbuffer_get_iov(&c->output, RINGBUFFER_READ, iov);
- nw = c->instance->io->sendv(c->instance->io, c->sock, iov, 2);
+ nw = c->instance->io->v.v0.sendv(c->instance->io, c->sock, iov, 2);
if (nw == -1) {
- switch (c->instance->io->error) {
+ switch (c->instance->io->v.v0.error) {
case EINTR:
/* retry */
break;
@@ -313,13 +313,13 @@ void lcb_server_event_handler(lcb_socket_t sock, short which, void *arg)
}
if (c->output.nbytes == 0) {
- c->instance->io->update_event(c->instance->io, c->sock,
- c->event, LCB_READ_EVENT,
- c, lcb_server_event_handler);
+ c->instance->io->v.v0.update_event(c->instance->io, c->sock,
+ c->event, LCB_READ_EVENT,
+ c, lcb_server_event_handler);
} else {
- c->instance->io->update_event(c->instance->io, c->sock,
- c->event, LCB_RW_EVENT,
- c, lcb_server_event_handler);
+ c->instance->io->v.v0.update_event(c->instance->io, c->sock,
+ c->event, LCB_RW_EVENT,
+ c, lcb_server_event_handler);
}
lcb_maybe_breakout(c->instance);
@@ -348,7 +348,7 @@ void lcb_maybe_breakout(lcb_t instance)
if (!lcb_has_data_in_buffers(instance)
&& hashset_num_items(instance->timers) == 0) {
instance->wait = 0;
- instance->io->stop_event_loop(instance->io);
+ instance->io->v.v0.stop_event_loop(instance->io);
}
}
}
View
62 src/http.c
@@ -34,10 +34,10 @@ void lcb_http_request_destroy(lcb_http_request_t req)
if (req) {
if (req->io) {
if (req->event) {
- req->io->destroy_event(req->io, req->event);
+ req->io->v.v0.destroy_event(req->io, req->event);
}
if (req->sock != INVALID_SOCKET) {
- req->io->close(req->io, req->sock);
+ req->io->v.v0.close(req->io, req->sock);
}
}
if (req->root_ai) {
@@ -204,9 +204,9 @@ static int request_do_fill_input_buffer(lcb_http_request_t req)
ringbuffer_get_iov(&req->input, RINGBUFFER_WRITE, iov);
- nr = req->io->recvv(req->io, req->sock, iov, 2);
+ nr = req->io->v.v0.recvv(req->io, req->sock, iov, 2);
if (nr == -1) {
- switch (req->io->error) {
+ switch (req->io->v.v0.error) {
case EINTR:
break;
case EWOULDBLOCK:
@@ -276,9 +276,9 @@ static int request_do_write(lcb_http_request_t req)
lcb_http_resp_t resp;
ringbuffer_get_iov(&req->output, RINGBUFFER_READ, iov);
- nw = req->io->sendv(req->io, req->sock, iov, 2);
+ nw = req->io->v.v0.sendv(req->io, req->sock, iov, 2);
if (nw == -1) {
- switch (req->io->error) {
+ switch (req->io->v.v0.error) {
case EINTR:
/* retry */
break;
@@ -310,9 +310,9 @@ static void request_event_handler(lcb_socket_t sock, short which, void *arg)
if (which & LCB_READ_EVENT) {
rv = request_do_read(req);
if (rv > 0) {
- instance->io->update_event(instance->io, req->sock,
- req->event, LCB_READ_EVENT,
- req, request_event_handler);
+ instance->io->v.v0.update_event(instance->io, req->sock,
+ req->event, LCB_READ_EVENT,
+ req, request_event_handler);
} else if (rv < 0) {
setup_lcb_http_resp_t(&resp, 0, req->path, req->npath,
NULL, NULL, 0);
@@ -334,18 +334,18 @@ static void request_event_handler(lcb_socket_t sock, short which, void *arg)
return;
}
if (req->output.nbytes == 0) {
- instance->io->update_event(instance->io, req->sock,
- req->event, LCB_READ_EVENT,
- req, request_event_handler);
+ instance->io->v.v0.update_event(instance->io, req->sock,
+ req->event, LCB_READ_EVENT,
+ req, request_event_handler);
} else {
- instance->io->update_event(instance->io, req->sock,
- req->event, LCB_WRITE_EVENT,
- req, request_event_handler);
+ instance->io->v.v0.update_event(instance->io, req->sock,
+ req->event, LCB_WRITE_EVENT,
+ req, request_event_handler);
}
}
if (instance->wait && hashset_num_items(server->http_requests) == 0) {
instance->wait = 0;
- instance->io->stop_event_loop(instance->io);
+ instance->io->v.v0.stop_event_loop(instance->io);
}
/* Make it known that this was a success. */
lcb_error_handler(instance, LCB_SUCCESS, NULL);
@@ -364,7 +364,7 @@ static void request_connect_handler(lcb_socket_t sock, short which, void *arg)
static void request_connected(lcb_http_request_t req)
{
- req->io->update_event(req->io, req->sock,
+ req->io->v.v0.update_event(req->io, req->sock,
req->event, LCB_WRITE_EVENT,
req, request_event_handler);
}
@@ -392,28 +392,28 @@ static lcb_error_t request_connect(lcb_http_request_t req)
}
retry = 0;
- if (req->io->connect(req->io,
- req->sock,
- req->curr_ai->ai_addr,
- (unsigned int)req->curr_ai->ai_addrlen) == 0) {
+ if (req->io->v.v0.connect(req->io,
+ req->sock,
+ req->curr_ai->ai_addr,
+ (unsigned int)req->curr_ai->ai_addrlen) == 0) {
/* connected */
request_connected(req);
return LCB_SUCCESS;
} else {
- switch (lcb_connect_status(req->io->error)) {
+ switch (lcb_connect_status(req->io->v.v0.error)) {
case LCB_CONNECT_EINTR:
retry = 1;
break;
case LCB_CONNECT_EISCONN:
request_connected(req);
return LCB_SUCCESS;
case LCB_CONNECT_EINPROGRESS: /*first call to connect*/
- req->io->update_event(req->io,
- req->sock,
- req->event,
- LCB_WRITE_EVENT,
- req,
- request_connect_handler);
+ req->io->v.v0.update_event(req->io,
+ req->sock,
+ req->event,
+ LCB_WRITE_EVENT,
+ req,
+ request_connect_handler);
return LCB_SUCCESS;
case LCB_CONNECT_EALREADY: /* Subsequent calls to connect */
return LCB_SUCCESS;
@@ -422,8 +422,8 @@ static lcb_error_t request_connect(lcb_http_request_t req)
if (req->curr_ai->ai_next) {
retry = 1;
req->curr_ai = req->curr_ai->ai_next;
- req->io->delete_event(req->io, req->sock, req->event);
- req->io->close(req->io, req->sock);
+ req->io->v.v0.delete_event(req->io, req->sock, req->event);
+ req->io->v.v0.close(req->io, req->sock);
req->sock = INVALID_SOCKET;
break;
} /* Else, we fallthrough */
@@ -748,7 +748,7 @@ lcb_error_t lcb_make_http_request(lcb_t instance,
{
/* Get server socket address */
int err;
- req->event = req->io->create_event(req->io);
+ req->event = req->io->v.v0.create_event(req->io);
err = lcb_getaddrinfo(instance, req->host, req->port, &req->root_ai);
req->curr_ai = req->root_ai;
if (err != 0) {
View
71 src/instance.c
@@ -237,7 +237,7 @@ lcb_error_t lcb_create(lcb_t *instance,
obj->last_error = LCB_SUCCESS;
/* setup io iops! */
obj->io = io;
- obj->timeout.event = obj->io->create_timer(obj->io);
+ obj->timeout.event = obj->io->v.v0.create_timer(obj->io);
if (obj->timeout.event == NULL) {
return LCB_CLIENT_ENOMEM;
}
@@ -272,10 +272,10 @@ lcb_error_t lcb_create(lcb_t *instance,
static void release_socket(lcb_t instance)
{
if (instance->sock != INVALID_SOCKET) {
- instance->io->delete_event(instance->io, instance->sock, instance->event);
- instance->io->destroy_event(instance->io, instance->event);
+ instance->io->v.v0.delete_event(instance->io, instance->sock, instance->event);
+ instance->io->v.v0.destroy_event(instance->io, instance->event);
instance->event = NULL;
- instance->io->close(instance->io, instance->sock);
+ instance->io->v.v0.close(instance->io, instance->sock);
instance->sock = INVALID_SOCKET;
}
}
@@ -296,8 +296,8 @@ void lcb_destroy(lcb_t instance)
release_socket(instance);
if (instance->timeout.event != NULL) {
- instance->io->delete_timer(instance->io, instance->timeout.event);
- instance->io->destroy_timer(instance->io, instance->timeout.event);
+ instance->io->v.v0.delete_timer(instance->io, instance->timeout.event);
+ instance->io->v.v0.destroy_timer(instance->io, instance->timeout.event);
instance->timeout.event = NULL;
}
@@ -318,13 +318,10 @@ void lcb_destroy(lcb_t instance)
if (instance->io) {
#ifndef _WIN32
- void *dlhandle = NULL;
- if (instance->io->version == 1) {
- dlhandle = instance->io->dlhandle;
- }
+ void *dlhandle = instance->io->v.v0.dlhandle;
#endif
- if (instance->io->destructor) {
- instance->io->destructor(instance->io);
+ if (instance->io->v.v0.destructor) {
+ instance->io->v.v0.destructor(instance->io);
}
#ifndef _WIN32
if (dlhandle) {
@@ -809,7 +806,7 @@ static void lcb_instance_connerr(lcb_t instance,
if (!instance->vbucket_config) {
/* Initial connection, no pending commands, and connect timer */
- instance->io->delete_timer(instance->io, instance->timeout.event);
+ instance->io->v.v0.delete_timer(instance->io, instance->timeout.event);
} else {
lcb_size_t ii;
for (ii = 0; ii < instance->nservers; ++ii) {
@@ -840,24 +837,24 @@ static void vbucket_stream_handler(lcb_socket_t sock, short which, void *arg)
if ((which & LCB_WRITE_EVENT) == LCB_WRITE_EVENT) {
lcb_ssize_t nw;
- nw = instance->io->send(instance->io, instance->sock,
- instance->http_uri + instance->n_http_uri_sent,
- strlen(instance->http_uri) - instance->n_http_uri_sent,
- 0);
+ nw = instance->io->v.v0.send(instance->io, instance->sock,
+ instance->http_uri + instance->n_http_uri_sent,
+ strlen(instance->http_uri) - instance->n_http_uri_sent,
+ 0);
if (nw == -1) {
lcb_error_handler(instance, LCB_NETWORK_ERROR,
"Failed to send data to REST server");
- instance->io->delete_event(instance->io, instance->sock,
- instance->event);
+ instance->io->v.v0.delete_event(instance->io, instance->sock,
+ instance->event);
return;
}
instance->n_http_uri_sent += (lcb_size_t)nw;
if (instance->n_http_uri_sent == strlen(instance->http_uri)) {
- instance->io->update_event(instance->io, instance->sock,
- instance->event, LCB_READ_EVENT,
- instance, vbucket_stream_handler);
+ instance->io->v.v0.update_event(instance->io, instance->sock,
+ instance->event, LCB_READ_EVENT,
+ instance, vbucket_stream_handler);
}
}
@@ -873,17 +870,17 @@ static void vbucket_stream_handler(lcb_socket_t sock, short which, void *arg)
}
avail = (buffer->size - buffer->avail);
- nr = instance->io->recv(instance->io, instance->sock,
- buffer->data + buffer->avail, avail, 0);
+ nr = instance->io->v.v0.recv(instance->io, instance->sock,
+ buffer->data + buffer->avail, avail, 0);
if (nr < 0) {
- switch (instance->io->error) {
+ switch (instance->io->v.v0.error) {
case EINTR:
break;
case EWOULDBLOCK:
return ;
default:
lcb_error_handler(instance, LCB_NETWORK_ERROR,
- strerror(instance->io->error));
+ strerror(instance->io->v.v0.error));
return ;
}
} else if (nr == 0) {
@@ -952,9 +949,9 @@ static void vbucket_stream_handler(lcb_socket_t sock, short which, void *arg)
static void lcb_instance_connected(lcb_t instance)
{
instance->backup_idx = 0;
- instance->io->update_event(instance->io, instance->sock,
- instance->event, LCB_RW_EVENT,
- instance, vbucket_stream_handler);
+ instance->io->v.v0.update_event(instance->io, instance->sock,
+ instance->event, LCB_RW_EVENT,
+ instance, vbucket_stream_handler);
}
static void lcb_instance_connect_handler(lcb_socket_t sock,
@@ -991,14 +988,14 @@ static void lcb_instance_connect_handler(lcb_socket_t sock,
}
retry = 0;
- if (instance->io->connect(instance->io,
- instance->sock,
- instance->curr_ai->ai_addr,
- (unsigned int)instance->curr_ai->ai_addrlen) == 0) {
+ if (instance->io->v.v0.connect(instance->io,
+ instance->sock,
+ instance->curr_ai->ai_addr,
+ (unsigned int)instance->curr_ai->ai_addrlen) == 0) {
lcb_instance_connected(instance);
return ;
} else {
- save_errno = instance->io->error;
+ save_errno = instance->io->v.v0.error;
connstatus = lcb_connect_status(save_errno);
switch (connstatus) {
@@ -1009,7 +1006,7 @@ static void lcb_instance_connect_handler(lcb_socket_t sock,
lcb_instance_connected(instance);
return ;
case LCB_CONNECT_EINPROGRESS:
- instance->io->update_event(instance->io,
+ instance->io->v.v0.update_event(instance->io,
instance->sock,
instance->event,
LCB_WRITE_EVENT,
@@ -1033,7 +1030,7 @@ static void lcb_instance_connect_handler(lcb_socket_t sock,
} else {
char errinfo[1024];
snprintf(errinfo, sizeof(errinfo), "Connection failed: %s",
- strerror(instance->io->error));
+ strerror(instance->io->v.v0.error));
lcb_instance_connerr(instance, LCB_CONNECT_ERROR, errinfo);
return ;
}
@@ -1104,7 +1101,7 @@ lcb_error_t lcb_connect(lcb_t instance)
} while (error != 0);
instance->curr_ai = instance->ai;
- instance->event = instance->io->create_event(instance->io);
+ instance->event = instance->io->v.v0.create_event(instance->io);
instance->last_error = LCB_SUCCESS;
lcb_instance_connect_handler(INVALID_SOCKET, 0, instance);
View
4 src/iofactory.c
@@ -207,9 +207,7 @@ static lcb_error_t create_v1(lcb_io_opt_t *io,
}
return LCB_CLIENT_ENOMEM;
} else {
- if ((*io)->version > 0) {
- (*io)->dlhandle = plugin.dlhandle;
- }
+ (*io)->v.v0.dlhandle = plugin.dlhandle;
}
return LCB_SUCCESS;
View
68 src/server.c
@@ -297,9 +297,9 @@ lcb_error_t lcb_failout_server(lcb_server_t *server,
server->connected = 0;
if (server->sock != INVALID_SOCKET) {
- server->instance->io->delete_event(server->instance->io, server->sock,
- server->event);
- server->instance->io->close(server->instance->io, server->sock);
+ server->instance->io->v.v0.delete_event(server->instance->io, server->sock,
+ server->event);
+ server->instance->io->v.v0.close(server->instance->io, server->sock);
server->sock = INVALID_SOCKET;
}
/* reset address info for future attempts */
@@ -329,14 +329,14 @@ void lcb_server_destroy(lcb_server_t *server)
}
/* Delete the event structure itself */
- server->instance->io->destroy_event(server->instance->io,
- server->event);
+ server->instance->io->v.v0.destroy_event(server->instance->io,
+ server->event);
- server->instance->io->destroy_timer(server->instance->io,
- server->timer);
+ server->instance->io->v.v0.destroy_timer(server->instance->io,
+ server->timer);
if (server->sock != INVALID_SOCKET) {
- server->instance->io->close(server->instance->io, server->sock);
+ server->instance->io->v.v0.close(server->instance->io, server->sock);
}
if (server->root_ai != NULL) {
@@ -468,9 +468,9 @@ void lcb_server_connected(lcb_server_t *server)
} else {
/* Set the correct event handler */
- server->instance->io->update_event(server->instance->io, server->sock,
- server->event, LCB_READ_EVENT,
- server, lcb_server_event_handler);
+ server->instance->io->v.v0.update_event(server->instance->io, server->sock,
+ server->event, LCB_READ_EVENT,
+ server, lcb_server_event_handler);
}
}
@@ -533,16 +533,16 @@ static void server_connect(lcb_server_t *server)
}
retry = 0;
- if (server->instance->io->connect(server->instance->io,
- server->sock,
- server->curr_ai->ai_addr,
- (unsigned int)server->curr_ai->ai_addrlen) == 0) {
+ if (server->instance->io->v.v0.connect(server->instance->io,
+ server->sock,
+ server->curr_ai->ai_addr,
+ (unsigned int)server->curr_ai->ai_addrlen) == 0) {
/* connected */
socket_connected(server);
return ;
} else {
lcb_connect_status_t connstatus =
- lcb_connect_status(server->instance->io->error);
+ lcb_connect_status(server->instance->io->v.v0.error);
switch (connstatus) {
case LCB_CONNECT_EINTR:
retry = 1;
@@ -551,12 +551,12 @@ static void server_connect(lcb_server_t *server)
socket_connected(server);
return ;
case LCB_CONNECT_EINPROGRESS: /*first call to connect*/
- server->instance->io->update_event(server->instance->io,
- server->sock,
- server->event,
- LCB_WRITE_EVENT,
- server,
- server_connect_handler);
+ server->instance->io->v.v0.update_event(server->instance->io,
+ server->sock,
+ server->event,
+ LCB_WRITE_EVENT,
+ server,
+ server_connect_handler);
return ;
case LCB_CONNECT_EALREADY: /* Subsequent calls to connect */
return ;
@@ -565,10 +565,10 @@ static void server_connect(lcb_server_t *server)
if (server->curr_ai->ai_next) {
retry = 1;
server->curr_ai = server->curr_ai->ai_next;
- server->instance->io->delete_event(server->instance->io,
- server->sock,
- server->event);
- server->instance->io->close(server->instance->io, server->sock);
+ server->instance->io->v.v0.delete_event(server->instance->io,
+ server->sock,
+ server->event);
+ server->instance->io->v.v0.close(server->instance->io, server->sock);
server->sock = INVALID_SOCKET;
break;
} /* Else, we fallthrough */
@@ -604,7 +604,7 @@ void lcb_server_initialize(lcb_server_t *server, int servernum)
n = vbucket_config_get_rest_api_server(server->instance->vbucket_config,
servernum);
server->rest_api_server = strdup(n);
- server->event = server->instance->io->create_event(server->instance->io);
+ server->event = server->instance->io->v.v0.create_event(server->instance->io);
assert(server->event);
error = lcb_getaddrinfo(server->instance, server->hostname, server->port,
&server->root_ai);
@@ -613,7 +613,7 @@ void lcb_server_initialize(lcb_server_t *server, int servernum)
if (error != 0) {
server->curr_ai = server->root_ai = NULL;
}
- server->timer = server->instance->io->create_timer(server->instance->io);
+ server->timer = server->instance->io->v.v0.create_timer(server->instance->io);
assert(server->timer);
server->sasl_conn = NULL;
@@ -623,12 +623,12 @@ void lcb_server_send_packets(lcb_server_t *server)
{
if (server->pending.nbytes > 0 || server->output.nbytes > 0) {
if (server->connected) {
- server->instance->io->update_event(server->instance->io,
- server->sock,
- server->event,
- LCB_RW_EVENT,
- server,
- lcb_server_event_handler);
+ server->instance->io->v.v0.update_event(server->instance->io,
+ server->sock,
+ server->event,
+ LCB_RW_EVENT,
+ server,
+ lcb_server_event_handler);
} else {
server_connect(server);
}
View
8 src/timeout.c
@@ -48,9 +48,9 @@ void lcb_update_server_timer(lcb_server_t *server)
lcb_t instance = server->instance;
if (server->timer) {
- instance->io->delete_timer(instance->io, server->timer);
+ instance->io->v.v0.delete_timer(instance->io, server->timer);
}
- instance->io->update_timer(instance->io, server->timer,
- instance->timeout.usec, server,
- lcb_server_timeout_handler);
+ instance->io->v.v0.update_timer(instance->io, server->timer,
+ instance->timeout.usec, server,
+ lcb_server_timeout_handler);
}
View
10 src/timer.c
@@ -23,7 +23,7 @@ static void timer_callback(lcb_socket_t sock, short which, void *arg)
lcb_t instance = timer->instance;
timer->callback(timer, instance, timer->cookie);
if (hashset_is_member(instance->timers, timer) && !timer->periodic) {
- instance->io->delete_timer(instance->io, timer->event);
+ instance->io->v.v0.delete_timer(instance->io, timer->event);
lcb_timer_destroy(instance, timer);
}
lcb_maybe_breakout(timer->instance);
@@ -56,13 +56,13 @@ lcb_timer_t lcb_timer_create(lcb_t instance,
tmr->cookie = command_cookie;
tmr->usec = usec;
tmr->periodic = periodic;
- tmr->event = instance->io->create_timer(instance->io);
+ tmr->event = instance->io->v.v0.create_timer(instance->io);
if (tmr->event == NULL) {
free(tmr);
*error = lcb_synchandler_return(instance, LCB_CLIENT_ENOMEM);
return NULL;
}
- instance->io->update_timer(instance->io, tmr->event, tmr->usec,
+ instance->io->v.v0.update_timer(instance->io, tmr->event, tmr->usec,
tmr, timer_callback);
@@ -76,8 +76,8 @@ lcb_error_t lcb_timer_destroy(lcb_t instance, lcb_timer_t timer)
{
if (hashset_is_member(instance->timers, timer)) {
hashset_remove(instance->timers, timer);
- instance->io->delete_timer(instance->io, timer->event);
- instance->io->destroy_timer(instance->io, timer->event);
+ instance->io->v.v0.delete_timer(instance->io, timer->event);
+ instance->io->v.v0.destroy_timer(instance->io, timer->event);
free(timer);
}
return lcb_synchandler_return(instance, LCB_SUCCESS);
View
10 src/utilities.c
@@ -155,14 +155,14 @@ lcb_socket_t lcb_gai2sock(lcb_t instance, struct addrinfo **ai,
for (; *ai; *ai = (*ai)->ai_next) {
- ret = instance->io->socket(instance->io,
- (*ai)->ai_family,
- (*ai)->ai_socktype,
- (*ai)->ai_protocol);
+ ret = instance->io->v.v0.socket(instance->io,
+ (*ai)->ai_family,
+ (*ai)->ai_socktype,
+ (*ai)->ai_protocol);
if (ret != INVALID_SOCKET) {
return ret;
} else {
- *connerr = instance->io->error;
+ *connerr = instance->io->v.v0.error;
}
}
View
28 src/wait.c
@@ -23,8 +23,8 @@ static void breakout_vbucket_state_listener(lcb_server_t *server)
server->instance->vbucket_state_listener_last;
server->instance->vbucket_state_listener_last = NULL;
}
- server->instance->io->delete_timer(server->instance->io,
- server->instance->timeout.event);
+ server->instance->io->v.v0.delete_timer(server->instance->io,
+ server->instance->timeout.event);
lcb_maybe_breakout(server->instance);
}
@@ -38,14 +38,14 @@ static void initial_connect_timeout_handler(lcb_socket_t sock,
if (instance->sock != INVALID_SOCKET) {
/* Do we need to delete the event? */
- instance->io->delete_event(instance->io,
- instance->sock,
- instance->event);
- instance->io->close(instance->io, instance->sock);
+ instance->io->v.v0.delete_event(instance->io,
+ instance->sock,
+ instance->event);
+ instance->io->v.v0.close(instance->io, instance->sock);
instance->sock = INVALID_SOCKET;
}
- instance->io->delete_timer(instance->io, instance->timeout.event);
+ instance->io->v.v0.delete_timer(instance->io, instance->timeout.event);
instance->timeout.next = 0;
lcb_maybe_breakout(instance);
@@ -97,11 +97,11 @@ lcb_error_t lcb_wait(lcb_t instance)
instance->vbucket_state_listener = breakout_vbucket_state_listener;
/* Initial connection timeout */
- instance->io->update_timer(instance->io,
- instance->timeout.event,
- instance->timeout.usec,
- instance,
- initial_connect_timeout_handler);
+ instance->io->v.v0.update_timer(instance->io,
+ instance->timeout.event,
+ instance->timeout.usec,
+ instance,
+ initial_connect_timeout_handler);
}
if (instance->vbucket_config == NULL || lcb_has_data_in_buffers(instance)
|| hashset_num_items(instance->timers) > 0) {
@@ -110,7 +110,7 @@ lcb_error_t lcb_wait(lcb_t instance)
for (idx = 0; idx < instance->nservers; ++idx) {
lcb_update_server_timer(instance->servers + idx);
}
- instance->io->run_event_loop(instance->io);
+ instance->io->v.v0.run_event_loop(instance->io);
} else {
instance->wait = 0;
}
@@ -127,7 +127,7 @@ LIBCOUCHBASE_API
void lcb_breakout(lcb_t instance)
{
if (instance->wait) {
- instance->io->stop_event_loop(instance->io);
+ instance->io->v.v0.stop_event_loop(instance->io);
instance->wait = 0;
}
}
View
18 tests/config-test.c
@@ -42,7 +42,7 @@ static void error_callback(lcb_t instance,
static void vbucket_state_callback(lcb_server_t *server)
{
config_cnt++;
- server->instance->io->stop_event_loop(server->instance->io);
+ server->instance->io->v.v0.stop_event_loop(server->instance->io);
}
struct rvbuf {
@@ -60,7 +60,7 @@ static void store_callback(lcb_t instance,
struct rvbuf *rv = (struct rvbuf *)cookie;
rv->error = error;
store_cnt++;
- instance->io->stop_event_loop(instance->io);
+ instance->io->v.v0.stop_event_loop(instance->io);
(void)operation;
(void)resp;
@@ -77,7 +77,7 @@ static void get_callback(lcb_t instance,
rv->bytes = malloc(resp->v.v0.nbytes);
memcpy((void *)rv->bytes, resp->v.v0.bytes, resp->v.v0.nbytes);
rv->nbytes = resp->v.v0.nbytes;
- instance->io->stop_event_loop(instance->io);
+ instance->io->v.v0.stop_event_loop(instance->io);
(void)resp;
}
@@ -125,17 +125,17 @@ static void smoke_test(void)
err_exit("Failed to connect libcouchbase instance to server");
}
config_cnt = 0;
- io->run_event_loop(io);
+ io->v.v0.run_event_loop(io);
assert(config_cnt == 20);
config_cnt = 0;
failover_node(mock, 0, NULL);
- io->run_event_loop(io);
+ io->v.v0.run_event_loop(io);
assert(config_cnt == 19);
config_cnt = 0;
respawn_node(mock, 0, NULL);
- io->run_event_loop(io);
+ io->v.v0.run_event_loop(io);
assert(config_cnt == 20);
lcb_destroy(instance);
@@ -195,7 +195,7 @@ static void buffer_relocation_test(void)
if (lcb_connect(instance) != LCB_SUCCESS) {
err_exit("Failed to connect libcouchbase instance to server");
}
- io->run_event_loop(io);
+ io->v.v0.run_event_loop(io);
/* schedule SET operation */
@@ -221,7 +221,7 @@ static void buffer_relocation_test(void)
/* it should never return LCB_NOT_MY_VBUCKET */
while (config_cnt == 0 || store_cnt == 0) {
memset(&rv, 0, sizeof(rv));
- io->run_event_loop(io);
+ io->v.v0.run_event_loop(io);
assert(err != LCB_NOT_MY_VBUCKET);
}
@@ -232,7 +232,7 @@ static void buffer_relocation_test(void)
getcmd.v.v0.nkey = nkey;
err = lcb_get(instance, &rv, 1, getcmds);
assert(err == LCB_SUCCESS);
- io->run_event_loop(io);
+ io->v.v0.run_event_loop(io);
assert(rv.error == LCB_SUCCESS);
assert(memcmp(rv.bytes, "bar", 3) == 0);
free((void *)rv.bytes);
View
12 tests/mock-unit-test.cc
@@ -259,7 +259,7 @@ extern "C" {
ASSERT_EQ(LCB_SUCCESS, error);
timeout_seqno--;
if (timeout_stats_done && timeout_seqno == 0) {
- io->stop_event_loop(io);
+ io->v.v0.stop_event_loop(io);
}
}
@@ -316,7 +316,7 @@ TEST_F(MockUnitTest, testTimeout)
lcb_server_stats_cmd_t *commands[] = {&stat };
ASSERT_EQ(LCB_SUCCESS, lcb_server_stats(instance, io, 1, commands));
- io->run_event_loop(io);
+ io->v.v0.run_event_loop(io);
lcb_destroy(instance);
}
@@ -353,7 +353,7 @@ extern "C" {
struct rvbuf *rv = (struct rvbuf *)cookie;
rv->error = error;
lcb_io_opt_t io = (lcb_io_opt_t)lcb_get_cookie(instance);
- io->stop_event_loop(io);
+ io->v.v0.stop_event_loop(io);
}
static void df_store_callback2(lcb_t instance,
@@ -366,7 +366,7 @@ extern "C" {
rv->error = error;
rv->cas2 = resp->v.v0.cas;
lcb_io_opt_t io = (lcb_io_opt_t)lcb_get_cookie(instance);
- io->stop_event_loop(io);
+ io->v.v0.stop_event_loop(io);
}
static void df_get_callback(lcb_t instance,
@@ -410,7 +410,7 @@ TEST_F(MockUnitTest, testDoubleFreeError)
err = lcb_store(instance, &rv, 1, storecmds);
ASSERT_EQ(LCB_SUCCESS, err);
- io->run_event_loop(io);
+ io->v.v0.run_event_loop(io);
ASSERT_EQ(LCB_SUCCESS, rv.error);
/* run exercise
@@ -427,7 +427,7 @@ TEST_F(MockUnitTest, testDoubleFreeError)
err = lcb_get(instance, &rv, 1, getcmds);
ASSERT_EQ(LCB_SUCCESS, err);
rv.cas1 = rv.cas2 = 0;
- io->run_event_loop(io);
+ io->v.v0.run_event_loop(io);
ASSERT_EQ(LCB_SUCCESS, rv.error);
ASSERT_GT(rv.cas1, 0);
ASSERT_GT(rv.cas2, 0);
View
8 tests/serverops-unit-test.cc
@@ -141,7 +141,7 @@ extern "C" {
EXPECT_EQ(MockEnvironment::getInstance()->getNumNodes(), *counter);
lcb_io_opt_t io;
io = (lcb_io_opt_t)lcb_get_cookie(instance);
- io->stop_event_loop(io);
+ io->v.v0.stop_event_loop(io);
return;
} else if (verbosity_endpoint == NULL) {
verbosity_endpoint = strdup(resp->v.v0.server_endpoint);
@@ -159,7 +159,7 @@ extern "C" {
if (resp->v.v0.server_endpoint == NULL) {
lcb_io_opt_t io;
io = (lcb_io_opt_t)lcb_get_cookie(instance);
- io->stop_event_loop(io);
+ io->v.v0.stop_event_loop(io);
} else {
EXPECT_STREQ(verbosity_endpoint, resp->v.v0.server_endpoint);
}
@@ -184,7 +184,7 @@ TEST_F(ServeropsUnitTest, testVerbosity)
lcb_io_opt_t io;
io = (lcb_io_opt_t)lcb_get_cookie(instance);
- io->run_event_loop(io);
+ io->v.v0.run_event_loop(io);
EXPECT_EQ(MockEnvironment::getInstance()->getNumNodes(), counter);
EXPECT_NE((char *)NULL, verbosity_endpoint);
@@ -194,7 +194,7 @@ TEST_F(ServeropsUnitTest, testVerbosity)
lcb_verbosity_cmd_t cmd2(LCB_VERBOSITY_DEBUG, verbosity_endpoint);
lcb_verbosity_cmd_t *commands2[] = { &cmd2 };
EXPECT_EQ(LCB_SUCCESS, lcb_set_verbosity(instance, &counter, 1, commands2));
- io->run_event_loop(io);
+ io->v.v0.run_event_loop(io);
free((void *)verbosity_endpoint);
lcb_destroy(instance);
View
30 tests/smoke-test.c
@@ -137,7 +137,7 @@ static void store_callback(lcb_t instance,
rv->nkey = resp->v.v0.nkey;
rv->cas = resp->v.v0.cas;
assert(io);
- io->stop_event_loop(io);
+ io->v.v0.stop_event_loop(io);
(void)instance;
}
@@ -156,7 +156,7 @@ static void mstore_callback(lcb_t instance,
rv->counter--;
if (rv->counter <= 0) {
assert(io);
- io->stop_event_loop(io);
+ io->v.v0.stop_event_loop(io);
}
(void)instance;
}
@@ -177,7 +177,7 @@ static void get_callback(lcb_t instance,
rv->counter--;
if (rv->counter <= 0) {
assert(io);
- io->stop_event_loop(io);
+ io->v.v0.stop_event_loop(io);
}
(void)instance;
}
@@ -195,7 +195,7 @@ static void touch_callback(lcb_t instance,
rv->counter--;
if (rv->counter <= 0) {
assert(io);
- io->stop_event_loop(io);
+ io->v.v0.stop_event_loop(io);
}
(void)instance;
}
@@ -216,7 +216,7 @@ static void version_callback(lcb_t instance,
if (server_endpoint == NULL) {
assert(rv->counter == 0);
- io->stop_event_loop(io);
+ io->v.v0.stop_event_loop(io);
return;
}
@@ -248,7 +248,7 @@ static void test_set1(void)
(void)lcb_set_store_callback(session, store_callback);
err = lcb_store(session, &rv, 1, cmds);
assert(err == LCB_SUCCESS);
- io->run_event_loop(io);
+ io->v.v0.run_event_loop(io);
assert(rv.error == LCB_SUCCESS);
assert(rv.operation == LCB_SET);
assert(memcmp(rv.key, "foo", 3) == 0);
@@ -276,7 +276,7 @@ static void test_set2(void)
err = lcb_store(session, &rv, 1, cmds);
assert(err == LCB_SUCCESS);
}
- io->run_event_loop(io);
+ io->v.v0.run_event_loop(io);
assert(rv.errors == 0);
}
@@ -301,7 +301,7 @@ static void test_get1(void)
err = lcb_store(session, &rv, 1, storecmds);
assert(err == LCB_SUCCESS);
- io->run_event_loop(io);
+ io->v.v0.run_event_loop(io);
assert(rv.error == LCB_SUCCESS);
memset(&rv, 0, sizeof(rv));
@@ -310,7 +310,7 @@ static void test_get1(void)
getcmd.v.v0.nkey = strlen(getcmd.v.v0.key);
err = lcb_get(session, &rv, 1, getcmds);
assert(err == LCB_SUCCESS);
- io->run_event_loop(io);
+ io->v.v0.run_event_loop(io);
assert(rv.error == LCB_SUCCESS);
assert(rv.nbytes == strlen("bar"));
assert(memcmp(rv.bytes, "bar", 3) == 0);
@@ -351,7 +351,7 @@ static void test_get2(void)
storecmd.v.v0.operation = LCB_SET;
err = lcb_store(session, &rv, 1, storecmds);
assert(err == LCB_SUCCESS);
- io->run_event_loop(io);
+ io->v.v0.run_event_loop(io);
assert(rv.error == LCB_SUCCESS);
memset(&rv, 0, sizeof(rv));
@@ -366,7 +366,7 @@ static void test_get2(void)
rv.counter = 26;
err = lcb_get(session, &rv, 26, (const lcb_get_cmd_t * const *)getcmds);
assert(err == LCB_SUCCESS);
- io->run_event_loop(io);
+ io->v.v0.run_event_loop(io);
assert(rv.error == LCB_SUCCESS);
assert(rv.nbytes == nval);
assert(memcmp(rv.bytes, "bar", 3) == 0);
@@ -418,7 +418,7 @@ static void test_touch1(void)
storecmd.v.v0.operation = LCB_SET;
err = lcb_store(session, &rv, 1, storecmds);
assert(err == LCB_SUCCESS);
- io->run_event_loop(io);
+ io->v.v0.run_event_loop(io);
assert(rv.error == LCB_SUCCESS);
memset(&rv, 0, sizeof(rv));
@@ -433,7 +433,7 @@ static void test_touch1(void)
rv.counter = 26;
err = lcb_touch(session, &rv, 26, (const lcb_touch_cmd_t * const *)touchcmds);
assert(err == LCB_SUCCESS);
- io->run_event_loop(io);
+ io->v.v0.run_event_loop(io);
assert(rv.error == LCB_SUCCESS);
for (ii = 0; ii < 26; ii++) {
free(keys[ii]);
@@ -527,7 +527,7 @@ static void test_set3(void)
storecmd.v.v0.operation = LCB_SET;
err = lcb_store(session, &rv, 1, storecmds);
assert(err == LCB_SUCCESS);
- io->run_event_loop(io);
+ io->v.v0.run_event_loop(io);
assert(rv.error == LCB_SUCCESS);
assert(rv.operation == LCB_SET);
assert(memcmp(rv.key, "foo", 3) == 0);
@@ -550,7 +550,7 @@ static void test_version1(void)
rv.counter = total_node_count;
- io->run_event_loop(io);
+ io->v.v0.run_event_loop(io);
/* Ensure all version responses have been received */
assert(rv.counter == 0);

0 comments on commit 74f59f6

Please sign in to comment.
Something went wrong with that request. Please try again.