diff options
author | yaworsky <yaworsky> | 2005-09-16 10:23:10 +0000 |
---|---|---|
committer | yaworsky <yaworsky> | 2005-09-16 10:23:10 +0000 |
commit | 6f4d8a67f7c492963b0ac96e136954d91c1ea0e6 (patch) | |
tree | 1c55e1762cd89dd2fa352b7af96c357c8856db63 /daemon | |
parent | c08f69a923394c54d6d7172359d7b81101789f01 (diff) | |
download | syslog-win32-6f4d8a67f7c492963b0ac96e136954d91c1ea0e6.tar.gz syslog-win32-6f4d8a67f7c492963b0ac96e136954d91c1ea0e6.tar.xz syslog-win32-6f4d8a67f7c492963b0ac96e136954d91c1ea0e6.zip |
Fixed file creation date workaround.
Diffstat (limited to 'daemon')
-rw-r--r-- | daemon/writer.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/daemon/writer.c b/daemon/writer.c index ea4f915..e05a2c8 100644 --- a/daemon/writer.c +++ b/daemon/writer.c @@ -308,7 +308,6 @@ static unsigned __stdcall writer_thread_proc( void* arg ) struct file_writer *writer = arg; HANDLE wait_objects[2] = { writer->fifo_semaphore, writer->shutdown_event }; gchar *pathname; - FILETIME systime; TRACE_ENTER( "writer=%p\n", writer ); @@ -319,22 +318,28 @@ static unsigned __stdcall writer_thread_proc( void* arg ) writer->fd = CreateFile( pathname, GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL ); - g_free( pathname ); if( INVALID_HANDLE_VALUE == writer->fd ) { ERR( "CreateFile(%s) error %lu\n", pathname, GetLastError() ); + g_free( pathname ); goto done; } - SetFilePointer( writer->fd, 0, NULL, FILE_END ); /* there's a strange bug or feature in windows: if there was a file with the same name in the directory, a new file will inherit its creation time; - because of this logs will be rotate each time; + because of this logs will be rotated each time; here is a workaround: */ - GetSystemTimeAsFileTime( &systime ); - if( !SetFileTime( writer->fd, &systime, &systime, &systime ) ) - ERR( "SetFileTime error %lu\n", GetLastError() ); + if( GetLastError() != ERROR_ALREADY_EXISTS ) + { + FILETIME systime; + GetSystemTimeAsFileTime( &systime ); + if( !SetFileTime( writer->fd, &systime, &systime, &systime ) ) + ERR( "SetFileTime error %lu\n", GetLastError() ); + } + + g_free( pathname ); + SetFilePointer( writer->fd, 0, NULL, FILE_END ); for(;;) { |