sharedspice.c: preliminary fixes: ftime() usage,
prevent crash if controlled_exit from worker thread
This commit is contained in:
parent
2e4e7535b7
commit
e9cadf9dc8
|
|
@ -136,11 +136,9 @@ typedef pthread_t threadId_t;
|
||||||
#include <frontend/com_measure2.h>
|
#include <frontend/com_measure2.h>
|
||||||
#include <frontend/misccoms.h>
|
#include <frontend/misccoms.h>
|
||||||
|
|
||||||
#ifndef HAVE_GETRUSAGE
|
|
||||||
#ifdef HAVE_FTIME
|
#ifdef HAVE_FTIME
|
||||||
#include <sys/timeb.h>
|
#include <sys/timeb.h>
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
|
|
||||||
/* To interupt a spice run */
|
/* To interupt a spice run */
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
|
@ -501,7 +499,6 @@ ngSpice_running (void)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* Initialise ngspice and setup native methods */
|
/* Initialise ngspice and setup native methods */
|
||||||
IMPEXP
|
IMPEXP
|
||||||
int
|
int
|
||||||
|
|
@ -1289,6 +1286,7 @@ void SetAnalyse(
|
||||||
int DecaPercent /*in: 10 times the progress [%]*/
|
int DecaPercent /*in: 10 times the progress [%]*/
|
||||||
/*HWND hwAnalyse, in: global handle to analysis window */
|
/*HWND hwAnalyse, in: global handle to analysis window */
|
||||||
) {
|
) {
|
||||||
|
#ifdef HAVE_FTIME
|
||||||
static int OldPercent = -2; /* Previous progress value */
|
static int OldPercent = -2; /* Previous progress value */
|
||||||
static char OldAn[128]; /* Previous analysis type */
|
static char OldAn[128]; /* Previous analysis type */
|
||||||
char* s; /* outputs to callback function */
|
char* s; /* outputs to callback function */
|
||||||
|
|
@ -1352,6 +1350,17 @@ void SetAnalyse(
|
||||||
result = statfcn(s, userptr);
|
result = statfcn(s, userptr);
|
||||||
}
|
}
|
||||||
tfree(s);
|
tfree(s);
|
||||||
|
#else
|
||||||
|
char* s;
|
||||||
|
int result;
|
||||||
|
static bool havesent = FALSE;
|
||||||
|
if (!havesent) {
|
||||||
|
s = copy("No usage info available");
|
||||||
|
result = statfcn(s, userptr);
|
||||||
|
tfree(s);
|
||||||
|
havesent = TRUE;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/* a dll or shared library should never exit, if loaded dynamically,
|
/* a dll or shared library should never exit, if loaded dynamically,
|
||||||
|
|
@ -1395,8 +1404,23 @@ void shared_exit(int status)
|
||||||
tfree(outsend);
|
tfree(outsend);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
// if we are in a worker thread, we exit it here
|
||||||
|
// detaching then has to be done explicitely by the caller
|
||||||
|
if (fl_running && !fl_exited) {
|
||||||
|
fl_exited = TRUE;
|
||||||
|
bgtr(fl_exited, userptr);
|
||||||
|
// set a flag that ngspice wants to be detached
|
||||||
|
ngexit(status, FALSE, coquit, userptr);
|
||||||
|
// finish and exit the worker thread
|
||||||
|
#ifdef HAVE_LIBPTHREAD
|
||||||
|
pthread_exit(1);
|
||||||
|
#elif defined _MSC_VER || defined __MINGW32__
|
||||||
|
_endthreadex(1);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
// set a flag in caller to detach ngspice.dll
|
// set a flag in caller to detach ngspice.dll
|
||||||
ngexit(status, immediate, coquit, userptr);
|
ngexit(status, immediate, coquit, userptr);
|
||||||
|
|
||||||
// jump back to finish the calling function
|
// jump back to finish the calling function
|
||||||
if (!intermj)
|
if (!intermj)
|
||||||
longjmp(errbufm,1); /* jump back to ngSpice_Circ() */
|
longjmp(errbufm,1); /* jump back to ngSpice_Circ() */
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue