Author: gonzalo
Date: 2005-04-07 20:21:29 -0400 (Thu, 07 Apr 2005)
New Revision: 42670

Modified:
   trunk/mono/mono/io-layer/ChangeLog
   trunk/mono/mono/io-layer/io-private.h
   trunk/mono/mono/io-layer/io.c
   trunk/mono/mono/io-layer/sockets.c
   trunk/mono/mono/io-layer/sockets.h
   trunk/mono/mono/io-layer/threads.c
   trunk/mono/mono/io-layer/threads.h
Log:
2005-04-07 Gonzalo Paniagua Javier <[EMAIL PROTECTED]>

        * io-private.h:
        * threads.c:
        * threads.h:
        * io.c:
        * sockets.c:
        * sockets.h: removed dead code that deals with async IO.



Modified: trunk/mono/mono/io-layer/ChangeLog
===================================================================
--- trunk/mono/mono/io-layer/ChangeLog  2005-04-08 00:20:20 UTC (rev 42669)
+++ trunk/mono/mono/io-layer/ChangeLog  2005-04-08 00:21:29 UTC (rev 42670)
@@ -1,3 +1,12 @@
+2005-04-07 Gonzalo Paniagua Javier <[EMAIL PROTECTED]>
+
+       * io-private.h:
+       * threads.c:
+       * threads.h:
+       * io.c:
+       * sockets.c:
+       * sockets.h: removed dead code that deals with async IO.
+
 2005-03-30  Zoltan Varga  <[EMAIL PROTECTED]>
 
        * atomic.c (InterlockedIncrement): Fix fallback implementation of

Modified: trunk/mono/mono/io-layer/io-private.h
===================================================================
--- trunk/mono/mono/io-layer/io-private.h       2005-04-08 00:20:20 UTC (rev 
42669)
+++ trunk/mono/mono/io-layer/io-private.h       2005-04-08 00:21:29 UTC (rev 
42670)
@@ -37,8 +37,6 @@
 struct _WapiHandlePrivate_file
 {
        WapiFDMapped fd_mapped;
-       gboolean async;
-       WapiOverlappedCB callback;
 };
 
 struct _WapiHandle_find
@@ -56,9 +54,6 @@
 
 G_BEGIN_DECLS
 int _wapi_file_handle_to_fd (gpointer handle);
-gboolean _wapi_io_add_callback (gpointer handle,
-                               WapiOverlappedCB callback,
-                               guint64 flags);
 G_END_DECLS
 
 #endif /* _WAPI_IO_PRIVATE_H_ */

Modified: trunk/mono/mono/io-layer/io.c
===================================================================
--- trunk/mono/mono/io-layer/io.c       2005-04-08 00:20:20 UTC (rev 42669)
+++ trunk/mono/mono/io-layer/io.c       2005-04-08 00:21:29 UTC (rev 42670)
@@ -20,18 +20,6 @@
 #include <stdio.h>
 #include <utime.h>
 
-#ifndef PLATFORM_WIN32
-#ifdef HAVE_AIO_H
-#include <aio.h>
-#define USE_AIO        1
-#elif defined(HAVE_SYS_AIO_H)
-#include <sys/aio.h>
-#define USE_AIO 1
-#else
-#undef USE_AIO
-#endif
-#endif
-
 #include <mono/io-layer/wapi.h>
 #include <mono/io-layer/wapi-private.h>
 #include <mono/io-layer/handles-private.h>
@@ -286,38 +274,6 @@
        return(FILE_TYPE_DISK);
 }
 
