summaryrefslogtreecommitdiff
path: root/usr.sbin/dconschat
diff options
context:
space:
mode:
authorHidetoshi Shimokawa <simokawa@FreeBSD.org>2007-06-07 12:29:33 +0000
committerHidetoshi Shimokawa <simokawa@FreeBSD.org>2007-06-07 12:29:33 +0000
commitf6416cb4842d31f8cc2da5eca210bbef5fe29175 (patch)
tree7e4cf9ca2e1cbe1e392549168c5c58453fdc37d6 /usr.sbin/dconschat
parent578e60792686f3fd44333eae77cb931d86fefda3 (diff)
downloadsrc-test2-f6416cb4842d31f8cc2da5eca210bbef5fe29175.tar.gz
src-test2-f6416cb4842d31f8cc2da5eca210bbef5fe29175.zip
Add heuristics for smooth reconnection.
Notes
Notes: svn path=/head/; revision=170399
Diffstat (limited to 'usr.sbin/dconschat')
-rw-r--r--usr.sbin/dconschat/dconschat.c26
1 files changed, 22 insertions, 4 deletions
diff --git a/usr.sbin/dconschat/dconschat.c b/usr.sbin/dconschat/dconschat.c
index 9594c16b888b..719b21fea799 100644
--- a/usr.sbin/dconschat/dconschat.c
+++ b/usr.sbin/dconschat/dconschat.c
@@ -769,7 +769,8 @@ dconschat_proc_dcons(struct dcons_state *dc)
while ((len = dconschat_read_dcons(dc, port, buf,
sizeof(buf))) > 0) {
dconschat_write_socket(p->outfd, buf, len);
- dconschat_get_ptr(dc);
+ if ((err = dconschat_get_ptr(dc)))
+ return (err);
}
if ((dc->flags & F_ONE_SHOT) != 0 && len <= 0)
dconschat_cleanup(0);
@@ -781,13 +782,30 @@ static int
dconschat_start_session(struct dcons_state *dc)
{
int counter = 0;
+ int retry = 0;
+ int retry_unit_init = MAX(1, poll_hz / 10);
+ int retry_unit_offline = poll_hz * DCONS_POLL_OFFLINE;
+ int retry_unit = retry_unit_init;
+ int retry_max = retry_unit_offline / retry_unit;
while (1) {
- if ((dc->flags & F_READY) == 0 &&
- (++counter % (poll_hz * DCONS_POLL_OFFLINE)) == 0)
+ if (((dc->flags & F_READY) == 0) && ++counter > retry_unit) {
+ counter = 0;
+ retry ++;
+ if (retry > retry_max)
+ retry_unit = retry_unit_offline;
+ if (verbose) {
+ printf("%d/%d ", retry, retry_max);
+ fflush(stdout);
+ }
dconschat_fetch_header(dc);
- if ((dc->flags & F_READY) != 0)
+ }
+ if ((dc->flags & F_READY) != 0) {
+ counter = 0;
+ retry = 0;
+ retry_unit = retry_unit_init;
dconschat_proc_dcons(dc);
+ }
dconschat_proc_socket(dc);
}
return (0);