* cygtls.cc (_cygtls::init_thread): Drop setting locals.process_logmask.
* cygtls.cc (_cygtls::remove): Always free mallocated TLS storage on thread exit. Drop freeing locals.process_ident. * cygtls.h (struct _local_storage): Remove syslog-related members. * syslog.cc (syslog_globals): New static storage for global syslog settings. Use throughout instead of _my_tls.locals. (openlog): Set new syslog_globals.process_ident value more carefully. * tlsoffsets.h: Regenerate.
This commit is contained in:
parent
2656876fb3
commit
a0307f9914
|
@ -1,3 +1,14 @@
|
|||
2011-04-21 Corinna Vinschen <corinna@vinschen.de>
|
||||
|
||||
* cygtls.cc (_cygtls::init_thread): Drop setting locals.process_logmask.
|
||||
* cygtls.cc (_cygtls::remove): Always free mallocated TLS storage on
|
||||
thread exit. Drop freeing locals.process_ident.
|
||||
* cygtls.h (struct _local_storage): Remove syslog-related members.
|
||||
* syslog.cc (syslog_globals): New static storage for global syslog
|
||||
settings. Use throughout instead of _my_tls.locals.
|
||||
(openlog): Set new syslog_globals.process_ident value more carefully.
|
||||
* tlsoffsets.h: Regenerate.
|
||||
|
||||
2011-04-21 Thomas Stalder <cygwinml@gmail.com>
|
||||
|
||||
* include/sys/poll.h: Include signal.h to get definition of sigset_t.
|
||||
|
|
|
@ -93,7 +93,6 @@ _cygtls::init_thread (void *x, DWORD (*func) (void *, void *))
|
|||
local_clib.__sglue._niobs = 3;
|
||||
local_clib.__sglue._iobs = &_GLOBAL_REENT->__sf[0];
|
||||
}
|
||||
locals.process_logmask = LOG_UPTO (LOG_DEBUG);
|
||||
}
|
||||
|
||||
thread_id = GetCurrentThreadId ();
|
||||
|
@ -146,25 +145,23 @@ _cygtls::remove (DWORD wait)
|
|||
return;
|
||||
|
||||
debug_printf ("wait %p", wait);
|
||||
if (locals.select.sockevt)
|
||||
CloseHandle (locals.select.sockevt);
|
||||
if (wait)
|
||||
{
|
||||
|
||||
/* FIXME: Need some sort of atthreadexit function to allow things like
|
||||
select to control this themselves. */
|
||||
|
||||
/* Close handle and free memory used by select. */
|
||||
if (locals.select.sockevt)
|
||||
{
|
||||
CloseHandle (locals.select.sockevt);
|
||||
locals.select.sockevt = NULL;
|
||||
free_local (select.ser_num);
|
||||
free_local (select.w4);
|
||||
}
|
||||
free_local (process_ident);
|
||||
/* Free memory used by network functions. */
|
||||
free_local (ntoa_buf);
|
||||
free_local (protoent_buf);
|
||||
free_local (servent_buf);
|
||||
free_local (hostent_buf);
|
||||
}
|
||||
|
||||
/* Free temporary TLS path buffers. */
|
||||
locals.pathbufs.destroy ();
|
||||
|
||||
|
|
|
@ -114,12 +114,6 @@ struct _local_storage
|
|||
/* strerror */
|
||||
char strerror_buf[sizeof ("Unknown error 4294967295")];
|
||||
|
||||
/* sysloc.cc */
|
||||
wchar_t *process_ident; // note: malloced
|
||||
int process_logopt;
|
||||
int process_facility;
|
||||
int process_logmask;
|
||||
|
||||
/* times.cc */
|
||||
char timezone_buf[20];
|
||||
struct tm _localtime_buf;
|
||||
|
|
|
@ -30,30 +30,39 @@ details. */
|
|||
|
||||
#define CYGWIN_LOG_NAME L"Cygwin"
|
||||
|
||||
static struct
|
||||
{
|
||||
wchar_t *process_ident;
|
||||
int process_logopt;
|
||||
int process_facility;
|
||||
int process_logmask;
|
||||
} syslog_globals = { NULL, 0, 0, LOG_UPTO (LOG_DEBUG) };
|
||||
|
||||
/* openlog: save the passed args. Don't open the system log or /dev/log yet. */
|
||||
extern "C" void
|
||||
openlog (const char *ident, int logopt, int facility)
|
||||
{
|
||||
wchar_t *new_ident = NULL;
|
||||
|
||||
debug_printf ("openlog called with (%s, %d, %d)",
|
||||
ident ? ident : "<NULL>", logopt, facility);
|
||||
|
||||
if (_my_tls.locals.process_ident != NULL)
|
||||
{
|
||||
free (_my_tls.locals.process_ident);
|
||||
_my_tls.locals.process_ident = NULL;
|
||||
}
|
||||
if (ident)
|
||||
{
|
||||
sys_mbstowcs_alloc (&_my_tls.locals.process_ident, HEAP_NOTHEAP, ident);
|
||||
if (!_my_tls.locals.process_ident)
|
||||
{
|
||||
sys_mbstowcs_alloc (&new_ident, HEAP_NOTHEAP, ident);
|
||||
if (!new_ident)
|
||||
debug_printf ("failed to allocate memory for "
|
||||
"_my_tls.locals.process_ident");
|
||||
return;
|
||||
"syslog_globals.process_ident");
|
||||
else
|
||||
{
|
||||
wchar_t *old_ident = syslog_globals.process_ident;
|
||||
syslog_globals.process_ident = new_ident;
|
||||
if (old_ident)
|
||||
free (old_ident);
|
||||
}
|
||||
}
|
||||
_my_tls.locals.process_logopt = logopt;
|
||||
_my_tls.locals.process_facility = facility;
|
||||
syslog_globals.process_logopt = logopt;
|
||||
syslog_globals.process_facility = facility;
|
||||
}
|
||||
|
||||
/* setlogmask: set the log priority mask and return previous mask.
|
||||
|
@ -62,10 +71,10 @@ int
|
|||
setlogmask (int maskpri)
|
||||
{
|
||||
if (maskpri == 0)
|
||||
return _my_tls.locals.process_logmask;
|
||||
return syslog_globals.process_logmask;
|
||||
|
||||
int old_mask = _my_tls.locals.process_logmask;
|
||||
_my_tls.locals.process_logmask = maskpri;
|
||||
int old_mask = syslog_globals.process_logmask;
|
||||
syslog_globals.process_logmask = maskpri;
|
||||
|
||||
return old_mask;
|
||||
}
|
||||
|
@ -269,7 +278,7 @@ try_connect_syslogd (int priority, const char *msg, int len)
|
|||
}
|
||||
/* If write fails and LOG_CONS is set, return failure to vsyslog so
|
||||
it falls back to the usual logging method for this OS. */
|
||||
if (ret >= 0 || !(_my_tls.locals.process_logopt & LOG_CONS))
|
||||
if (ret >= 0 || !(syslog_globals.process_logopt & LOG_CONS))
|
||||
ret = syslogd_sock;
|
||||
}
|
||||
try_connect_guard.release ();
|
||||
|
@ -289,20 +298,20 @@ vsyslog (int priority, const char *message, va_list ap)
|
|||
{
|
||||
debug_printf ("%x %s", priority, message);
|
||||
/* If the priority fails the current mask, reject */
|
||||
if ((LOG_MASK (LOG_PRI (priority)) & _my_tls.locals.process_logmask) == 0)
|
||||
if ((LOG_MASK (LOG_PRI (priority)) & syslog_globals.process_logmask) == 0)
|
||||
{
|
||||
debug_printf ("failing message %x due to priority mask %x",
|
||||
priority, _my_tls.locals.process_logmask);
|
||||
priority, syslog_globals.process_logmask);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Set default facility to LOG_USER if not yet set via openlog. */
|
||||
if (!_my_tls.locals.process_facility)
|
||||
_my_tls.locals.process_facility = LOG_USER;
|
||||
if (!syslog_globals.process_facility)
|
||||
syslog_globals.process_facility = LOG_USER;
|
||||
|
||||
/* Add default facility if not in the given priority. */
|
||||
if (!(priority & LOG_FACMASK))
|
||||
priority |= _my_tls.locals.process_facility;
|
||||
priority |= syslog_globals.process_facility;
|
||||
|
||||
/* Translate %m in the message to error text */
|
||||
char *errtext = strerror (get_errno ());
|
||||
|
@ -376,12 +385,12 @@ vsyslog (int priority, const char *message, va_list ap)
|
|||
pass.set_message ((char *) alloca (n));
|
||||
|
||||
/* Deal with ident_string */
|
||||
if (_my_tls.locals.process_ident != NULL)
|
||||
if (syslog_globals.process_ident != NULL)
|
||||
{
|
||||
if (pass.print ("%ls: ", _my_tls.locals.process_ident) == -1)
|
||||
if (pass.print ("%ls: ", syslog_globals.process_ident) == -1)
|
||||
return;
|
||||
}
|
||||
if (_my_tls.locals.process_logopt & LOG_PID)
|
||||
if (syslog_globals.process_logopt & LOG_PID)
|
||||
{
|
||||
if (pass.print ("PID %u: ", getpid ()) == -1)
|
||||
return;
|
||||
|
@ -397,7 +406,7 @@ vsyslog (int priority, const char *message, va_list ap)
|
|||
if (len != 0 && (total_msg[len - 1] == '\n'))
|
||||
total_msg[--len] = '\0';
|
||||
|
||||
if (_my_tls.locals.process_logopt & LOG_PERROR)
|
||||
if (syslog_globals.process_logopt & LOG_PERROR)
|
||||
{
|
||||
write (STDERR_FILENO, total_msg, len);
|
||||
write (STDERR_FILENO, "\n", 1);
|
||||
|
@ -409,7 +418,7 @@ vsyslog (int priority, const char *message, va_list ap)
|
|||
/* If syslogd isn't present, open the event log and send the message */
|
||||
HANDLE hEventSrc;
|
||||
|
||||
hEventSrc = RegisterEventSourceW (NULL, _my_tls.locals.process_ident
|
||||
hEventSrc = RegisterEventSourceW (NULL, syslog_globals.process_ident
|
||||
?: CYGWIN_LOG_NAME);
|
||||
if (!hEventSrc)
|
||||
debug_printf ("RegisterEventSourceW, %E");
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
//;# autogenerated: Do not edit.
|
||||
|
||||
//; $tls::sizeof__cygtls = 4304;
|
||||
//; $tls::sizeof__cygtls = 4288;
|
||||
//; $tls::func = -12700;
|
||||
//; $tls::pfunc = 0;
|
||||
//; $tls::saved_errno = -12696;
|
||||
|
@ -37,26 +37,26 @@
|
|||
//; $tls::p__dontuse = 412;
|
||||
//; $tls::locals = -11200;
|
||||
//; $tls::plocals = 1500;
|
||||
//; $tls::_ctinfo = -9480;
|
||||
//; $tls::p_ctinfo = 3220;
|
||||
//; $tls::andreas = -9476;
|
||||
//; $tls::pandreas = 3224;
|
||||
//; $tls::wq = -9472;
|
||||
//; $tls::pwq = 3228;
|
||||
//; $tls::sig = -9444;
|
||||
//; $tls::psig = 3256;
|
||||
//; $tls::incyg = -9440;
|
||||
//; $tls::pincyg = 3260;
|
||||
//; $tls::spinning = -9436;
|
||||
//; $tls::pspinning = 3264;
|
||||
//; $tls::stacklock = -9432;
|
||||
//; $tls::pstacklock = 3268;
|
||||
//; $tls::stackptr = -9428;
|
||||
//; $tls::pstackptr = 3272;
|
||||
//; $tls::stack = -9424;
|
||||
//; $tls::pstack = 3276;
|
||||
//; $tls::initialized = -8400;
|
||||
//; $tls::pinitialized = 4300;
|
||||
//; $tls::_ctinfo = -9496;
|
||||
//; $tls::p_ctinfo = 3204;
|
||||
//; $tls::andreas = -9492;
|
||||
//; $tls::pandreas = 3208;
|
||||
//; $tls::wq = -9488;
|
||||
//; $tls::pwq = 3212;
|
||||
//; $tls::sig = -9460;
|
||||
//; $tls::psig = 3240;
|
||||
//; $tls::incyg = -9456;
|
||||
//; $tls::pincyg = 3244;
|
||||
//; $tls::spinning = -9452;
|
||||
//; $tls::pspinning = 3248;
|
||||
//; $tls::stacklock = -9448;
|
||||
//; $tls::pstacklock = 3252;
|
||||
//; $tls::stackptr = -9444;
|
||||
//; $tls::pstackptr = 3256;
|
||||
//; $tls::stack = -9440;
|
||||
//; $tls::pstack = 3260;
|
||||
//; $tls::initialized = -8416;
|
||||
//; $tls::pinitialized = 4284;
|
||||
//; __DATA__
|
||||
|
||||
#define tls_func (-12700)
|
||||
|
@ -95,23 +95,23 @@
|
|||
#define tls_p__dontuse (412)
|
||||
#define tls_locals (-11200)
|
||||
#define tls_plocals (1500)
|
||||
#define tls__ctinfo (-9480)
|
||||
#define tls_p_ctinfo (3220)
|
||||
#define tls_andreas (-9476)
|
||||
#define tls_pandreas (3224)
|
||||
#define tls_wq (-9472)
|
||||
#define tls_pwq (3228)
|
||||
#define tls_sig (-9444)
|
||||
#define tls_psig (3256)
|
||||
#define tls_incyg (-9440)
|
||||
#define tls_pincyg (3260)
|
||||
#define tls_spinning (-9436)
|
||||
#define tls_pspinning (3264)
|
||||
#define tls_stacklock (-9432)
|
||||
#define tls_pstacklock (3268)
|
||||
#define tls_stackptr (-9428)
|
||||
#define tls_pstackptr (3272)
|
||||
#define tls_stack (-9424)
|
||||
#define tls_pstack (3276)
|
||||
#define tls_initialized (-8400)
|
||||
#define tls_pinitialized (4300)
|
||||
#define tls__ctinfo (-9496)
|
||||
#define tls_p_ctinfo (3204)
|
||||
#define tls_andreas (-9492)
|
||||
#define tls_pandreas (3208)
|
||||
#define tls_wq (-9488)
|
||||
#define tls_pwq (3212)
|
||||
#define tls_sig (-9460)
|
||||
#define tls_psig (3240)
|
||||
#define tls_incyg (-9456)
|
||||
#define tls_pincyg (3244)
|
||||
#define tls_spinning (-9452)
|
||||
#define tls_pspinning (3248)
|
||||
#define tls_stacklock (-9448)
|
||||
#define tls_pstacklock (3252)
|
||||
#define tls_stackptr (-9444)
|
||||
#define tls_pstackptr (3256)
|
||||
#define tls_stack (-9440)
|
||||
#define tls_pstack (3260)
|
||||
#define tls_initialized (-8416)
|
||||
#define tls_pinitialized (4284)
|
||||
|
|
Loading…
Reference in New Issue