Skip to content
Snippets Groups Projects
Commit e80398c1 authored by Moe Jette's avatar Moe Jette
Browse files

No logic changes, minor code clean-up.

parent 9af3899f
No related branches found
No related tags found
No related merge requests found
...@@ -47,7 +47,7 @@ ...@@ -47,7 +47,7 @@
*/ */
#if HAVE_CONFIG_H #if HAVE_CONFIG_H
# include <config.h> # include "config.h"
#endif #endif
#include <stdio.h> #include <stdio.h>
...@@ -59,18 +59,22 @@ ...@@ -59,18 +59,22 @@
#include <stdarg.h> #include <stdarg.h>
#include <errno.h> #include <errno.h>
#include <syslog.h> #include <syslog.h>
#include <pthread.h>
#ifdef WITH_PTHREADS
# include <pthread.h>
#endif /* WITH_PTHREADS */
#if HAVE_STDLIB_H #if HAVE_STDLIB_H
# include <stdlib.h> /* for abort() */ # include <stdlib.h> /* for abort() */
#endif #endif
#include <src/common/macros.h> #include "src/common/log.h"
#include <src/common/log.h> #include "src/common/macros.h"
#include <src/common/xmalloc.h> #include "src/common/safeopen.h"
#include <src/common/xassert.h> #include "src/common/xassert.h"
#include <src/common/xstring.h> #include "src/common/xmalloc.h"
#include <src/common/safeopen.h> #include "src/common/xstring.h"
#ifndef LINEBUFSIZE #ifndef LINEBUFSIZE
# define LINEBUFSIZE 256 # define LINEBUFSIZE 256
...@@ -142,8 +146,9 @@ _log_init(char *prog, log_options_t opt, log_facility_t fac, char *logfile ) ...@@ -142,8 +146,9 @@ _log_init(char *prog, log_options_t opt, log_facility_t fac, char *logfile )
char *errmsg = NULL; char *errmsg = NULL;
pthread_mutex_unlock(&log_lock); pthread_mutex_unlock(&log_lock);
xslurm_strerrorcat(errmsg); xslurm_strerrorcat(errmsg);
fprintf(stderr, "%s: log_init(): Unable to open logfile" fprintf(stderr,
"`%s': %s\n", prog, logfile, errmsg); "%s: log_init(): Unable to open logfile"
"`%s': %s\n", prog, logfile, errmsg);
xfree(errmsg); xfree(errmsg);
rc = errno; rc = errno;
goto out; goto out;
...@@ -226,7 +231,8 @@ static char *vxstrfmt(const char *fmt, va_list ap) ...@@ -226,7 +231,8 @@ static char *vxstrfmt(const char *fmt, va_list ap)
while (*fmt != '\0') { while (*fmt != '\0') {
if ((p = (char *)strchr(fmt, '%')) == NULL) { /* no more format chars */ if ((p = (char *)strchr(fmt, '%')) == NULL) {
/* no more format chars */
xstrcat(buf, fmt); xstrcat(buf, fmt);
break; break;
...@@ -253,7 +259,7 @@ static char *vxstrfmt(const char *fmt, va_list ap) ...@@ -253,7 +259,7 @@ static char *vxstrfmt(const char *fmt, va_list ap)
xslurm_strerrorcat(buf); xslurm_strerrorcat(buf);
break; break;
case 't': /* "%t" => locally preferred date/time*/ case 't': /* "%t" => locally date/time*/
xstrftimecat(buf, "%x %X"); xstrftimecat(buf, "%x %X");
break; break;
case 'T': /* "%T" => "dd Mon yyyy hh:mm:ss off" */ case 'T': /* "%T" => "dd Mon yyyy hh:mm:ss off" */
...@@ -510,7 +516,8 @@ struct fatal_cleanup { ...@@ -510,7 +516,8 @@ struct fatal_cleanup {
static pthread_mutex_t fatal_lock = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t fatal_lock = PTHREAD_MUTEX_INITIALIZER;
static struct fatal_cleanup *fatal_cleanups = NULL; static struct fatal_cleanup *fatal_cleanups = NULL;
/* Registers a cleanup function to be called by fatal() for this thread before exiting. */ /* Registers a cleanup function to be called by fatal() for this thread
** before exiting. */
void void
fatal_add_cleanup(void (*proc) (void *), void *context) fatal_add_cleanup(void (*proc) (void *), void *context)
{ {
...@@ -526,7 +533,8 @@ fatal_add_cleanup(void (*proc) (void *), void *context) ...@@ -526,7 +533,8 @@ fatal_add_cleanup(void (*proc) (void *), void *context)
pthread_mutex_unlock(&fatal_lock); pthread_mutex_unlock(&fatal_lock);
} }
/* Registers a cleanup function to be called by fatal() for all threads of the job. */ /* Registers a cleanup function to be called by fatal() for all threads
** of the job. */
void void
fatal_add_cleanup_job(void (*proc) (void *), void *context) fatal_add_cleanup_job(void (*proc) (void *), void *context)
{ {
...@@ -566,7 +574,8 @@ fatal_remove_cleanup(void (*proc) (void *context), void *context) ...@@ -566,7 +574,8 @@ fatal_remove_cleanup(void (*proc) (void *context), void *context)
(u_long) proc, (u_long) context); (u_long) proc, (u_long) context);
} }
/* Removes a cleanup frunction to be called at fatal() for all threads of the job. */ /* Removes a cleanup frunction to be called at fatal() for all threads of
** the job. */
void void
fatal_remove_cleanup_job(void (*proc) (void *context), void *context) fatal_remove_cleanup_job(void (*proc) (void *context), void *context)
{ {
...@@ -585,11 +594,13 @@ fatal_remove_cleanup_job(void (*proc) (void *context), void *context) ...@@ -585,11 +594,13 @@ fatal_remove_cleanup_job(void (*proc) (void *context), void *context)
} }
} }
pthread_mutex_unlock(&fatal_lock); pthread_mutex_unlock(&fatal_lock);
fatal("fatal_remove_cleanup_job: no such cleanup function: 0x%lx 0x%lx", fatal(
"fatal_remove_cleanup_job: no such cleanup function: 0x%lx 0x%lx",
(u_long) proc, (u_long) context); (u_long) proc, (u_long) context);
} }
/* Execute cleanup functions, first thread-specific then those for the whole job */ /* Execute cleanup functions, first thread-specific then those for the
** whole job */
void void
fatal_cleanup(void) fatal_cleanup(void)
{ {
......
...@@ -47,7 +47,8 @@ ...@@ -47,7 +47,8 @@
#include <syslog.h> #include <syslog.h>
#include <stdio.h> #include <stdio.h>
#include <src/common/macros.h>
#include "src/common/macros.h"
/* supported syslog facilities and levels */ /* supported syslog facilities and levels */
typedef enum { typedef enum {
......
...@@ -29,8 +29,12 @@ ...@@ -29,8 +29,12 @@
#endif #endif
/* GLOBAL INCLUDES */ /* GLOBAL INCLUDES */
#ifdef WITH_PTHREADS
# include <pthread.h>
#endif /* WITH_PTHREADS */
#include <errno.h> #include <errno.h>
#include <pthread.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment