* syslog.cc (syslog): Do not print the Windows pid. Print the Cygwin pid as an
unsigned decimal. On Win95 print a timestamp and attempt to lock the file up to four times in 3 ms.
This commit is contained in:
parent
fe96201935
commit
878e60c561
@ -1,3 +1,9 @@
|
|||||||
|
2003-02-22 Pierre Humblet <pierre.humblet@ieee.org>
|
||||||
|
|
||||||
|
* syslog.cc (syslog): Do not print the Windows pid. Print the Cygwin
|
||||||
|
pid as an unsigned decimal. On Win95 print a timestamp and attempt to
|
||||||
|
lock the file up to four times in 3 ms.
|
||||||
|
|
||||||
2003-02-21 Corinna Vinschen <corinna@vinschen.de>
|
2003-02-21 Corinna Vinschen <corinna@vinschen.de>
|
||||||
|
|
||||||
* fhandler_socket.cc (fhandler_socket::fhandler_socket): Fix compiler
|
* fhandler_socket.cc (fhandler_socket::fhandler_socket): Fix compiler
|
||||||
|
@ -767,6 +767,7 @@ lseek
|
|||||||
_lseek = lseek
|
_lseek = lseek
|
||||||
lseek64
|
lseek64
|
||||||
lstat64
|
lstat64
|
||||||
|
mallinfo
|
||||||
malloc
|
malloc
|
||||||
_malloc = malloc
|
_malloc = malloc
|
||||||
malloc_stats
|
malloc_stats
|
||||||
|
@ -184,12 +184,13 @@ details. */
|
|||||||
lrintf lround lroundf nearbyint nearbyintf remquo remquof
|
lrintf lround lroundf nearbyint nearbyintf remquo remquof
|
||||||
round roundf scalbln scalblnf sincos sincosf tgamma tgammaf
|
round roundf scalbln scalblnf sincos sincosf tgamma tgammaf
|
||||||
truncf
|
truncf
|
||||||
|
76: mallinfo
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Note that we forgot to bump the api for ualarm, strtoll, strtoull */
|
/* Note that we forgot to bump the api for ualarm, strtoll, strtoull */
|
||||||
|
|
||||||
#define CYGWIN_VERSION_API_MAJOR 0
|
#define CYGWIN_VERSION_API_MAJOR 0
|
||||||
#define CYGWIN_VERSION_API_MINOR 75
|
#define CYGWIN_VERSION_API_MINOR 76
|
||||||
|
|
||||||
/* There is also a compatibity version number associated with the
|
/* There is also a compatibity version number associated with the
|
||||||
shared memory regions. It is incremented when incompatible
|
shared memory regions. It is incremented when incompatible
|
||||||
|
@ -302,8 +302,7 @@ syslog (int priority, const char *message, ...)
|
|||||||
}
|
}
|
||||||
if (process_logopt & LOG_PID)
|
if (process_logopt & LOG_PID)
|
||||||
{
|
{
|
||||||
if (pass.print ("Win32 Process Id = 0x%X : Cygwin Process Id = 0x%X : ",
|
if (pass.print ("PID %u : ", getpid ()) == -1)
|
||||||
GetCurrentProcessId (), getpid ()) == -1)
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -375,6 +374,8 @@ syslog (int priority, const char *message, ...)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Under Windows 95, append the message to the log file */
|
/* Under Windows 95, append the message to the log file */
|
||||||
|
char timestamp[24];
|
||||||
|
time_t ctime;
|
||||||
FILE *fp = fopen (get_win95_event_log_path (), "a");
|
FILE *fp = fopen (get_win95_event_log_path (), "a");
|
||||||
if (fp == NULL)
|
if (fp == NULL)
|
||||||
{
|
{
|
||||||
@ -382,24 +383,32 @@ syslog (int priority, const char *message, ...)
|
|||||||
get_win95_event_log_path ());
|
get_win95_event_log_path ());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
strftime (timestamp, sizeof timestamp, "%Y-%m-%d %H:%M:%S : ",
|
||||||
|
localtime (&(ctime = time (NULL))));
|
||||||
|
|
||||||
/* Now to prevent several syslog messages from being
|
/* Now to prevent several syslog messages from being
|
||||||
interleaved, we must lock the first byte of the file
|
interleaved, we must lock the first byte of the file
|
||||||
This works on Win32 even if we created the file above.
|
This works on Win32 even if we created the file above.
|
||||||
*/
|
*/
|
||||||
HANDLE fHandle = cygheap->fdtab[fileno (fp)]->get_handle ();
|
HANDLE fHandle = cygheap->fdtab[fileno (fp)]->get_handle ();
|
||||||
if (LockFile (fHandle, 0, 0, 1, 0) == FALSE)
|
for (int i = 0;; i++)
|
||||||
{
|
if (LockFile (fHandle, 0, 0, 1, 0) == FALSE)
|
||||||
debug_printf ("failed to lock file %s", get_win95_event_log_path ());
|
if (i == 3)
|
||||||
fclose (fp);
|
{
|
||||||
return;
|
debug_printf ("failed to lock file %s", get_win95_event_log_path ());
|
||||||
}
|
fclose (fp);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
usleep (1000);
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
fputs (timestamp, fp);
|
||||||
fputs (msg_strings[0], fp);
|
fputs (msg_strings[0], fp);
|
||||||
fputc ('\n', fp);
|
fputc ('\n', fp);
|
||||||
UnlockFile (fHandle, 0, 0, 1, 0);
|
UnlockFile (fHandle, 0, 0, 1, 0);
|
||||||
if (ferror (fp))
|
if (ferror (fp))
|
||||||
{
|
debug_printf ("error in writing syslog");
|
||||||
debug_printf ("error in writing syslog");
|
|
||||||
}
|
|
||||||
fclose (fp);
|
fclose (fp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user