diff options
| author | Donald Sharp <sharpd@nvidia.com> | 2020-11-06 18:21:50 -0500 |
|---|---|---|
| committer | Donald Sharp <sharpd@nvidia.com> | 2020-11-15 14:50:17 -0500 |
| commit | 8a3f8f2e4ae1e8aaa3666fd8d38780e753bc09e7 (patch) | |
| tree | 6d39449fbe173f576de0c4309dc284d837a6edb1 /lib/zclient.c | |
| parent | 07414912cd55f1a8517242a16beada2623c49cfc (diff) | |
bgpd, lib, sharpd: Add enum for zclient_send_message return
Add a `enum zclient_send_status` for appropriate handling
of return codes from zclient_send_message. Touch all the places
where we handle this.
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
Diffstat (limited to 'lib/zclient.c')
| -rw-r--r-- | lib/zclient.c | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/lib/zclient.c b/lib/zclient.c index 980ecc5ed8..56c131f7e3 100644 --- a/lib/zclient.c +++ b/lib/zclient.c @@ -249,12 +249,12 @@ int zclient_socket_connect(struct zclient *zclient) return sock; } -static int zclient_failed(struct zclient *zclient) +static enum zclient_send_status zclient_failed(struct zclient *zclient) { zclient->fail++; zclient_stop(zclient); zclient_event(ZCLIENT_CONNECT, zclient); - return -1; + return ZCLIENT_SEND_FAILURE; } static int zclient_flush_data(struct thread *thread) @@ -285,14 +285,15 @@ static int zclient_flush_data(struct thread *thread) } /* - * -1 is a failure - * 0 means we sent - * 1 means we are buffering + * Returns: + * ZCLIENT_SEND_FAILED - is a failure + * ZCLIENT_SEND_SUCCESS - means we sent data to zebra + * ZCLIENT_SEND_BUFFERED - means we are buffering */ -int zclient_send_message(struct zclient *zclient) +enum zclient_send_status zclient_send_message(struct zclient *zclient) { if (zclient->sock < 0) - return -1; + return ZCLIENT_SEND_FAILURE; switch (buffer_write(zclient->wb, zclient->sock, STREAM_DATA(zclient->obuf), stream_get_endp(zclient->obuf))) { @@ -303,17 +304,15 @@ int zclient_send_message(struct zclient *zclient) return zclient_failed(zclient); case BUFFER_EMPTY: THREAD_OFF(zclient->t_write); - return 0; - break; + return ZCLIENT_SEND_SUCCESS; case BUFFER_PENDING: thread_add_write(zclient->master, zclient_flush_data, zclient, zclient->sock, &zclient->t_write); - return 1; - break; + return ZCLIENT_SEND_BUFFERED; } /* should not get here */ - return 0; + return ZCLIENT_SEND_SUCCESS; } /* @@ -771,11 +770,11 @@ int zclient_send_rnh(struct zclient *zclient, int command, * * XXX: No attention paid to alignment. */ -int zclient_route_send(uint8_t cmd, struct zclient *zclient, - struct zapi_route *api) +enum zclient_send_status +zclient_route_send(uint8_t cmd, struct zclient *zclient, struct zapi_route *api) { if (zapi_route_encode(cmd, zclient->obuf, api) < 0) - return -1; + return ZCLIENT_SEND_FAILURE; return zclient_send_message(zclient); } |
