From: Ballard J. <sac...@ho...> - 2004-02-23 23:38:37
|
Index: COLINUX_0/src/colinux/os/winnt/user/daemon.c=0A= diff -u COLINUX_0/src/colinux/os/winnt/user/daemon.c:1.4 = COLINUX_0/src/colinux/os/winnt/user/daemon.c:1.7=0A= --- COLINUX_0/src/colinux/os/winnt/user/daemon.c:1.4 Mon Feb 23 09:49:13 = 2004=0A= +++ COLINUX_0/src/colinux/os/winnt/user/daemon.c Mon Feb 23 15:28:53 2004=0A= @@ -5,14 +5,14 @@=0A= *=0A= * The code is licensed under the GPL. See the COPYING file at=0A= * the root directory.=0A= - */ =0A= + */=0A= =0A= /*=0A= * Ballard, Jonathan H. <cal...@us...>=0A= * 2004 02 22 : Designed and implemented co_os_daemon_thread()=0A= * : with message queue, wait state, and error=0A= * : recovery.=0A= - */ =0A= + */=0A= =0A= #include <windows.h>=0A= #include <stdio.h>=0A= @@ -21,281 +21,320 @@=0A= =0A= #include <colinux/os/alloc.h>=0A= =0A= -static DWORD WINAPI co_os_daemon_thread( LPVOID data ) ;=0A= +static DWORD WINAPI co_os_daemon_thread(LPVOID data);=0A= =0A= -co_rc_t co_os_open_daemon_pipe(co_id_t linux_id, co_module_t module_id, = co_daemon_handle_t *handle_out)=0A= +co_rc_t=0A= +co_os_open_daemon_pipe(co_id_t linux_id, co_module_t module_id,=0A= + co_daemon_handle_t * handle_out)=0A= {=0A= - HANDLE handle =3D INVALID_HANDLE_VALUE ;=0A= - long written =3D 0 ;=0A= - char pathname[0x100] ;=0A= - co_daemon_handle_t daemon_handle =3D 0 ;=0A= -=0A= - snprintf(pathname, sizeof(pathname), "\\\\.\\pipe\\coLinux%d", = (int)linux_id);=0A= -=0A= - co_debug("pipe client %d/%d: Connecting to daemon...\n", linux_id, = module_id);=0A= - =0A= - if( ! WaitNamedPipe(pathname, NMPWAIT_USE_DEFAULT_WAIT) ) {=0A= + HANDLE handle =3D INVALID_HANDLE_VALUE;=0A= + long written =3D 0;=0A= + char pathname[0x100];=0A= + co_daemon_handle_t daemon_handle =3D 0;=0A= +=0A= + snprintf(pathname, sizeof (pathname), "\\\\.\\pipe\\coLinux%d",=0A= + (int) linux_id);=0A= +=0A= + co_debug("pipe client %d/%d: Connecting to daemon...\n", linux_id,=0A= + module_id);=0A= +=0A= + if (!WaitNamedPipe(pathname, NMPWAIT_USE_DEFAULT_WAIT)) {=0A= co_debug("Connection timed out (%x)\n", GetLastError());=0A= - goto co_os_open_daemon_pipe_error ;=0A= + goto co_os_open_daemon_pipe_error;=0A= }=0A= =0A= - co_debug("pipe client %d/%d: Connection established\n", linux_id, = module_id);=0A= + co_debug("pipe client %d/%d: Connection established\n", linux_id,=0A= + module_id);=0A= =0A= - handle =3D CreateFile (=0A= - pathname,=0A= - GENERIC_READ | GENERIC_WRITE,=0A= - 0,=0A= - 0,=0A= - OPEN_EXISTING,=0A= - FILE_FLAG_OVERLAPPED,=0A= - 0=0A= - );=0A= + handle =3D CreateFile(pathname,=0A= + GENERIC_READ | GENERIC_WRITE,=0A= + 0, 0, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, 0);=0A= =0A= - if( handle =3D=3D INVALID_HANDLE_VALUE )=0A= - goto co_os_open_daemon_pipe_error ;=0A= + if (handle =3D=3D INVALID_HANDLE_VALUE)=0A= + goto co_os_open_daemon_pipe_error;=0A= =0A= /* Identify ourselves to the daemon */=0A= - if( ! WriteFile( handle , &module_id , sizeof(module_id) , &written, = NULL ) ) {=0A= - co_debug( "pipe client %d/%d: Attachment failed\n" , linux_id , = module_id ) ;=0A= - goto co_os_open_daemon_pipe_error ;=0A= - }=0A= -=0A= - if( ! ( daemon_handle =3D co_os_malloc(sizeof(*daemon_handle)) ) )=0A= - goto co_os_open_daemon_pipe_error ;=0A= - daemon_handle->handle =3D handle ;=0A= - daemon_handle->loop =3D 1 ;=0A= - daemon_handle->rc =3D CO_RC( OK ) ;=0A= - daemon_handle->message =3D 0 ;=0A= - daemon_handle->shifted =3D CreateEvent( 0 , FALSE , FALSE , 0 ) ;=0A= - daemon_handle->readable =3D CreateEvent( 0 , TRUE , TRUE , 0 ) ;=0A= - if( ! ( daemon_handle->shifted && daemon_handle->readable ) )=0A= - goto co_os_open_daemon_pipe_error ;=0A= - daemon_handle->thread =3D CreateThread( 0 , 0 , co_os_daemon_thread , = daemon_handle , 0 , 0 ) ;=0A= -=0A= - if( daemon_handle->thread ) {=0A= - *handle_out =3D daemon_handle ;=0A= - return CO_RC( OK ) ;=0A= - }=0A= -=0A= - co_debug("co_os_daemon_thread() did not start\n") ;=0A= -=0A= - co_os_open_daemon_pipe_error:=0A= - if( daemon_handle ) {=0A= - if( daemon_handle->readable )=0A= - CloseHandle( daemon_handle->readable ) ;=0A= - if( daemon_handle->shifted )=0A= - CloseHandle( daemon_handle->shifted ) ;=0A= - if( daemon_handle->thread )=0A= - CloseHandle( daemon_handle->thread ) ;=0A= - co_os_free( daemon_handle ) ;=0A= - }=0A= - if( handle !=3D INVALID_HANDLE_VALUE )=0A= - CloseHandle( handle ) ;=0A= - return CO_RC( ERROR ) ;=0A= + if (!WriteFile(handle, &module_id, sizeof (module_id), &written, = NULL)) {=0A= + co_debug("pipe client %d/%d: Attachment failed\n", linux_id,=0A= + module_id);=0A= + goto co_os_open_daemon_pipe_error;=0A= + }=0A= +=0A= + if (!(daemon_handle =3D co_os_malloc(sizeof (*daemon_handle))))=0A= + goto co_os_open_daemon_pipe_error;=0A= + daemon_handle->handle =3D handle;=0A= + daemon_handle->loop =3D 1;=0A= + daemon_handle->rc =3D CO_RC(OK);=0A= + daemon_handle->message =3D 0;=0A= + daemon_handle->shifted =3D CreateEvent(0, FALSE, FALSE, 0);=0A= + daemon_handle->readable =3D CreateEvent(0, TRUE, TRUE, 0);=0A= + if (!(daemon_handle->shifted && daemon_handle->readable))=0A= + goto co_os_open_daemon_pipe_error;=0A= + daemon_handle->thread =3D=0A= + CreateThread(0, 0, co_os_daemon_thread, daemon_handle, 0, 0);=0A= +=0A= + if (daemon_handle->thread) {=0A= + *handle_out =3D daemon_handle;=0A= + return CO_RC(OK);=0A= + }=0A= +=0A= + co_debug("co_os_daemon_thread() did not start\n");=0A= +=0A= + co_os_open_daemon_pipe_error:=0A= + if (daemon_handle) {=0A= + if (daemon_handle->readable)=0A= + CloseHandle(daemon_handle->readable);=0A= + if (daemon_handle->shifted)=0A= + CloseHandle(daemon_handle->shifted);=0A= + if (daemon_handle->thread)=0A= + CloseHandle(daemon_handle->thread);=0A= + co_os_free(daemon_handle);=0A= + }=0A= + if (handle !=3D INVALID_HANDLE_VALUE)=0A= + CloseHandle(handle);=0A= + return CO_RC(ERROR);=0A= }=0A= =0A= -co_rc_t co_os_daemon_get_message(co_daemon_handle_t handle, =0A= - co_message_t **message_out,=0A= - unsigned long timeout)=0A= +co_rc_t=0A= +co_os_daemon_get_message(co_daemon_handle_t handle,=0A= + co_message_t ** message_out, unsigned long timeout)=0A= {=0A= - DWORD r ;=0A= - co_rc_t rc =3D handle->rc ;=0A= + DWORD r;=0A= + co_rc_t rc =3D handle->rc;=0A= =0A= - *message_out =3D NULL; =0A= + *message_out =3D NULL;=0A= =0A= - if( handle->message ) {=0A= - *message_out =3D handle->message ;=0A= - handle->message =3D 0 ;=0A= - return CO_RC( OK ) ;=0A= + if (handle->message) {=0A= + *message_out =3D handle->message;=0A= + handle->message =3D 0;=0A= + return CO_RC(OK);=0A= }=0A= =0A= - if( ! CO_OK( rc ) )=0A= - return rc ;=0A= -=0A= - SetEvent( handle->shifted ) ;=0A= + if (!CO_OK(rc))=0A= + return rc;=0A= =0A= - r =3D MsgWaitForMultipleObjects( 1 , &handle->readable , FALSE , = timeout , QS_ALLEVENTS ) ;=0A= - if( r =3D=3D WAIT_TIMEOUT || r =3D=3D WAIT_OBJECT_0 + 1 )=0A= - return CO_RC( TIMEOUT ) ;=0A= + SetEvent(handle->shifted);=0A= =0A= - if( handle->message ) {=0A= - *message_out =3D handle->message ;=0A= - handle->message =3D 0 ;=0A= + r =3D MsgWaitForMultipleObjects(1, &handle->readable, FALSE, timeout,=0A= + QS_ALLEVENTS);=0A= + if (r =3D=3D WAIT_TIMEOUT || r =3D=3D WAIT_OBJECT_0 + 1)=0A= + return CO_RC(TIMEOUT);=0A= +=0A= + if (handle->message) {=0A= + *message_out =3D handle->message;=0A= + handle->message =3D 0;=0A= }=0A= - SetEvent( handle->shifted ) ;=0A= + SetEvent(handle->shifted);=0A= =0A= - return CO_RC( OK ) ;=0A= + return CO_RC(OK);=0A= }=0A= =0A= -co_rc_t co_os_daemon_send_message(co_daemon_handle_t handle, = co_message_t *message)=0A= +co_rc_t=0A= +co_os_daemon_send_message(co_daemon_handle_t handle, co_message_t * = message)=0A= {=0A= unsigned long bytes_written;=0A= - unsigned long bytes_to_write =3D sizeof(*message) + message->size;=0A= + unsigned long bytes_to_write =3D sizeof (*message) + message->size;=0A= BOOL ret;=0A= =0A= - ret =3D WriteFile(handle->handle, (char *)message, =0A= - bytes_to_write, &bytes_written, NULL);=0A= + ret =3D WriteFile(handle->handle, (char *) message,=0A= + bytes_to_write, &bytes_written, NULL);=0A= =0A= if (ret !=3D TRUE)=0A= return CO_RC(ERROR);=0A= =0A= - if ( bytes_written !=3D bytes_to_write )=0A= + if (bytes_written !=3D bytes_to_write)=0A= return CO_RC(ERROR);=0A= =0A= return CO_RC(OK);=0A= }=0A= =0A= -static DWORD WINAPI co_os_daemon_thread( LPVOID D )=0A= +static DWORD WINAPI=0A= +co_os_daemon_thread(LPVOID D)=0A= {=0A= - co_daemon_handle_t d =3D D ;=0A= - HANDLE h =3D d->handle ;=0A= - HANDLE w[2] ;=0A= - OVERLAPPED overlapped ;=0A= - DWORD r ;=0A= - co_message_t * data =3D 0 ;=0A= - bool_t queued =3D 0 ;=0A= - unsigned qItems =3D 0 ;=0A= - unsigned qOut =3D 0 ;=0A= - unsigned qIn =3D 0 ;=0A= - co_message_t ** queue =3D 0 ;=0A= - co_message_t ** _q ;=0A= - unsigned _i ;=0A= - unsigned _o ;=0A= - co_rc_t rc ;=0A= - =0A= - r =3D WaitForSingleObject( d->shifted , INFINITE ) ;=0A= - if( r =3D=3D WAIT_FAILED )=0A= - goto co_os_daemon_thread_error ;=0A= -=0A= - queue =3D co_os_malloc( ( qItems =3D = CO_OS_DAEMON_QUEUE_ITEMS_BASIC_MINIMUM ) * sizeof( co_message_t * ) ) ;=0A= -=0A= - overlapped.hEvent =3D CreateEvent( 0 , TRUE , FALSE , 0 ) ;=0A= -=0A= - if( ! ( queue && overlapped.hEvent ) )=0A= - goto co_os_daemon_thread_error ;=0A= -=0A= - w[0] =3D overlapped.hEvent ;=0A= - w[1] =3D d->shifted ;=0A= -=0A= - while( d->loop ) {=0A= - if( ! ( d->message || qIn =3D=3D qOut ) ) {=0A= - d->message =3D queue[ qOut++ ] ; - SetEvent( d->readable ) ; - if( qOut =3D=3D qItems ) - qOut =3D 0 ; - } - if( queued ) {=0A= - r =3D WaitForMultipleObjects( 2 , w , FALSE , INFINITE ) ;=0A= - if( r =3D=3D WAIT_FAILED )=0A= - goto co_os_daemon_thread_error ;=0A= - if( ! d->message )=0A= - ResetEvent( d->readable ) ;=0A= - if( r !=3D WAIT_OBJECT_0 )=0A= - continue ;=0A= - if( ! GetOverlappedResult( h , &overlapped , &r , FALSE ) ) {=0A= - r =3D GetLastError() ;=0A= - if( r =3D=3D ERROR_IO_INCOMPLETE )=0A= - continue ;=0A= - if( r =3D=3D ERROR_IO_PENDING )=0A= - continue ;=0A= - if( r =3D=3D ERROR_BROKEN_PIPE )=0A= - goto co_os_daemon_thread_broken_pipe ;=0A= - goto co_os_daemon_thread_error ;=0A= + co_daemon_handle_t d =3D D;=0A= + HANDLE h =3D d->handle;=0A= + HANDLE w[2];=0A= + OVERLAPPED overlapped;=0A= + DWORD r;=0A= + co_message_t *data =3D 0;=0A= + bool_t queued =3D 0;=0A= + unsigned qItems =3D 0;=0A= + unsigned qOut =3D 0;=0A= + unsigned qIn =3D 0;=0A= + co_message_t **queue =3D 0;=0A= + co_rc_t rc;=0A= +=0A= + co_message_t **_q;=0A= + unsigned _i;=0A= + unsigned _o;=0A= +=0A= +# define Q_REALLOC_1() \=0A= + (_q =3D co_os_realloc( \=0A= + (void *) queue, \=0A= + sizeof (co_message_t *) * (_i =3D (qItems * 2))))=0A= +=0A= +# define Q_REALLOC_2() \=0A= + (_q =3D (co_message_t **) co_os_realloc( \=0A= + (void *) queue, \=0A= + sizeof (co_message_t *) * (_i =3D (qItems * 2))))=0A= +=0A= +# define Q_COPY_2() \=0A= + memcpy( \=0A= + _q + (qOut +=3D qItems), _q + _o, \=0A= + sizeof (co_message_t *) * (qItems - _o))=0A= +=0A= +# define NT_ERROR(_1) { \=0A= + co_debug("co_os_daemon_thread() error [ %x , %s ]\n", \=0A= + GetLastError(), \=0A= + _1); \=0A= + goto co_os_daemon_thread_error_winnt; \=0A= + }=0A= +=0A= + r =3D WaitForSingleObject(d->shifted, INFINITE);=0A= + if (r =3D=3D WAIT_FAILED)=0A= + NT_ERROR("W0001");=0A= +=0A= + queue =3D=0A= + co_os_malloc((qItems =3D=0A= + CO_OS_DAEMON_QUEUE_ITEMS_BASIC_MINIMUM) *=0A= + sizeof (co_message_t *));=0A= + if (!queue)=0A= + goto co_os_daemon_thread_error;=0A= +=0A= + overlapped.hEvent =3D CreateEvent(0, TRUE, FALSE, 0);=0A= +=0A= + if (!overlapped.hEvent)=0A= + NT_ERROR("CE001");=0A= +=0A= + w[0] =3D overlapped.hEvent;=0A= + w[1] =3D d->shifted;=0A= +=0A= + while (d->loop) {=0A= + if (!(d->message || qIn =3D=3D qOut)) {=0A= + d->message =3D queue[qOut++];=0A= + SetEvent(d->readable);=0A= + if (qOut =3D=3D qItems)=0A= + qOut =3D 0;=0A= + }=0A= + if (queued) {=0A= + r =3D WaitForMultipleObjects(2, w, FALSE, INFINITE);=0A= + if (r =3D=3D WAIT_FAILED)=0A= + NT_ERROR("W0002");=0A= + if (!d->message)=0A= + ResetEvent(d->readable);=0A= + if (r !=3D WAIT_OBJECT_0)=0A= + continue;=0A= + if (!GetOverlappedResult(h, &overlapped, &r, FALSE)) {=0A= + r =3D GetLastError();=0A= + if (r =3D=3D ERROR_IO_INCOMPLETE)=0A= + continue;=0A= + if (r =3D=3D ERROR_IO_PENDING)=0A= + continue;=0A= + if (r =3D=3D ERROR_BROKEN_PIPE)=0A= + goto co_os_daemon_thread_broken_pipe;=0A= + NT_ERROR("GOR01");=0A= + }=0A= + queue[qIn++] =3D data;=0A= + queued =3D PFALSE;=0A= + if (qIn =3D=3D qItems)=0A= + if (qOut)=0A= + qIn =3D 0;=0A= + else {=0A= + if (!Q_REALLOC_1())=0A= + goto co_os_daemon_thread_error;=0A= + queue =3D _q, qItems =3D _i;=0A= + } else if (qIn =3D=3D qOut) {=0A= + if (!!Q_REALLOC_2())=0A= + goto co_os_daemon_thread_error;=0A= + _o =3D qOut;=0A= + Q_COPY_2();=0A= + queue =3D _q, qItems =3D _i;=0A= }=0A= - queue[ qIn++ ] =3D data ; - queued =3D PFALSE ; - if( qIn =3D=3D qItems ) - if( qOut ) - qIn =3D 0 ; - else { - if( ! ( _q =3D co_os_realloc( (void*) queue , sizeof(co_message_t = *) * ( _i =3D ( qItems * 2 ) ) ) ) ) - goto co_os_daemon_thread_error ; - queue =3D _q , qItems =3D _i ; - } - else - if( qIn =3D=3D qOut ) { - if( ! ( _q =3D (co_message_t **) co_os_realloc( (void*) queue , = sizeof(co_message_t *) * ( _i =3D ( qItems * 2 ) ) ) ) ) - goto co_os_daemon_thread_error ; - _o =3D qOut ; - memcpy( _q + ( qOut +=3D qItems ) , _q + _o , sizeof(co_message_t = *) * ( qItems - _o ) ) ; - queue =3D _q , qItems =3D _i ; - } }=0A= - if( ! queued ) {=0A= - if( ! PeekNamedPipe( h , 0 , 0 , 0 , 0 , &r ) )=0A= - goto co_os_daemon_thread_error ;=0A= - data =3D co_os_malloc( r ) ;=0A= - if( ! data )=0A= - goto co_os_daemon_thread_error ;=0A= - queued =3D PTRUE ;=0A= - if( ! ReadFile( h , data , r , 0 , &overlapped ) ) {=0A= - r =3D GetLastError() ;=0A= - if( r =3D=3D ERROR_IO_INCOMPLETE )=0A= - continue ;=0A= - if( r =3D=3D ERROR_IO_PENDING )=0A= - continue ;=0A= - if( r =3D=3D ERROR_BROKEN_PIPE )=0A= - goto co_os_daemon_thread_broken_pipe ;=0A= - goto co_os_daemon_thread_error ;=0A= + if (!queued) {=0A= + if (!PeekNamedPipe(h, 0, 0, 0, 0, &r))=0A= + NT_ERROR("PNP01");=0A= + data =3D co_os_malloc(r);=0A= + if (!data)=0A= + goto co_os_daemon_thread_error;=0A= + queued =3D PTRUE;=0A= + if (!ReadFile(h, data, r, 0, &overlapped)) {=0A= + r =3D GetLastError();=0A= + if (r =3D=3D ERROR_IO_INCOMPLETE)=0A= + continue;=0A= + if (r =3D=3D ERROR_IO_PENDING)=0A= + continue;=0A= + if (r =3D=3D ERROR_BROKEN_PIPE)=0A= + goto co_os_daemon_thread_broken_pipe;=0A= + NT_ERROR("RF001");=0A= }=0A= }=0A= }=0A= =0A= - rc =3D CO_RC( OK ) ;=0A= + rc =3D CO_RC(OK);=0A= =0A= - co_os_daemon_thread_return:=0A= - if ( queued ) {=0A= - CancelIo( h ) ;=0A= - co_os_free( data ) ;=0A= - }=0A= - while( d->loop && qIn !=3D qOut ) {=0A= - if( ! d->message ) {=0A= - d->message =3D queue[ qOut++ ] ; - SetEvent( d->readable ) ; - if( qOut =3D=3D qItems ) - qOut =3D 0 ; - } - r =3D WaitForSingleObject( w[1] , INFINITE ) ;=0A= - if( r =3D=3D WAIT_FAILED ) {=0A= - if( ! CO_OK( rc ) )=0A= - break ;=0A= - goto co_os_daemon_thread_error ;=0A= - }=0A= - if( ! d->message )=0A= - ResetEvent( d->readable ) ;=0A= + co_os_daemon_thread_return:=0A= + if (queued) {=0A= + CancelIo(h);=0A= + co_os_free(data);=0A= + }=0A= + while (d->loop && qIn !=3D qOut) {=0A= + if (!d->message) {=0A= + d->message =3D queue[qOut++];=0A= + SetEvent(d->readable);=0A= + if (qOut =3D=3D qItems)=0A= + qOut =3D 0;=0A= + }=0A= + r =3D WaitForSingleObject(w[1], INFINITE);=0A= + if (r =3D=3D WAIT_FAILED) {=0A= + if (!CO_OK(rc))=0A= + break;=0A= + NT_ERROR("W0003");=0A= }=0A= - while( qIn !=3D qOut ) {=0A= - co_os_free( queue[ qOut++ ] ) ; - if( qOut =3D=3D qItems ) - qOut =3D 0 ; - } - if( queue )=0A= - co_os_free( queue ) ;=0A= - if( overlapped.hEvent )=0A= - CloseHandle( overlapped.hEvent ) ;=0A= - d->rc =3D rc ;=0A= - if( d->loop )=20 - SetEvent( d->readable ) ;=0A= - return 0 ;=0A= -=0A= - co_os_daemon_thread_error:=0A= - co_debug( "co_os_daemon_thread() error\n" ) ;=0A= - rc =3D CO_RC( ERROR ) ;=0A= - goto co_os_daemon_thread_return ;=0A= -=0A= - co_os_daemon_thread_broken_pipe:=0A= - rc =3D CO_RC( BROKEN_PIPE ) ;=0A= - goto co_os_daemon_thread_return ;=0A= + if (!d->message)=0A= + ResetEvent(d->readable);=0A= + }=0A= + while (qIn !=3D qOut) {=0A= + co_os_free(queue[qOut++]);=0A= + if (qOut =3D=3D qItems)=0A= + qOut =3D 0;=0A= + }=0A= + if (queue)=0A= + co_os_free(queue);=0A= + if (overlapped.hEvent)=0A= + CloseHandle(overlapped.hEvent);=0A= + d->rc =3D rc;=0A= + if (d->loop)=0A= + SetEvent(d->readable);=0A= + return 0;=0A= +=0A= + co_os_daemon_thread_error_winnt:=0A= + rc =3D CO_RC(ERROR);=0A= + goto co_os_daemon_thread_return;=0A= +=0A= + co_os_daemon_thread_error:=0A= + co_debug("co_os_daemon_thread() error\n");=0A= + rc =3D CO_RC(ERROR);=0A= + goto co_os_daemon_thread_return;=0A= +=0A= + co_os_daemon_thread_broken_pipe:=0A= + rc =3D CO_RC(BROKEN_PIPE);=0A= + goto co_os_daemon_thread_return;=0A= +=0A= +# undef Q_REALLOC_1=0A= +# undef Q_REALLOC_2=0A= +# undef Q_COPY_2=0A= }=0A= =0A= -void co_os_daemon_close( co_daemon_handle_t D )=0A= +void=0A= +co_os_daemon_close(co_daemon_handle_t D)=0A= {=0A= - D->loop =3D 0 ;=0A= - SetEvent( D->shifted ) ;=0A= - WaitForSingleObject( D->thread , INFINITE ) ;=0A= - CloseHandle( D->readable ) ;=0A= - CloseHandle( D->shifted ) ;=0A= - CloseHandle( D->handle );=0A= - CloseHandle( D->thread );=0A= - co_os_free( D ) ;=0A= + D->loop =3D 0;=0A= + SetEvent(D->shifted);=0A= + WaitForSingleObject(D->thread, INFINITE);=0A= + CloseHandle(D->readable);=0A= + CloseHandle(D->shifted);=0A= + CloseHandle(D->handle);=0A= + CloseHandle(D->thread);=0A= + co_os_free(D);=0A= }=0A= Index: COLINUX_0/src/colinux/os/winnt/user/daemon.h=0A= diff -u COLINUX_0/src/colinux/os/winnt/user/daemon.h:1.3 = COLINUX_0/src/colinux/os/winnt/user/daemon.h:1.4=0A= --- COLINUX_0/src/colinux/os/winnt/user/daemon.h:1.3 Sun Feb 22 11:04:02 = 2004=0A= +++ COLINUX_0/src/colinux/os/winnt/user/daemon.h Mon Feb 23 15:28:53 2004=0A= @@ -5,12 +5,12 @@=0A= *=0A= * The code is licensed under the GPL. See the COPYING file at=0A= * the root directory.=0A= - */ =0A= + */=0A= =0A= /*=0A= * Ballard, Jonathan H. <cal...@us...>=0A= * 2004 02 22 : Redesigned co_daemon_handle for use with = co_os_daemon_thread()=0A= - */ =0A= + */=0A= =0A= #ifndef __COLINUX_USER_WINNT_DAEMON_H__=0A= #define __COLINUX_USER_WINNT_DAEMON_H__=0A= @@ -20,13 +20,13 @@=0A= #include <colinux/os/user/daemon.h>=0A= =0A= struct co_daemon_handle {=0A= - HANDLE handle ;=0A= - HANDLE thread ;=0A= - HANDLE readable ;=0A= - HANDLE shifted ;=0A= - co_message_t * message ;=0A= - co_rc_t rc ;=0A= - bool_t loop ;=0A= + HANDLE handle;=0A= + HANDLE thread;=0A= + HANDLE readable;=0A= + HANDLE shifted;=0A= + co_message_t *message;=0A= + co_rc_t rc;=0A= + bool_t loop;=0A= };=0A= =0A= #define CO_OS_DAEMON_QUEUE_ITEMS_BASIC_MINIMUM 0x100=0A= |