diff options
-rw-r--r-- | daemon/dest_file.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/daemon/dest_file.c b/daemon/dest_file.c index a1e917b..3925499 100644 --- a/daemon/dest_file.c +++ b/daemon/dest_file.c @@ -246,11 +246,13 @@ static void destroy_file_writer( struct file_writer* writer ) /****************************************************************************** * create_file_writer */ -static struct file_writer* create_file_writer( gchar* file_name ) +static struct file_writer* create_file_writer( gchar* file_name, + struct destination* destination ) { struct file_writer *ret; unsigned writer_thread_id; HANDLE *writer_thread; + struct dest_extra *extra; TRACE_ENTER( "file_name=%s\n", file_name ); ret = g_malloc0( sizeof(struct file_writer) ); @@ -268,14 +270,23 @@ static struct file_writer* create_file_writer( gchar* file_name ) ERR( "Cannot create event; error %lu\n", GetLastError() ); goto error; } + writer_thread = (HANDLE) _beginthreadex( NULL, 0, writer_thread_proc, ret, - 0, &writer_thread_id ); + CREATE_SUSPENDED, &writer_thread_id ); if( !writer_thread ) { ERR( "Cannot create thread; error %lu\n", GetLastError() ); goto error; } + + /* add writer to destination */ + extra = destination->extra; + extra->file_writers = g_list_append( extra->file_writers, ret ); + ret->destination = destination; + + ResumeThread( writer_thread ); CloseHandle( writer_thread ); + TRACE_LEAVE( "done; ret=%p\n", ret ); return ret; @@ -464,12 +475,9 @@ static void put_message_to_file_dest( struct destination* destination, struct me if( !writer ) { /* create new writer */ - writer = create_file_writer( file_name ); + writer = create_file_writer( file_name, destination ); if( !writer ) goto done; - /* add writer to destination */ - extra->file_writers = g_list_append( extra->file_writers, writer ); - writer->destination = destination; } /* put message into queue */ reference_message( msg ); |