diff options
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(;;) { |