From: Robert J. <rc...@li...> - 2009-09-02 16:10:11
|
DR commands shouldn't take long to complete, but having both an entry and exit timestamp eliminates the guessing and can point people in the correct direction while they debug issues. Signed-off-by: Robert Jennings <rc...@li...> --- src/drmgr/common.c | 9 ++++++++- src/drmgr/drmgr.c | 21 ++++++++++++++------- 2 files changed, 22 insertions(+), 8 deletions(-) Index: b/src/drmgr/common.c =================================================================== --- a/src/drmgr/common.c +++ b/src/drmgr/common.c @@ -63,7 +63,7 @@ dr_init(void) time_t t; char tbuf[128]; - /* Insert seperator between drmgr invocations */ + /* Insert seperator at beginning of drmgr invocation */ time(&t); strftime(tbuf, 128, "%b %d %T %G", localtime(&t)); dbg("\n########## %s ##########\n", tbuf); @@ -81,12 +81,19 @@ dr_fini(void) struct stat sbuf; int max_dr_log_sz = 25000; int rc; + time_t t; + char tbuf[128]; free_drc_info(); if (! log_fd) return; + /* Insert seperator at end of drmgr invocation */ + time(&t); + strftime(tbuf, 128, "%b %d %T %G", localtime(&t)); + dbg("########## %s ##########\n", tbuf); + close(log_fd); /* Check for log rotation */ Index: b/src/drmgr/drmgr.c =================================================================== --- a/src/drmgr/drmgr.c +++ b/src/drmgr/drmgr.c @@ -355,36 +355,42 @@ main(int argc, char *argv[]) if (display_capabilities) { print_dlpar_capabilities(); - return 0; + rc = 0; + goto exit; } command = get_command(&opts); if (display_usage) { command_usage(command); - return 0; + rc = 0; + goto exit; } /* Validate the options for the action we want to perform */ rc = command->validate_options(&opts); if (rc) - return rc; + goto exit; /* Validate this platform */ - if (! valid_platform("chrp")) - exit(1); + if (! valid_platform("chrp")) { + rc = 1; + goto exit; + } /* Mask signals so we do not get interrupted */ if (sig_setup()) { err_msg("Could not mask signals to avoid interrupts\n"); - return -1; + rc = -1; + goto exit; } rc = dr_lock(opts.timeout); if (rc) { err_msg("Unable to obtain Dynamic Reconfiguration lock. " "Please try command again later.\n"); - return -1; + rc = -1; + goto exit; } /* Log this invocation to /var/log/messages and /var/log/drmgr */ @@ -400,6 +406,7 @@ main(int argc, char *argv[]) rc = command->func(&opts); dr_unlock(); +exit: dr_fini(); return rc; } |