25 #include <citrusleaf/cf_ll.h>
31 #if defined(AS_USE_LIBEV)
33 #elif defined(AS_USE_LIBUV)
35 #elif defined(AS_USE_LIBEVENT)
36 #include <event2/event.h>
48 #define AS_ASYNC_STATE_UNREGISTERED 0
49 #define AS_ASYNC_STATE_TLS_CONNECT 1
50 #define AS_ASYNC_STATE_AUTH_WRITE 2
51 #define AS_ASYNC_STATE_AUTH_READ_HEADER 4
52 #define AS_ASYNC_STATE_AUTH_READ_BODY 8
53 #define AS_ASYNC_STATE_WRITE 16
54 #define AS_ASYNC_STATE_READ_HEADER 32
55 #define AS_ASYNC_STATE_READ_BODY 64
57 #define AS_ASYNC_AUTH_RETURN_CODE 1
59 #define AS_EVENT_CONNECTION_COMPLETE 0
60 #define AS_EVENT_CONNECTION_PENDING 1
61 #define AS_EVENT_CONNECTION_ERROR 2
63 #define AS_EVENT_QUEUE_INITIAL_CAPACITY 256
69 #if defined(AS_USE_LIBEV)
73 #elif defined(AS_USE_LIBUV)
80 #elif defined(AS_USE_LIBEVENT)
104 #if defined(AS_USE_LIBEV)
105 struct ev_timer timer;
106 #elif defined(AS_USE_LIBUV)
108 #elif defined(AS_USE_LIBEVENT)
146 typedef enum as_connection_status_e {
221 #if defined(AS_USE_LIBEV)
232 if (conn->socket.ctx) {
233 conn->socket.last_used = cf_get_seconds();
261 #elif defined(AS_USE_LIBUV)
269 if (uv_fileno((uv_handle_t*)&conn->socket, &fd) == 0) {
293 as_uv_timer_closed(uv_handle_t* handle);
300 uv_close((uv_handle_t*)&cmd->timer, as_uv_timer_closed);
311 #elif defined(AS_USE_LIBEVENT)
322 if (conn->socket.ctx) {
323 conn->socket.last_used = cf_get_seconds();
331 evtimer_del(&cmd->timer);
338 event_del(&conn->watcher);
436 cmd->
auth_len = (uint32_t)proto->sz;
as_event_loop * event_loop
as_event_parse_results_fn parse_results
void as_event_timeout(as_event_command *cmd)
bool as_event_command_parse_success_failure(as_event_command *cmd)
as_event_executor_complete_fn complete_fn
bool(* as_event_parse_results_fn)(struct as_event_command *cmd)
#define AS_ASYNC_STATE_AUTH_READ_HEADER
as_pipe_listener listener
void as_event_command_free(as_event_command *cmd)
static void as_event_set_auth_parse_header(as_event_command *cmd)
void as_proto_swap_from_be(as_proto *m)
static void as_event_set_auth_read_header(as_event_command *cmd)
bool as_event_command_parse_header(as_event_command *cmd)
void as_event_executor_cancel(as_event_executor *executor, int queued_count)
static void as_event_command_release(as_event_command *cmd)
void as_event_node_destroy(as_node *node)
void as_event_socket_error(as_event_command *cmd, as_error *err)
void as_event_executor_complete(as_event_command *cmd)
static void as_event_decr_connection(as_cluster *cluster, as_queue *queue)
bool as_event_send(as_event_command *cmd)
char * as_error_string(as_status status)
struct as_event_command ** commands
bool as_event_create_loop(as_event_loop *event_loop)
as_event_loop * event_loop
as_status as_event_command_execute(as_event_command *cmd, as_error *err)
static void as_event_set_conn_last_used(as_event_connection *conn)
int as_socket_validate(as_socket *sock)
int as_socket_validate_fd(int fd)
void(* as_event_executor_complete_fn)(struct as_event_executor *executor, as_error *err)
static int as_event_validate_connection(as_event_connection *conn)
#define AS_ASYNC_STATE_AUTH_READ_BODY
static void as_event_stop_watcher(as_event_command *cmd, as_event_connection *conn)
void(* as_pipe_listener)(void *udata, as_event_loop *event_loop)
void as_event_response_error(as_event_command *cmd, as_error *err)
static void as_event_decr_conn(as_event_command *cmd)
void as_event_command_begin(as_event_command *cmd)
bool as_event_send_close_loop(as_event_loop *event_loop)
void as_event_register_external_loop(as_event_loop *event_loop)
#define as_error_set_message(__err, __code, __msg)
uint32_t as_authenticate_set(const char *user, const char *credential, uint8_t *buffer)
static void as_event_command_execute_in_loop(as_event_command *cmd)
uint32_t async_conn_count
static as_event_loop * as_event_loop_get()
as_event_connection * conn
static void as_event_set_auth_write(as_event_command *cmd)
static void as_event_stop_timer(as_event_command *cmd)
void as_event_close_connection(as_event_connection *conn)
as_pipe_listener pipe_listener
static void as_event_release_connection(as_cluster *cluster, as_event_connection *conn, as_queue *queue)
void(* as_event_executor_destroy_fn)(struct as_event_executor *executor)
bool as_event_command_parse_result(as_event_command *cmd)
struct as_event_command * cmd
static as_event_loop * as_event_assign(as_event_loop *event_loop)
void as_event_error_callback(as_event_command *cmd, as_error *err)
as_connection_status as_event_get_connection(as_event_command *cmd)
static void as_queue_decr_total(as_queue *queue)