summaryrefslogtreecommitdiff
path: root/lib/send.c
diff options
context:
space:
mode:
authorLinus Nordberg <linus@nordberg.se>2013-05-15 14:20:52 +0200
committerLinus Nordberg <linus@nordberg.se>2013-05-15 14:20:52 +0200
commitfba1c7d1a6418221a94965d0431bf7df0a9a74a0 (patch)
tree168d4401100181050306a635adc72d118395b391 /lib/send.c
parent58f591ffc9a7d4fea5879210d56db3ca11e98f1e (diff)
WIP commit moving towards working server support.
Diffstat (limited to 'lib/send.c')
-rw-r--r--lib/send.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/lib/send.c b/lib/send.c
index fab89a9..3ed6c93 100644
--- a/lib/send.c
+++ b/lib/send.c
@@ -21,15 +21,15 @@
static int
_conn_open (struct rs_connection *conn, struct rs_message *msg)
{
- if (event_init_eventbase (conn))
+ if (event_init_eventbase (TO_BASE_CONN (conn)))
return -1;
- if (!conn->base_.active_peer)
+ if (!conn->active_peer)
peer_pick_peer (conn);
- if (!conn->base_.active_peer)
+ if (!conn->active_peer)
return rs_err_conn_push_fl (conn, RSE_NOPEER, __FILE__, __LINE__, NULL);
- if (event_init_socket (conn, conn->base_.active_peer))
+ if (event_init_socket (&conn->base_, conn->active_peer))
return -1;
if (conn->base_.realm->type == RS_CONN_TYPE_TCP
@@ -37,7 +37,7 @@ _conn_open (struct rs_connection *conn, struct rs_message *msg)
{
if (tcp_init_connect_timer (conn))
return -1;
- if (event_init_bufferevent (conn, conn->base_.active_peer))
+ if (event_init_bufferevent (conn))
return -1;
}
else
@@ -59,7 +59,7 @@ static int
_conn_is_open_p (struct rs_connection *conn)
{
return conn->state == RS_CONN_STATE_CONNECTED
- && conn->base_.active_peer != NULL;
+ && conn->active_peer != NULL;
}
/* User callback used when we're dispatching for user. */
@@ -76,7 +76,7 @@ _wcb (void *user_data)
}
int
-rs_message_send (struct rs_message *msg, void *user_data)
+rs_message_send (struct rs_message *msg)
{
struct rs_connection *conn = NULL;
int err = 0;
@@ -93,14 +93,13 @@ rs_message_send (struct rs_message *msg, void *user_data)
assert (conn->base_.ctx);
assert (conn->base_.ctx->evb);
- assert (conn->base_.active_peer);
+ assert (conn->active_peer);
assert (conn->base_.fd >= 0);
- conn->base_.user_data = user_data;
-
if (conn->base_.bev) /* TCP */
{
- bufferevent_setcb (conn->base_.bev, NULL, tcp_write_cb, tcp_event_cb, msg);
+ bufferevent_setcb (conn->base_.bev, NULL, tcp_write_cb, tcp_event_cb,
+ msg);
bufferevent_enable (conn->base_.bev, EV_WRITE);
}
else /* UDP */
@@ -118,6 +117,7 @@ rs_message_send (struct rs_message *msg, void *user_data)
/* Do dispatch, unless the user wants to do it herself. */
if (!conn_user_dispatch_p (conn))
{
+ /* Blocking mode. */
conn->callbacks.sent_cb = _wcb;
conn->base_.user_data = msg;
rs_debug (("%s: entering event loop\n", __func__));