#ifdef GMX_THREADS
static tMPI_Thread_mutex_t debug_mutex=TMPI_THREAD_MUTEX_INITIALIZER;
static tMPI_Thread_mutex_t where_mutex=TMPI_THREAD_MUTEX_INITIALIZER;
+static tMPI_Thread_mutex_t fatal_tmp_mutex=TMPI_THREAD_MUTEX_INITIALIZER;
+static tMPI_Thread_mutex_t warning_mutex=TMPI_THREAD_MUTEX_INITIALIZER;
#endif
bool bDebugMode(void)
void _set_fatal_tmp_file(const char *fn, const char *file, int line)
{
#ifdef GMX_THREADS
- tMPI_Thread_mutex_lock(&debug_mutex);
+ tMPI_Thread_mutex_lock(&fatal_tmp_mutex);
#endif
if (fatal_tmp_file == NULL)
fatal_tmp_file = strdup(fn);
fprintf(stderr,"BUGWARNING: fatal_tmp_file already set at %s:%d",
file,line);
#ifdef GMX_THREADS
- tMPI_Thread_mutex_unlock(&debug_mutex);
+ tMPI_Thread_mutex_unlock(&fatal_tmp_mutex);
#endif
}
void _unset_fatal_tmp_file(const char *fn, const char *file, int line)
{
#ifdef GMX_THREADS
- tMPI_Thread_mutex_lock(&debug_mutex);
+ tMPI_Thread_mutex_lock(&fatal_tmp_mutex);
#endif
if (strcmp(fn,fatal_tmp_file) == 0) {
sfree(fatal_tmp_file);
fprintf(stderr,"BUGWARNING: file %s not set as fatal_tmp_file at %s:%d",
fn,file,line);
#ifdef GMX_THREADS
- tMPI_Thread_mutex_unlock(&debug_mutex);
+ tMPI_Thread_mutex_unlock(&fatal_tmp_mutex);
#endif
}
static void clean_fatal_tmp_file()
{
#ifdef GMX_THREADS
- tMPI_Thread_mutex_lock(&debug_mutex);
+ tMPI_Thread_mutex_lock(&fatal_tmp_mutex);
#endif
if (fatal_tmp_file) {
fprintf(stderr,"Cleaning up temporary file %s\n",fatal_tmp_file);
fatal_tmp_file = NULL;
}
#ifdef GMX_THREADS
- tMPI_Thread_mutex_unlock(&debug_mutex);
+ tMPI_Thread_mutex_unlock(&fatal_tmp_mutex);
#endif
}
va_end(ap);
bputc(msg,&len,'\0');
- fatal_errno = f_errno;
+ fatal_errno = f_errno; /* TODO might need a mutex as it's global [pszilard] */
#ifdef GMX_THREADS
tMPI_Thread_mutex_unlock(&debug_mutex);
#endif
void init_warning(int maxwarning)
{
#ifdef GMX_THREADS
- tMPI_Thread_mutex_lock(&debug_mutex);
+ tMPI_Thread_mutex_lock(&warning_mutex);
#endif
maxwarn = maxwarning;
nwarn_note = 0;
nwarn_warn = 0;
nwarn_error = 0;
#ifdef GMX_THREADS
- tMPI_Thread_mutex_unlock(&debug_mutex);
+ tMPI_Thread_mutex_unlock(&warning_mutex);
#endif
}
void set_warning_line(const char *s,int line)
{
#ifdef GMX_THREADS
- tMPI_Thread_mutex_lock(&debug_mutex);
+ tMPI_Thread_mutex_lock(&warning_mutex);
#endif
if (s == NULL)
gmx_incons("Calling set_warning_line with NULL pointer");
strcpy(filenm,s);
lineno = line;
#ifdef GMX_THREADS
- tMPI_Thread_mutex_unlock(&debug_mutex);
+ tMPI_Thread_mutex_unlock(&warning_mutex);
#endif
}
{
int ret;
#ifdef GMX_THREADS
- tMPI_Thread_mutex_lock(&debug_mutex);
+ tMPI_Thread_mutex_lock(&warning_mutex);
#endif
ret=lineno;
#ifdef GMX_THREADS
- tMPI_Thread_mutex_unlock(&debug_mutex);
+ tMPI_Thread_mutex_unlock(&warning_mutex);
#endif
return ret;
}
void warning(const char *s)
{
#ifdef GMX_THREADS
- tMPI_Thread_mutex_lock(&debug_mutex);
+ tMPI_Thread_mutex_lock(&warning_mutex);
#endif
nwarn_warn++;
low_warning("WARNING",nwarn_warn,s);
#ifdef GMX_THREADS
- tMPI_Thread_mutex_unlock(&debug_mutex);
+ tMPI_Thread_mutex_unlock(&warning_mutex);
#endif
}
void warning_note(const char *s)
{
#ifdef GMX_THREADS
- tMPI_Thread_mutex_lock(&debug_mutex);
+ tMPI_Thread_mutex_lock(&warning_mutex);
#endif
nwarn_note++;
low_warning("NOTE",nwarn_note,s);
#ifdef GMX_THREADS
- tMPI_Thread_mutex_unlock(&debug_mutex);
+ tMPI_Thread_mutex_unlock(&warning_mutex);
#endif
}
void warning_error(const char *s)
{
#ifdef GMX_THREADS
- tMPI_Thread_mutex_lock(&debug_mutex);
+ tMPI_Thread_mutex_lock(&warning_mutex);
#endif
nwarn_error++;
low_warning("ERROR",nwarn_error,s);
#ifdef GMX_THREADS
- tMPI_Thread_mutex_unlock(&debug_mutex);
+ tMPI_Thread_mutex_unlock(&warning_mutex);
#endif
}
void print_warn_num(bool bFatalError)
{
#ifdef GMX_THREADS
- tMPI_Thread_mutex_lock(&debug_mutex);
+ tMPI_Thread_mutex_lock(&warning_mutex);
#endif
print_warn_count("note",nwarn_note);
"If you are sure all warnings are harmless, use the -maxwarn option.",nwarn_warn,Program());
}
#ifdef GMX_THREADS
- tMPI_Thread_mutex_unlock(&debug_mutex);
+ tMPI_Thread_mutex_unlock(&warning_mutex);
#endif
}
void check_warning_error(int f_errno,const char *file,int line)
{
#ifdef GMX_THREADS
- tMPI_Thread_mutex_lock(&debug_mutex);
+ tMPI_Thread_mutex_lock(&warning_mutex);
#endif
if (nwarn_error > 0) {
print_warn_num(FALSE);
(nwarn_error==1) ? "" : "s");
}
#ifdef GMX_THREADS
- tMPI_Thread_mutex_unlock(&debug_mutex);
+ tMPI_Thread_mutex_unlock(&warning_mutex);
#endif
}
char *strerr;
#ifdef GMX_THREADS
- tMPI_Thread_mutex_lock(&debug_mutex);
+ if (msg == NULL) /* TODO needs checking for possible deadlock when msg == NULL [pszilard] */
+ {
+ tMPI_Thread_mutex_lock(&warning_mutex);
+ }
#endif
/* protect the audience from suggestive discussions */
strerr,msg ? msg : warn_buf,llines,tmpbuf);
free(strerr);
#ifdef GMX_THREADS
- tMPI_Thread_mutex_unlock(&debug_mutex);
+ if (msg == NULL)
+ {
+ tMPI_Thread_mutex_unlock(&warning_mutex);
+ }
#endif
gmx_error_handler(buf);
}