-#ifdef USE_AIO
-typedef struct {
-       struct aiocb *aio;
-       WapiOverlapped *overlapped;
-       WapiOverlappedCB callback;
-} notifier_data_t;
-
-#define SIGPTR(a) a.SIGVAL_PTR
-
-static void
-async_notifier (union sigval sig)
-{
-       notifier_data_t *ndata = SIGPTR (sig);
-       guint32 error;
-       guint32 numbytes;
-
-       error = aio_return (ndata->aio);
-       if (error < 0) {
-               error = _wapi_get_win32_file_error (error);
-               numbytes = 0;
-       } else {
-               numbytes = error;
-               error = 0;
-       }
-
-       ndata->callback (error, numbytes, ndata->overlapped);
-       g_free (ndata->aio);
-       g_free (ndata);
-}
-
-#endif /* USE_AIO */
-
 static gboolean file_read(gpointer handle, gpointer buffer,
                          guint32 numbytes, guint32 *bytesread,
                          WapiOverlapped *overlapped)
@@ -356,90 +312,30 @@
                return(FALSE);
        }
 
-       if (file_private_handle->async == FALSE) {
-               do {
-                       ret=read(file_private_handle->fd_mapped.fd, buffer,
-                                numbytes);
-               }
-               while (ret==-1 && errno==EINTR && 
!_wapi_thread_cur_apc_pending());
-                       
-               if(ret==-1) {
-                       gint err = errno;
-
-#ifdef DEBUG
-                       g_message(G_GNUC_PRETTY_FUNCTION
-                                 ": read of handle %p fd %d error: %s", handle,
-                                 file_private_handle->fd_mapped.fd,
-                                 strerror(err));
-#endif
-                       SetLastError (_wapi_get_win32_file_error (err));
-                       return(FALSE);
-               }
-               
-               if(bytesread!=NULL) {
-                       *bytesread=ret;
-               }
-               
-               return(TRUE);
+       do {
+               ret=read(file_private_handle->fd_mapped.fd, buffer,
+                        numbytes);
        }
+       while (ret==-1 && errno==EINTR && !_wapi_thread_cur_apc_pending());
+               
+       if(ret==-1) {
+               gint err = errno;
 
-#ifndef USE_AIO
-       SetLastError (ERROR_NOT_SUPPORTED);
-       return FALSE;
-#else
-       if (overlapped == NULL || file_private_handle->callback == NULL) {
-               SetLastError (ERROR_INVALID_PARAMETER);
-               return FALSE;
-       }
-
-       {
-       int fd = file_private_handle->fd_mapped.fd;
-       struct aiocb *aio;
-       int result;
-       notifier_data_t *ndata;
-
-       ndata = g_new0 (notifier_data_t, 1);
-       aio = g_new0 (struct aiocb, 1);
-       ndata->overlapped = overlapped;
-       ndata->aio = aio;
-       ndata->callback = file_private_handle->callback;
-
-       aio->aio_fildes = fd;
-       aio->aio_lio_opcode = LIO_READ;
-       aio->aio_nbytes = numbytes;
-       aio->aio_offset = overlapped->Offset + (((gint64) 
overlapped->OffsetHigh) << 32);
-       aio->aio_buf = buffer;
-       aio->aio_sigevent.sigev_notify = SIGEV_THREAD;
-       aio->aio_sigevent.sigev_notify_function = async_notifier;
-       SIGPTR (aio->aio_sigevent.sigev_value) = ndata;
-
-       result = aio_read (aio);
-       if (result == -1) {
-               _wapi_set_last_error_from_errno ();
-               return FALSE;
-       }
-
-       result = aio_error (aio);
 #ifdef DEBUG
-       g_print ("aio_error (read) returned %d for %d\n", result, fd);
+               g_message(G_GNUC_PRETTY_FUNCTION
+                         ": read of handle %p fd %d error: %s", handle,
+                         file_private_handle->fd_mapped.fd,
+                         strerror(err));
 #endif
-       if (result == 0) {
-               numbytes = aio_return (aio);
-#ifdef DEBUG
-               g_print ("numbytes %d for %d\n", numbytes, fd);
-#endif
-       } else {
-               errno = result;
-               _wapi_set_last_error_from_errno ();
-               return FALSE;
+               SetLastError (_wapi_get_win32_file_error (err));
+               return(FALSE);
        }
-
-       if (bytesread)
-               *bytesread = numbytes;
-
-       return TRUE;
+       
+       if(bytesread!=NULL) {
+               *bytesread=ret;
        }
-#endif
+       
+       return(TRUE);
 }
 
 static gboolean file_write(gpointer handle, gconstpointer buffer,
@@ -450,6 +346,7 @@
        struct _WapiHandlePrivate_file *file_private_handle;
        gboolean ok;
        int ret;
+       off_t current_pos;
        
        ok=_wapi_lookup_handle (handle, WAPI_HANDLE_FILE,
                                (gpointer *)&file_handle,
@@ -480,116 +377,54 @@
                return(FALSE);
        }
        
-       if (file_private_handle->async == FALSE) {
-               off_t current_pos;
-               
-               /* Need to lock the region we're about to write to,
-                * because we only do advisory locking on POSIX
-                * systems
-                */
-               current_pos = lseek (file_private_handle->fd_mapped.fd,
-                                    (off_t)0, SEEK_CUR);
-               if (current_pos == -1) {
+       /* Need to lock the region we're about to write to,
+        * because we only do advisory locking on POSIX
+        * systems
+        */
+       current_pos = lseek (file_private_handle->fd_mapped.fd,
+                            (off_t)0, SEEK_CUR);
+       if (current_pos == -1) {
 #ifdef DEBUG
-                       g_message (G_GNUC_PRETTY_FUNCTION ": handle %p fd %d 
lseek failed: %s", handle, file_private_handle->fd_mapped.fd, strerror (errno));
+               g_message (G_GNUC_PRETTY_FUNCTION ": handle %p fd %d lseek 
failed: %s", handle, file_private_handle->fd_mapped.fd, strerror (errno));
 #endif
-                       _wapi_set_last_error_from_errno ();
-                       return(FALSE);
-               }
-               
-               if (_wapi_lock_file_region (file_private_handle->fd_mapped.fd,
-                                           current_pos, numbytes) == FALSE) {
-                       /* The error has already been set */
-                       return(FALSE);
-               }
-               
-               do {
-                       ret=write(file_private_handle->fd_mapped.fd, buffer,
-                                 numbytes);
-               }
-               while (ret==-1 && errno==EINTR && 
!_wapi_thread_cur_apc_pending());
-
-               _wapi_unlock_file_region (file_private_handle->fd_mapped.fd,
-                                         current_pos, numbytes);
-
-               if (ret == -1) {
-                       if (errno == EINTR) {
-                               ret = 0;
-                       } else {
-                               _wapi_set_last_error_from_errno ();
-#ifdef DEBUG
-                       g_message(G_GNUC_PRETTY_FUNCTION
-                                 ": write of handle %p fd %d error: %s", 
handle,
-                                 file_private_handle->fd_mapped.fd,
-                                 strerror(errno));
-#endif
-
-                               return(FALSE);
-                       }
-               }
-               if(byteswritten!=NULL) {
-                       *byteswritten=ret;
-               }
-               return(TRUE);
+               _wapi_set_last_error_from_errno ();
+               return(FALSE);
        }
-
-#ifndef USE_AIO
-       SetLastError (ERROR_NOT_SUPPORTED);
-       return FALSE;
-#else
-       if (overlapped == NULL || file_private_handle->callback == NULL) {
-               SetLastError (ERROR_INVALID_PARAMETER);
-               return FALSE;
+       
+       if (_wapi_lock_file_region (file_private_handle->fd_mapped.fd,
+                                   current_pos, numbytes) == FALSE) {
+               /* The error has already been set */
+               return(FALSE);
        }
-
-       {
-       int fd = file_private_handle->fd_mapped.fd;
-       struct aiocb *aio;
-       int result;
-       notifier_data_t *ndata;
-
-       ndata = g_new0 (notifier_data_t, 1);
-       aio = g_new0 (struct aiocb, 1);
-       ndata->overlapped = overlapped;
-       ndata->aio = aio;
-       ndata->callback = file_private_handle->callback;
-
-       aio->aio_fildes = fd;
-       aio->aio_lio_opcode = LIO_WRITE;
-       aio->aio_nbytes = numbytes;
-       aio->aio_offset = overlapped->Offset + (((gint64) 
overlapped->OffsetHigh) << 32);
-       aio->aio_buf = (gpointer) buffer;
-       aio->aio_sigevent.sigev_notify = SIGEV_THREAD;
-       aio->aio_sigevent.sigev_notify_function = async_notifier;
-       SIGPTR (aio->aio_sigevent.sigev_value) = ndata;
-
-       result = aio_write (aio);
-       if (result == -1) {
-               _wapi_set_last_error_from_errno ();
-               return FALSE;
+       
+       do {
+               ret=write(file_private_handle->fd_mapped.fd, buffer,
+                         numbytes);
        }
+       while (ret==-1 && errno==EINTR && !_wapi_thread_cur_apc_pending());
 
-       result = aio_error (aio);
+       _wapi_unlock_file_region (file_private_handle->fd_mapped.fd,
+                                 current_pos, numbytes);
+
+       if (ret == -1) {
+               if (errno == EINTR) {
+                       ret = 0;
+               } else {
+                       _wapi_set_last_error_from_errno ();
 #ifdef DEBUG
-       g_print ("aio_error (write) returned %d for %d\n", result, fd);
+               g_message(G_GNUC_PRETTY_FUNCTION
+                         ": write of handle %p fd %d error: %s", handle,
+                         file_private_handle->fd_mapped.fd,
+                         strerror(errno));
 #endif
-       if (result == 0) {
-               numbytes = aio_return (aio);
-#ifdef DEBUG
-       g_print ("numbytes %d for %d\n", numbytes, fd);
-#endif
-       } else {
-               errno = result;
-               _wapi_set_last_error_from_errno ();
-               return FALSE;
-       }
 
-       if (byteswritten)
-               *byteswritten = numbytes;
-
-       return TRUE;
+                       return(FALSE);
+               }
        }
-#endif
+       if(byteswritten!=NULL) {
+               *byteswritten=ret;
+       }
+       return(TRUE);
 }
 
 static gboolean file_flush(gpointer handle)
@@ -1873,7 +1708,6 @@
 
        file_private_handle->fd_mapped.fd=fd;
        file_private_handle->fd_mapped.assigned=TRUE;
-       file_private_handle->async = ((attrs & FILE_FLAG_OVERLAPPED) != 0);
        file_handle->filename=_wapi_handle_scratch_store (filename,
                                                          strlen (filename));
        if(security!=NULL) {
@@ -4019,60 +3853,6 @@
        return(ret);
 }
 
-gboolean
-_wapi_io_add_callback (gpointer fd_handle,
-                      WapiOverlappedCB callback,
-                      guint64 flags G_GNUC_UNUSED)
-{
-       struct _WapiHandle_file *file_handle;
-       struct _WapiHandlePrivate_file *file_private_handle;
-       gboolean ok;
-       int thr_ret;
-       gboolean ret = FALSE;
-       gpointer handle = _wapi_handle_fd_offset_to_handle (fd_handle);
-       
-       if (handle == NULL) {
-               SetLastError (ERROR_INVALID_HANDLE);
-               return(FALSE);
-       }
-       
-       ok = _wapi_lookup_handle (handle, WAPI_HANDLE_FILE,
-                                 (gpointer *) &file_handle,
-                                 (gpointer *) &file_private_handle);
-
-       if (ok == FALSE) {
-               ok = _wapi_lookup_handle (handle, WAPI_HANDLE_PIPE,
-                                         (gpointer *) &file_handle,
-                                         (gpointer *) &file_private_handle);
-
-       }
-
-       if (ok == FALSE || file_private_handle->async == FALSE) {
-               SetLastError (ERROR_INVALID_HANDLE);
-               return FALSE;
-       }
-
-       pthread_cleanup_push ((void(*)(void *))_wapi_handle_unlock_handle,
-                             handle);
-       thr_ret = _wapi_handle_lock_handle (handle);
-       g_assert (thr_ret == 0);
-       
-       if (file_private_handle->callback != NULL) {
-               SetLastError (ERROR_INVALID_PARAMETER);
-               goto cleanup;
-       }
-       ret = TRUE;
-       
-       file_private_handle->callback = callback;
-
-cleanup:
-       thr_ret = _wapi_handle_unlock_handle (handle);
-       g_assert (thr_ret == 0);
-       pthread_cleanup_pop (0);
-
-       return(ret);
-}
-
 gint32
 GetLogicalDriveStrings (guint32 len, gunichar2 *buf)
 {

Modified: trunk/mono/mono/io-layer/sockets.c
===================================================================
--- trunk/mono/mono/io-layer/sockets.c  2005-04-08 00:20:20 UTC (rev 42669)
+++ trunk/mono/mono/io-layer/sockets.c  2005-04-08 00:21:29 UTC (rev 42670)
@@ -28,18 +28,6 @@
 #include <signal.h>
 #endif
 
-#ifndef PLATFORM_WIN32
-#ifdef HAVE_AIO_H
-#include <aio.h>
-#define USE_AIO        1
-#elif defined(HAVE_SYS_AIO_H)
-#include <sys/aio.h>
-#define USE_AIO 1
-#else
-#undef USE_AIO
-#endif
-#endif
-
 #include <mono/io-layer/wapi.h>
 #include <mono/io-layer/wapi-private.h>
 #include <mono/io-layer/socket-private.h>
@@ -1063,110 +1051,3 @@
        FD_SET(fd, set);
 }
 
-#ifdef USE_AIO
-
-typedef struct {
-       struct aiocb *aio;
-       gpointer ares;
-       SocketAsyncCB callback;
-} notifier_data_t;
-
-#define SIGPTR(a) a.SIGVAL_PTR
-
-static void
-async_notifier (union sigval sig)
-{
-       notifier_data_t *ndata = SIGPTR (sig);
-       guint32 error;
-       guint32 numbytes;
-
-       error = aio_return (ndata->aio);
-       if (error < 0) {
-               error = _wapi_get_win32_file_error (error);
-               numbytes = 0;
-       } else {
-               numbytes = error;
-               error = 0;
-       }
-
-       ndata->callback (error, numbytes, ndata->ares);
-       g_free (ndata->aio);
-       g_free (ndata);
-}
-
-static gboolean
-do_aio_call (gboolean is_read, gpointer fd_handle, gpointer buffer,
-               guint32 numbytes, guint32 *out_bytes,
-               gpointer ares,
-               SocketAsyncCB callback)
-{
-       gpointer handle = _wapi_handle_fd_offset_to_handle (fd_handle);
-       int fd = GPOINTER_TO_UINT (fd_handle);
-       struct aiocb *aio;
-       int result;
-       notifier_data_t *ndata;
-       
-       if (handle == NULL ||
-           _wapi_handle_type (handle) != WAPI_HANDLE_SOCKET) {
-               WSASetLastError (WSAENOTSOCK);
-               return FALSE;
-       }
-
-       ndata = g_new0 (notifier_data_t, 1);
-       aio = g_new0 (struct aiocb, 1);
-       ndata->ares = ares;
-       ndata->aio = aio;
-       ndata->callback = callback;
-
-       aio->aio_fildes = fd;
-       aio->aio_lio_opcode = (is_read) ? LIO_READ : LIO_WRITE;
-       aio->aio_nbytes = numbytes;
-       aio->aio_offset = 0;
-       aio->aio_buf = buffer;
-       aio->aio_sigevent.sigev_notify = SIGEV_THREAD;
-       aio->aio_sigevent.sigev_notify_function = async_notifier;
-       SIGPTR (aio->aio_sigevent.sigev_value) = ndata;
-
-       if (is_read) {
-               result = aio_read (aio);
-       } else {
-               result = aio_write (aio);
-       }
-
-       if (result == -1) {
-               WSASetLastError (errno_to_WSA (errno, "do_aio_call"));
-               return FALSE;
-       }
-
-       result = aio_error (aio);
-       if (result == 0) {
-               numbytes = aio_return (aio);
-       } else {
-               WSASetLastError (errno_to_WSA (result, "do_aio_call"));
-               return FALSE;
-       }
-
-       if (out_bytes)
-               *out_bytes = numbytes;
-
-       return TRUE;
-}
-
-gboolean _wapi_socket_async_read (gpointer handle, gpointer buffer,
-                                 guint32 numbytes,
-                                 guint32 *bytesread, gpointer ares,
-                                 SocketAsyncCB callback)
-{
-       return do_aio_call (TRUE, handle, buffer, numbytes, bytesread, ares, 
callback);
-}
-
-gboolean _wapi_socket_async_write (gpointer handle, gpointer buffer,
-                                 guint32 numbytes,
-                                 guint32 *byteswritten, gpointer ares,
-                                 SocketAsyncCB callback)
-{
-       return do_aio_call (FALSE, handle, buffer, numbytes, byteswritten, 
ares, callback);
-}
-
-#endif /* USE_AIO */
-

Modified: trunk/mono/mono/io-layer/sockets.h
===================================================================
--- trunk/mono/mono/io-layer/sockets.h  2005-04-08 00:20:20 UTC (rev 42669)
+++ trunk/mono/mono/io-layer/sockets.h  2005-04-08 00:21:29 UTC (rev 42670)
@@ -49,18 +49,4 @@
                     gchar *output, gint o_len, glong *written,
                     void *unused1, void *unused2);
 
-#ifndef PLATFORM_WIN32
-typedef void (*SocketAsyncCB) (guint32 error, guint32 numbytes, gpointer ares);
-
-gboolean _wapi_socket_async_read (gpointer handle, gpointer buffer,
-                                 guint32 numbytes,
-                                 guint32 *bytesread, gpointer ares,
-                                 SocketAsyncCB callback);
-
-gboolean _wapi_socket_async_write (gpointer handle, gpointer buffer,
-                                 guint32 numbytes,
-                                 guint32 *bytesread, gpointer ares,
-                                 SocketAsyncCB callback);
-#endif
-
 #endif /* _WAPI_SOCKETS_H_ */

Modified: trunk/mono/mono/io-layer/threads.c
===================================================================
--- trunk/mono/mono/io-layer/threads.c  2005-04-08 00:20:20 UTC (rev 42669)
+++ trunk/mono/mono/io-layer/threads.c  2005-04-08 00:21:29 UTC (rev 42670)
@@ -933,21 +933,6 @@
        SleepEx(ms, FALSE);
 }
 
-gboolean
-BindIoCompletionCallback (gpointer handle,
-                         WapiOverlappedCB callback,
-                         guint64 flags)
-{
-       WapiHandleType type;
-       
-       type = _wapi_handle_type (handle);
-       if (type == WAPI_HANDLE_FILE || type == WAPI_HANDLE_PIPE)
-               return _wapi_io_add_callback (handle, callback, flags);
-
-       SetLastError (ERROR_NOT_SUPPORTED);
-       return FALSE;
-}
-
 guint32 QueueUserAPC (WapiApcProc apc_callback, gpointer handle, 
                                        gpointer param)
 {

Modified: trunk/mono/mono/io-layer/threads.h
===================================================================
--- trunk/mono/mono/io-layer/threads.h  2005-04-08 00:20:20 UTC (rev 42669)
+++ trunk/mono/mono/io-layer/threads.h  2005-04-08 00:21:29 UTC (rev 42670)
@@ -55,10 +55,6 @@
 extern gboolean TlsSetValue(guint32 idx, gpointer value);
 extern void Sleep(guint32 ms);
 extern guint32 SleepEx(guint32 ms, gboolean alertable);
-extern gboolean BindIoCompletionCallback (gpointer handle,
-                                         WapiOverlappedCB callback,
-                                         guint64 flags);
-
 extern guint32 QueueUserAPC (WapiApcProc apc_callback, gpointer thread_handle, 
                                        gpointer param);
 

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to