diff options
| author | David Lamparter <equinox@diac24.net> | 2017-01-03 16:44:44 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-01-03 16:44:44 +0100 |
| commit | 9b532e09f9a612884b2f394fe17d2d3386d3e3a9 (patch) | |
| tree | 416ce8e13e3fd965cee263946e6c86f7e2efa68b /lib/zclient.c | |
| parent | 9f221bd1a826f473b14393b1cf523543738c5050 (diff) | |
| parent | ff9eb96a93cdb5509a45f84bc557eb6dc9122c27 (diff) | |
Merge pull request #37 from LabNConsulting/working/2.0/patch-set-170102a
Working/2.0/patch set 170102a
Diffstat (limited to 'lib/zclient.c')
| -rw-r--r-- | lib/zclient.c | 28 |
1 files changed, 9 insertions, 19 deletions
diff --git a/lib/zclient.c b/lib/zclient.c index 894e0d19ef..440de3635f 100644 --- a/lib/zclient.c +++ b/lib/zclient.c @@ -216,7 +216,9 @@ zclient_socket(void) ret = connect (sock, (struct sockaddr *) &serv, sizeof (serv)); if (ret < 0) { - zlog_warn ("%s connect failure: %d", __PRETTY_FUNCTION__, errno); + if (zclient_debug) + zlog_warn ("%s connect failure: %d(%s)", __PRETTY_FUNCTION__, + errno, safe_strerror (errno)); close (sock); return -1; } @@ -252,7 +254,9 @@ zclient_socket_un (const char *path) ret = connect (sock, (struct sockaddr *) &addr, len); if (ret < 0) { - zlog_warn ("%s connect failure: %d", __PRETTY_FUNCTION__, errno); + if (zclient_debug) + zlog_warn ("%s connect failure: %d(%s)", __PRETTY_FUNCTION__, + errno, safe_strerror (errno)); close (sock); return -1; } @@ -572,23 +576,11 @@ zclient_start (struct zclient *zclient) if (zclient->t_connect) return 0; - /* - * If we fail to connect to the socket on initialization, - * Let's wait a second and see if we can reconnect. - * Cause if we don't connect, we never attempt to - * reconnect. On startup if zebra is slow we - * can get into this situation. - */ - while (zclient_socket_connect(zclient) < 0 && zclient->fail < 5) + if (zclient_socket_connect(zclient) < 0) { if (zclient_debug) zlog_debug ("zclient connection fail"); zclient->fail++; - sleep (1); - } - - if (zclient->sock < 0) - { zclient_event (ZCLIENT_CONNECT, zclient); return -1; } @@ -1727,11 +1719,9 @@ zclient_event (enum event event, struct zclient *zclient) thread_add_event (zclient->master, zclient_connect, zclient, 0); break; case ZCLIENT_CONNECT: - if (zclient->fail >= 10) - return; if (zclient_debug) - zlog_debug ("zclient connect schedule interval is %d", - zclient->fail < 3 ? 10 : 60); + zlog_debug ("zclient connect failures: %d schedule interval is now %d", + zclient->fail, zclient->fail < 3 ? 10 : 60); if (! zclient->t_connect) zclient->t_connect = thread_add_timer (zclient->master, zclient_connect, zclient, |
