X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=lib%2Frconn.c;h=4bfd5a422f55db1d52c4a6e5d2256e8401b6ecdc;hb=b2f43905ea77f5e6e564d608616b7a4dec9d96b2;hp=7fd440529702b548f19f2d59404c6e975596d4b1;hpb=59ba307325ee2f9c6e1fe80f4c8a2fac7f6b32f2;p=openvswitch diff --git a/lib/rconn.c b/lib/rconn.c index 7fd44052..4bfd5a42 100644 --- a/lib/rconn.c +++ b/lib/rconn.c @@ -186,14 +186,13 @@ rconn_recv_wait(struct rconn *rc) } } -/* There is no rconn_send_wait() function: an rconn has a send queue that it - * takes care of sending if you call rconn_wait(), which will have the side - * effect of waking up poll_block(). */ +/* Sends 'b' on 'rc'. Returns 0 if successful, EAGAIN if at least 'txq_limit' + * packets are already queued, otherwise a positive errno value. */ int -rconn_send(struct rconn *rc, struct buffer *b) +do_send(struct rconn *rc, struct buffer *b, int txq_limit) { if (rc->vconn) { - if (rc->txq.n < rc->txq_limit) { + if (rc->txq.n < txq_limit) { queue_push_tail(&rc->txq, b); if (rc->txq.n == 1) { try_send(rc); @@ -207,6 +206,29 @@ rconn_send(struct rconn *rc, struct buffer *b) } } +/* Sends 'b' on 'rc'. Returns 0 if successful, EAGAIN if the send queue is + * full, otherwise a positive errno value. + * + * There is no rconn_send_wait() function: an rconn has a send queue that it + * takes care of sending if you call rconn_wait(), which will have the side + * effect of waking up poll_block(). */ +int +rconn_send(struct rconn *rc, struct buffer *b) +{ + return do_send(rc, b, rc->txq_limit); +} + +/* Sends 'b' on 'rc'. Returns 0 if successful, EAGAIN if the send queue is + * full, otherwise a positive errno value. + * + * Compared to rconn_send(), this function relaxes the queue limit, allowing + * more packets than usual to be queued. */ +int +rconn_force_send(struct rconn *rc, struct buffer *b) +{ + return do_send(rc, b, 2 * rc->txq_limit); +} + /* Returns true if 'rc''s send buffer is full, * false if it has room for at least one more packet. */ bool @@ -229,6 +251,13 @@ rconn_is_alive(const struct rconn *rconn) { return rconn->reliable || rconn->vconn; } + +/* Returns true if 'rconn' is connected, false otherwise. */ +bool +rconn_is_connected(const struct rconn *rconn) +{ + return rconn->vconn && !vconn_connect(rconn->vconn); +} static struct rconn * create_rconn(const char *name, int txq_limit, struct vconn *vconn)