mirror of https://github.com/GNOME/gimp.git
libgimpbase: fix declaration after statement and reset safecheck...
... after each successful read(). I completely missed this declaration after a statement during the review of !13 even though I saw another similar issue! Also let's reset the error counter to 0 each time a successful read() happens so that we can continue reading even if a lot of EINTR were to happen, as long as we globally go forward. Only consecutive errors increment the counter. Finally add a small comment to explain why we let EINTR pass instead of breaking directly.
This commit is contained in:
parent
559d9b89e3
commit
49b4b1a5c2
|
@ -1185,8 +1185,10 @@ gimp_stack_trace_print (const gchar *prog_name,
|
||||||
DWORD tid = GetCurrentThreadId ();
|
DWORD tid = GetCurrentThreadId ();
|
||||||
#elif defined(PLATFORM_OSX)
|
#elif defined(PLATFORM_OSX)
|
||||||
uint64 tid64;
|
uint64 tid64;
|
||||||
|
long tid;
|
||||||
|
|
||||||
pthread_threadid_np (NULL, &tid64);
|
pthread_threadid_np (NULL, &tid64);
|
||||||
long tid = (long)tid64;
|
tid = (long) tid64;
|
||||||
#elif defined(SYS_gettid)
|
#elif defined(SYS_gettid)
|
||||||
long tid = syscall (SYS_gettid);
|
long tid = syscall (SYS_gettid);
|
||||||
#elif defined(HAVE_THR_SELF)
|
#elif defined(HAVE_THR_SELF)
|
||||||
|
@ -1284,6 +1286,13 @@ gimp_stack_trace_print (const gchar *prog_name,
|
||||||
{
|
{
|
||||||
if (read_n < 0)
|
if (read_n < 0)
|
||||||
{
|
{
|
||||||
|
/* LLDB on macOS seems to trigger a few EINTR error (see
|
||||||
|
* !13), though read() finally ends up working later. So
|
||||||
|
* let's not make this error fatal, and instead try again.
|
||||||
|
* Yet to avoid infinite loop (in case the error really
|
||||||
|
* happens at every call), we abandon after a few
|
||||||
|
* consecutive errors.
|
||||||
|
*/
|
||||||
if (errno == EINTR && eintr_count <= 5)
|
if (errno == EINTR && eintr_count <= 5)
|
||||||
{
|
{
|
||||||
eintr_count++;
|
eintr_count++;
|
||||||
|
@ -1291,6 +1300,7 @@ gimp_stack_trace_print (const gchar *prog_name,
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
eintr_count = 0;
|
||||||
if (! stack_printed)
|
if (! stack_printed)
|
||||||
{
|
{
|
||||||
#if defined(G_OS_WIN32) || defined(SYS_gettid) || defined(HAVE_THR_SELF)
|
#if defined(G_OS_WIN32) || defined(SYS_gettid) || defined(HAVE_THR_SELF)
|
||||||
|
|
Loading…
Reference in New Issue