From: Philip Homburg Date: Mon, 15 May 2006 12:08:43 +0000 (+0000) Subject: Fixed off by one error in backoff code. Limit backoff to 1 second for X-Git-Tag: v3.1.3~358 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/invmod.png?a=commitdiff_plain;h=c3cf4ef460d5eb087de0ee835f700ebac46ae45d;p=minix.git Fixed off by one error in backoff code. Limit backoff to 1 second for disk drivers. --- diff --git a/servers/rs/manager.c b/servers/rs/manager.c index f831e5a71..017407aa1 100644 --- a/servers/rs/manager.c +++ b/servers/rs/manager.c @@ -254,8 +254,10 @@ PUBLIC void do_exit(message *m_ptr) rp->r_restarts= 0; #endif if (rp->r_restarts > 0) { - rp->r_backoff = 1 << MIN(rp->r_restarts,(BACKOFF_BITS-1)); + rp->r_backoff = 1 << MIN(rp->r_restarts,(BACKOFF_BITS-2)); rp->r_backoff = MIN(rp->r_backoff,MAX_BACKOFF); + if (rp->r_exec != NULL && rp->r_backoff > 1) + rp->r_backoff= 1; } else { start_service(rp); /* direct restart */ diff --git a/servers/rs/service.c b/servers/rs/service.c index e4c929068..cefc67b70 100644 --- a/servers/rs/service.c +++ b/servers/rs/service.c @@ -95,7 +95,7 @@ PRIVATE void failure(int num) /* Parse and verify correctness of arguments. Report problem and exit if an * error is found. Store needed parameters in global variables. */ -PRIVATE int parse_arguments(int argcX, char **argvX) +PRIVATE int parse_arguments(int argc, char **argv) { struct stat stat_buf; char *hz; @@ -104,35 +104,35 @@ PRIVATE int parse_arguments(int argcX, char **argvX) int c_flag; c_flag= 0; - while (c= getopt(argcX, argvX, "c?"), c != -1) + while (c= getopt(argc, argv, "c?"), c != -1) { switch(c) { case '?': - print_usage(argvX[ARG_NAME], "wrong number of arguments"); + print_usage(argv[ARG_NAME], "wrong number of arguments"); exit(EINVAL); case 'c': c_flag= 1; break; default: fprintf(stderr, "%s: getopt failed: %c\n", - argvX[ARG_NAME], c); + argv[ARG_NAME], c); exit(1); } } /* Verify argument count. */ - if (argcX < optind+MIN_ARG_COUNT) { - print_usage(argvX[ARG_NAME], "wrong number of arguments"); + if (argc < optind+MIN_ARG_COUNT) { + print_usage(argv[ARG_NAME], "wrong number of arguments"); exit(EINVAL); } /* Verify request type. */ for (req_type=0; req_type< ILLEGAL_REQUEST; req_type++) { - if (strcmp(known_requests[req_type],argvX[optind+ARG_REQUEST])==0) break; + if (strcmp(known_requests[req_type],argv[optind+ARG_REQUEST])==0) break; } if (req_type == ILLEGAL_REQUEST) { - print_usage(argvX[ARG_NAME], "illegal request type"); + print_usage(argv[ARG_NAME], "illegal request type"); exit(ENOSYS); } req_nr = RS_RQ_BASE + req_type; @@ -143,15 +143,15 @@ PRIVATE int parse_arguments(int argcX, char **argvX) req_nr= RS_UP_COPY; /* Verify argument count. */ - if (argcX - 1 < optind+ARG_PATH) { - print_usage(argvX[ARG_NAME], "action requires a binary to start"); + if (argc - 1 < optind+ARG_PATH) { + print_usage(argv[ARG_NAME], "action requires a binary to start"); exit(EINVAL); } /* Verify the name of the binary of the system service. */ - req_path = argvX[optind+ARG_PATH]; + req_path = argv[optind+ARG_PATH]; if (req_path[0] != '/') { - print_usage(argvX[ARG_NAME], "binary should be absolute path"); + print_usage(argv[ARG_NAME], "binary should be absolute path"); exit(EINVAL); } if (stat(req_path, &stat_buf) == -1) { @@ -160,44 +160,44 @@ PRIVATE int parse_arguments(int argcX, char **argvX) exit(errno); } if (! (stat_buf.st_mode & S_IFREG)) { - print_usage(argvX[ARG_NAME], "binary is not a regular file"); + print_usage(argv[ARG_NAME], "binary is not a regular file"); exit(EINVAL); } /* Check optional arguments that come in pairs like "-args arglist". */ - for (i=optind+MIN_ARG_COUNT+1; i> MAJOR) & BYTE; } - else if (strcmp(argvX[i], ARG_ARGS)==0) { - req_priv = argvX[i+1]; + else if (strcmp(argv[i], ARG_ARGS)==0) { + req_priv = argv[i+1]; } else { - print_usage(argvX[ARG_NAME], "unknown optional argument given"); + print_usage(argv[ARG_NAME], "unknown optional argument given"); exit(EINVAL); } } @@ -205,33 +205,33 @@ PRIVATE int parse_arguments(int argcX, char **argvX) else if (req_nr == RS_DOWN || req_nr == RS_REFRESH) { /* Verify argument count. */ - if (argcX - 1 < optind+ARG_PID) { - print_usage(argvX[ARG_NAME], "action requires a pid to stop"); + if (argc - 1 < optind+ARG_PID) { + print_usage(argv[ARG_NAME], "action requires a pid to stop"); exit(EINVAL); } - if (! (req_pid = atoi(argvX[optind+ARG_PID])) > 0) { - print_usage(argvX[ARG_NAME], "pid must be greater than zero"); + if (! (req_pid = atoi(argv[optind+ARG_PID])) > 0) { + print_usage(argv[ARG_NAME], "pid must be greater than zero"); exit(EINVAL); } } else if (req_nr == RS_RESCUE) { /* Verify argument count. */ - if (argcX - 1 < optind+ARG_PATH) { - print_usage(argvX[ARG_NAME], "action requires rescue directory"); + if (argc - 1 < optind+ARG_PATH) { + print_usage(argv[ARG_NAME], "action requires rescue directory"); exit(EINVAL); } - req_path = argvX[optind+ARG_PATH]; + req_path = argv[optind+ARG_PATH]; if (req_path[0] != '/') { - print_usage(argvX[ARG_NAME], "rescue dir should be absolute path"); + print_usage(argv[ARG_NAME], "rescue dir should be absolute path"); exit(EINVAL); } - if (stat(argvX[optind+ARG_PATH], &stat_buf) == -1) { - print_usage(argvX[ARG_NAME], "couldn't get status of directory"); + if (stat(argv[optind+ARG_PATH], &stat_buf) == -1) { + print_usage(argv[ARG_NAME], "couldn't get status of directory"); exit(errno); } if ( ! (stat_buf.st_mode & S_IFDIR)) { - print_usage(argvX[ARG_NAME], "file is not a directory"); + print_usage(argv[ARG_NAME], "file is not a directory"); exit(EINVAL); } }