Cleaned up and removed some no longer used code.
diff --git a/files/change.c b/files/change.c
index 331700c..3dde14c 100644
--- a/files/change.c
+++ b/files/change.c
@@ -29,14 +29,10 @@
typedef struct
{
K32OBJ header;
-
LPSTR lpPathName;
BOOL32 bWatchSubtree;
DWORD dwNotifyFilter;
-
- THREAD_QUEUE wait_queue;
BOOL32 notify;
-
} CHANGE_OBJECT;
/****************************************************************************
@@ -67,13 +63,11 @@
CHANGE_OBJECT *change;
struct create_change_notification_request req;
struct create_change_notification_reply reply;
- int len;
req.subtree = bWatchSubtree;
req.filter = dwNotifyFilter;
CLIENT_SendRequest( REQ_CREATE_CHANGE_NOTIFICATION, -1, 1, &req, sizeof(req) );
- CLIENT_WaitReply( &len, NULL, 1, &reply, sizeof(reply) );
- CHECK_LEN( len, sizeof(reply) );
+ CLIENT_WaitSimpleReply( &reply, sizeof(reply), NULL );
if (reply.handle == -1) return INVALID_HANDLE_VALUE32;
change = HeapAlloc( SystemHeap, 0, sizeof(CHANGE_OBJECT) );
@@ -89,8 +83,6 @@
change->lpPathName = HEAP_strdupA( SystemHeap, 0, lpPathName );
change->bWatchSubtree = bWatchSubtree;
change->dwNotifyFilter = dwNotifyFilter;
-
- change->wait_queue = NULL;
change->notify = FALSE;
return HANDLE_Alloc( PROCESS_Current(), &change->header,
diff --git a/files/dos_fs.c b/files/dos_fs.c
index 5dfb7e6..7e49cae 100644
--- a/files/dos_fs.c
+++ b/files/dos_fs.c
@@ -652,10 +652,7 @@
!strcmp(DOSFS_Devices[i].name,"HPSCAN"))
{
int fd = open( "/dev/null", unixmode );
- if ((handle = FILE_Alloc( &file, fd )) == INVALID_HANDLE_VALUE32)
- return HFILE_ERROR32;
- file->unix_name = HEAP_strdupA( SystemHeap, 0, name );
- return handle;
+ return FILE_Alloc( &file, fd, DOSFS_Devices[i].name );
}
FIXME(dosfs,"device open %s not supported (yet)\n",DOSFS_Devices[i].name);
return HFILE_ERROR32;
diff --git a/files/file.c b/files/file.c
index 5b000cf..3fc8c5c 100644
--- a/files/file.c
+++ b/files/file.c
@@ -71,19 +71,17 @@
*
* Allocate a file. The unix_handle is closed.
*/
-HFILE32 FILE_Alloc( FILE_OBJECT **file, int unix_handle )
+HFILE32 FILE_Alloc( FILE_OBJECT **file, int unix_handle, const char *unix_name )
{
HFILE32 handle;
struct create_file_request req;
struct create_file_reply reply;
- int len;
req.access = FILE_ALL_ACCESS | GENERIC_READ |
GENERIC_WRITE | GENERIC_EXECUTE; /* FIXME */
req.inherit = 1; /* FIXME */
CLIENT_SendRequest( REQ_CREATE_FILE, unix_handle, 1, &req, sizeof(req) );
- CLIENT_WaitReply( &len, NULL, 1, &reply, sizeof(reply) );
- CHECK_LEN( len, sizeof(reply) );
+ CLIENT_WaitSimpleReply( &reply, sizeof(reply), NULL );
if (reply.handle == -1) return INVALID_HANDLE_VALUE32;
*file = HeapAlloc( SystemHeap, 0, sizeof(FILE_OBJECT) );
@@ -95,10 +93,9 @@
}
(*file)->header.type = K32OBJ_FILE;
(*file)->header.refcount = 0;
- (*file)->unix_name = NULL;
+ (*file)->unix_name = unix_name ? HEAP_strdupA( SystemHeap, 0, unix_name ) : NULL;
(*file)->type = FILE_TYPE_DISK;
(*file)->mode = 0;
- (*file)->wait_queue = NULL;
handle = HANDLE_Alloc( PROCESS_Current(), &(*file)->header, req.access,
req.inherit, reply.handle );
@@ -152,28 +149,6 @@
/***********************************************************************
- * FILE_GetUnixHandle
- *
- * Return the Unix handle associated to a file handle.
- * The Unix handle must be closed after use.
- */
-int FILE_GetUnixHandle( HFILE32 hFile, DWORD access )
-{
- FILE_OBJECT *file;
- int unix_handle;
- struct get_unix_handle_request req;
-
- file = (FILE_OBJECT *)HANDLE_GetObjPtr( PROCESS_Current(), hFile,
- K32OBJ_FILE, access, &req.handle );
- if (!file) return -1;
- req.access = access;
- CLIENT_SendRequest( REQ_GET_UNIX_HANDLE, -1, 1, &req, sizeof(req) );
- CLIENT_WaitReply( NULL, &unix_handle, 0 );
- K32OBJ_DecCount( &file->header );
- return unix_handle;
-}
-
-/***********************************************************************
* FILE_UnixToDosMode
*
* PARAMS
@@ -503,7 +478,7 @@
FILE_SetDosError();
return INVALID_HANDLE_VALUE32;
}
- return FILE_Alloc( &file, unix_handle );
+ return FILE_Alloc( &file, unix_handle, NULL );
}
@@ -512,7 +487,6 @@
*/
HFILE32 FILE_OpenUnixFile( const char *name, int mode )
{
- HFILE32 handle;
int unix_handle;
FILE_OBJECT *file;
struct stat st;
@@ -534,12 +508,9 @@
return INVALID_HANDLE_VALUE32;
}
- /* File opened OK, now fill the FILE_OBJECT */
+ /* File opened OK, now allocate a handle */
- if ((handle = FILE_Alloc( &file, unix_handle )) == INVALID_HANDLE_VALUE32)
- return INVALID_HANDLE_VALUE32;
- file->unix_name = HEAP_strdupA( SystemHeap, 0, name );
- return handle;
+ return FILE_Alloc( &file, unix_handle, name );
}
@@ -650,9 +621,9 @@
/* File created OK, now fill the FILE_OBJECT */
- if ((handle = FILE_Alloc( &file, unix_handle )) == INVALID_HANDLE_VALUE32)
+ if ((handle = FILE_Alloc( &file, unix_handle,
+ full_name.long_name )) == INVALID_HANDLE_VALUE32)
return INVALID_HANDLE_VALUE32;
- file->unix_name = HEAP_strdupA( SystemHeap, 0, full_name.long_name );
file->mode = dosMode;
return handle;
}
@@ -712,18 +683,16 @@
DWORD WINAPI GetFileInformationByHandle( HFILE32 hFile,
BY_HANDLE_FILE_INFORMATION *info )
{
- FILE_OBJECT *file;
struct get_file_info_request req;
struct get_file_info_reply reply;
- int len;
if (!info) return 0;
- if (!(file = FILE_GetFile( hFile, 0, &req.handle ))) return 0;
+ if ((req.handle = HANDLE_GetServerHandle( PROCESS_Current(), hFile,
+ K32OBJ_FILE, 0 )) == -1)
+ return 0;
CLIENT_SendRequest( REQ_GET_FILE_INFO, -1, 1, &req, sizeof(req) );
- CLIENT_WaitReply( &len, NULL, 1, &reply, sizeof(reply) );
- CHECK_LEN( len, sizeof(reply) );
- FILE_ReleaseFile( file );
-
+ if (CLIENT_WaitSimpleReply( &reply, sizeof(reply), NULL ))
+ return 0;
DOSFS_UnixTimeToFileTime( reply.write_time, &info->ftCreationTime, 0 );
DOSFS_UnixTimeToFileTime( reply.write_time, &info->ftLastWriteTime, 0 );
DOSFS_UnixTimeToFileTime( reply.access_time, &info->ftLastAccessTime, 0 );
@@ -1175,7 +1144,6 @@
BOOL32 WINAPI ReadFile( HANDLE32 hFile, LPVOID buffer, DWORD bytesToRead,
LPDWORD bytesRead, LPOVERLAPPED overlapped )
{
- K32OBJ *ptr;
struct get_read_fd_request req;
int unix_handle, result;
@@ -1184,18 +1152,11 @@
if (bytesRead) *bytesRead = 0; /* Do this before anything else */
if (!bytesToRead) return TRUE;
- if (!(ptr = HANDLE_GetObjPtr( PROCESS_Current(), hFile,
- K32OBJ_UNKNOWN, GENERIC_READ, &req.handle )))
+ if ((req.handle = HANDLE_GetServerHandle( PROCESS_Current(), hFile,
+ K32OBJ_UNKNOWN, GENERIC_READ )) == -1)
return FALSE;
-
- if (req.handle == -1) /* We need a server handle */
- {
- K32OBJ_DecCount( ptr );
- return FALSE;
- }
CLIENT_SendRequest( REQ_GET_READ_FD, -1, 1, &req, sizeof(req) );
CLIENT_WaitReply( NULL, &unix_handle, 0 );
- K32OBJ_DecCount( ptr );
if (unix_handle == -1) return FALSE;
while ((result = read( unix_handle, buffer, bytesToRead )) == -1)
{
@@ -1216,7 +1177,6 @@
BOOL32 WINAPI WriteFile( HANDLE32 hFile, LPCVOID buffer, DWORD bytesToWrite,
LPDWORD bytesWritten, LPOVERLAPPED overlapped )
{
- K32OBJ *ptr;
struct get_write_fd_request req;
int unix_handle, result;
@@ -1225,18 +1185,11 @@
if (bytesWritten) *bytesWritten = 0; /* Do this before anything else */
if (!bytesToWrite) return TRUE;
- if (!(ptr = HANDLE_GetObjPtr( PROCESS_Current(), hFile,
- K32OBJ_UNKNOWN, GENERIC_WRITE, &req.handle )))
+ if ((req.handle = HANDLE_GetServerHandle( PROCESS_Current(), hFile,
+ K32OBJ_UNKNOWN, GENERIC_READ )) == -1)
return FALSE;
-
- if (req.handle == -1) /* We need a server handle */
- {
- K32OBJ_DecCount( ptr );
- return FALSE;
- }
CLIENT_SendRequest( REQ_GET_WRITE_FD, -1, 1, &req, sizeof(req) );
CLIENT_WaitReply( NULL, &unix_handle, 0 );
- K32OBJ_DecCount( ptr );
if (unix_handle == -1) return FALSE;
while ((result = write( unix_handle, buffer, bytesToWrite )) == -1)
{
@@ -1336,10 +1289,8 @@
DWORD WINAPI SetFilePointer( HFILE32 hFile, LONG distance, LONG *highword,
DWORD method )
{
- FILE_OBJECT *file;
struct set_file_pointer_request req;
struct set_file_pointer_reply reply;
- int len, err;
if (highword && *highword)
{
@@ -1350,18 +1301,15 @@
TRACE(file, "handle %d offset %ld origin %ld\n",
hFile, distance, method );
- if (!(file = FILE_GetFile( hFile, 0, &req.handle ))) return 0xffffffff;
- assert( req.handle != -1 );
-
+ if ((req.handle = HANDLE_GetServerHandle( PROCESS_Current(), hFile,
+ K32OBJ_FILE, 0 )) == -1)
+ return 0xffffffff;
req.low = distance;
req.high = highword ? *highword : 0;
/* FIXME: assumes 1:1 mapping between Windows and Unix seek constants */
req.whence = method;
CLIENT_SendRequest( REQ_SET_FILE_POINTER, -1, 1, &req, sizeof(req) );
- err = CLIENT_WaitReply( &len, NULL, 1, &reply, sizeof(reply) );
- CHECK_LEN( len, sizeof(reply) );
- FILE_ReleaseFile( file );
- if (err) return 0xffffffff;
+ if (CLIENT_WaitSimpleReply( &reply, sizeof(reply), NULL )) return 0xffffffff;
SetLastError( 0 );
if (highword) *highword = reply.high;
return reply.low;
@@ -1552,17 +1500,13 @@
*/
BOOL32 WINAPI FlushFileBuffers( HFILE32 hFile )
{
- FILE_OBJECT *file;
- BOOL32 ret;
struct flush_file_request req;
- if (!(file = FILE_GetFile( hFile, GENERIC_WRITE, &req.handle ))) return FALSE;
- assert( req.handle != -1 );
-
+ if ((req.handle = HANDLE_GetServerHandle( PROCESS_Current(), hFile,
+ K32OBJ_FILE, 0 )) == -1)
+ return FALSE;
CLIENT_SendRequest( REQ_FLUSH_FILE, -1, 1, &req, sizeof(req) );
- ret = !CLIENT_WaitReply( NULL, NULL, 0 );
- FILE_ReleaseFile( file );
- return ret;
+ return !CLIENT_WaitReply( NULL, NULL, 0 );
}
@@ -1571,17 +1515,13 @@
*/
BOOL32 WINAPI SetEndOfFile( HFILE32 hFile )
{
- FILE_OBJECT *file;
- BOOL32 ret;
struct truncate_file_request req;
- if (!(file = FILE_GetFile( hFile, GENERIC_WRITE, &req.handle ))) return FALSE;
- assert( req.handle != -1 );
-
+ if ((req.handle = HANDLE_GetServerHandle( PROCESS_Current(), hFile,
+ K32OBJ_FILE, 0 )) == -1)
+ return FALSE;
CLIENT_SendRequest( REQ_TRUNCATE_FILE, -1, 1, &req, sizeof(req) );
- ret = !CLIENT_WaitReply( NULL, NULL, 0 );
- FILE_ReleaseFile( file );
- return ret;
+ return !CLIENT_WaitReply( NULL, NULL, 0 );
}
@@ -1648,7 +1588,7 @@
/***********************************************************************
* FILE_dommap
*/
-LPVOID FILE_dommap( FILE_OBJECT *file, int unix_handle, LPVOID start,
+LPVOID FILE_dommap( int unix_handle, LPVOID start,
DWORD size_high, DWORD size_low,
DWORD offset_high, DWORD offset_low,
int prot, int flags )
@@ -1660,7 +1600,7 @@
if (size_high || offset_high)
FIXME(file, "offsets larger than 4Gb not supported\n");
- if (!file)
+ if (unix_handle == -1)
{
#ifdef MAP_ANON
flags |= MAP_ANON;
@@ -1695,7 +1635,7 @@
/* page-aligned (EINVAL), or because the underlying filesystem */
/* does not support mmap() (ENOEXEC), we do it by hand. */
- if (!file) return ret;
+ if (unix_handle == -1) return ret;
if ((errno != ENOEXEC) && (errno != EINVAL)) return ret;
if (prot & PROT_WRITE)
{
@@ -1709,7 +1649,7 @@
}
/* printf( "FILE_mmap: mmap failed (%d), faking it\n", errno );*/
/* Reserve the memory with an anonymous mmap */
- ret = FILE_dommap( NULL, -1, start, size_high, size_low, 0, 0,
+ ret = FILE_dommap( -1, start, size_high, size_low, 0, 0,
PROT_READ | PROT_WRITE, flags );
if (ret == (LPVOID)-1) return ret;
/* Now read in the file */
@@ -2269,5 +2209,3 @@
HeapFree( GetProcessHeap(), 0, nameA );
return res;
}
-
-
diff --git a/include/file.h b/include/file.h
index 3de96d6..dd2a71a 100644
--- a/include/file.h
+++ b/include/file.h
@@ -10,7 +10,6 @@
#include <time.h>
#include "windows.h"
#include "k32obj.h"
-#include "thread.h"
#define MAX_PATHNAME_LEN 1024
@@ -21,7 +20,6 @@
int mode;
char *unix_name;
DWORD type; /* Type for win32 apps */
- THREAD_QUEUE wait_queue;
} FILE_OBJECT;
/* Definition of a full DOS file name */
@@ -62,9 +60,8 @@
extern FILE_OBJECT *FILE_GetFile( HFILE32 handle, DWORD access,
int *server_handle );
extern void FILE_ReleaseFile( FILE_OBJECT *file );
-extern HFILE32 FILE_Alloc( FILE_OBJECT **file, int unix_handle );
+extern HFILE32 FILE_Alloc( FILE_OBJECT **file, int unix_handle, const char *unix_name );
extern void FILE_SetDosError(void);
-extern int FILE_GetUnixHandle( HFILE32 hFile, DWORD access );
extern HFILE32 FILE_DupUnixHandle( int fd );
extern BOOL32 FILE_Stat( LPCSTR unixName, BY_HANDLE_FILE_INFORMATION *info );
extern HFILE32 FILE_Dup( HFILE32 hFile );
@@ -72,7 +69,7 @@
extern HFILE32 FILE_Open( LPCSTR path, INT32 mode ,INT32 sharemode);
extern HFILE32 FILE_OpenUnixFile( LPCSTR path, INT32 mode );
extern BOOL32 FILE_SetFileType( HFILE32 hFile, DWORD type );
-extern LPVOID FILE_dommap( FILE_OBJECT *file, int unix_handle, LPVOID start,
+extern LPVOID FILE_dommap( int unix_handle, LPVOID start,
DWORD size_high, DWORD size_low,
DWORD offset_high, DWORD offset_low,
int prot, int flags );
diff --git a/scheduler/client.c b/scheduler/client.c
index 4f01efd..24fdfa4 100644
--- a/scheduler/client.c
+++ b/scheduler/client.c
@@ -28,7 +28,7 @@
/***********************************************************************
* CLIENT_ProtocolError
*/
-void CLIENT_ProtocolError( const char *err, ... )
+static void CLIENT_ProtocolError( const char *err, ... )
{
THDB *thdb = THREAD_Current();
va_list args;
@@ -216,6 +216,26 @@
/***********************************************************************
+ * CLIENT_WaitSimpleReply
+ *
+ * Wait for a simple fixed-length reply from the server.
+ */
+unsigned int CLIENT_WaitSimpleReply( void *reply, int len, int *passed_fd )
+{
+ struct iovec vec[2];
+ unsigned int ret;
+ int got;
+
+ vec[1].iov_base = reply;
+ vec[1].iov_len = len;
+ ret = CLIENT_WaitReply_v( &got, passed_fd, vec, 2 );
+ if (got != len)
+ CLIENT_ProtocolError( "WaitSimpleReply: len %d != %d\n", len, got );
+ return ret;
+}
+
+
+/***********************************************************************
* CLIENT_NewThread
*
* Send a new thread request.
@@ -224,7 +244,7 @@
{
struct new_thread_request request;
struct new_thread_reply reply;
- int len, fd[2];
+ int fd[2];
extern BOOL32 THREAD_InitDone;
extern void server_init( int fd );
extern void select_loop(void);
@@ -273,16 +293,13 @@
request.pid = thdb->process->server_pid;
CLIENT_SendRequest( REQ_NEW_THREAD, fd[1], 1, &request, sizeof(request) );
-
- if (CLIENT_WaitReply( &len, NULL, 1, &reply, sizeof(reply) )) goto error;
- if (len < sizeof(reply)) goto error;
+ if (CLIENT_WaitSimpleReply( &reply, sizeof(reply), NULL )) goto error;
thdb->server_tid = reply.tid;
thdb->process->server_pid = reply.pid;
if (thdb->socket != -1) close( thdb->socket );
thdb->socket = fd[0];
thdb->seq = 0; /* reset the sequence number for the new fd */
- /* we don't need the handles for now */
if (thandle) *thandle = reply.thandle;
else if (reply.thandle != -1) CLIENT_CloseHandle( reply.thandle );
if (phandle) *phandle = reply.phandle;
@@ -359,45 +376,12 @@
req.options = options;
CLIENT_SendRequest( REQ_DUP_HANDLE, -1, 1, &req, sizeof(req) );
- CLIENT_WaitReply( &len, NULL, 1, &reply, sizeof(reply) );
- CHECK_LEN( len, sizeof(reply) );
+ CLIENT_WaitSimpleReply( &reply, sizeof(reply), NULL );
return reply.handle;
}
/***********************************************************************
- * CLIENT_GetProcessInfo
- *
- * Send a get process info request. Return 0 if OK.
- */
-int CLIENT_GetProcessInfo( int handle, struct get_process_info_reply *reply )
-{
- int len, err;
-
- CLIENT_SendRequest( REQ_GET_PROCESS_INFO, -1, 1, &handle, sizeof(handle) );
- err = CLIENT_WaitReply( &len, NULL, 1, reply, sizeof(*reply) );
- CHECK_LEN( len, sizeof(*reply) );
- return err;
-}
-
-
-/***********************************************************************
- * CLIENT_GetThreadInfo
- *
- * Send a get thread info request. Return 0 if OK.
- */
-int CLIENT_GetThreadInfo( int handle, struct get_thread_info_reply *reply )
-{
- int len, err;
-
- CLIENT_SendRequest( REQ_GET_THREAD_INFO, -1, 1, &handle, sizeof(handle) );
- err = CLIENT_WaitReply( &len, NULL, 1, reply, sizeof(*reply) );
- CHECK_LEN( len, sizeof(*reply) );
- return err;
-}
-
-
-/***********************************************************************
* CLIENT_OpenProcess
*
* Open a handle to a process.
@@ -406,15 +390,13 @@
{
struct open_process_request req;
struct open_process_reply reply;
- int len;
req.pid = pid;
req.access = access;
req.inherit = inherit;
CLIENT_SendRequest( REQ_OPEN_PROCESS, -1, 1, &req, sizeof(req) );
- CLIENT_WaitReply( &len, NULL, 1, &reply, sizeof(reply) );
- CHECK_LEN( len, sizeof(reply) );
+ CLIENT_WaitSimpleReply( &reply, sizeof(reply), NULL );
return reply.handle;
}
@@ -435,7 +417,6 @@
CLIENT_SendRequest( REQ_SELECT, -1, 2,
&req, sizeof(req),
handles, count * sizeof(int) );
- CLIENT_WaitReply( &len, NULL, 1, &reply, sizeof(reply) );
- CHECK_LEN( len, sizeof(reply) );
+ CLIENT_WaitSimpleReply( &reply, sizeof(reply), NULL );
return reply.signaled;
}
diff --git a/scheduler/event.c b/scheduler/event.c
index 30a1c76..fbf2991 100644
--- a/scheduler/event.c
+++ b/scheduler/event.c
@@ -20,13 +20,6 @@
K32OBJ header;
} EVENT;
-static void EVENT_Destroy( K32OBJ *obj );
-
-const K32OBJ_OPS EVENT_Ops =
-{
- EVENT_Destroy /* destroy */
-};
-
/***********************************************************************
* CreateEvent32A (KERNEL32.156)
@@ -45,8 +38,7 @@
req.inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle);
CLIENT_SendRequest( REQ_CREATE_EVENT, -1, 2, &req, sizeof(req), name, len );
- CLIENT_WaitReply( &len, NULL, 1, &reply, sizeof(reply) );
- CHECK_LEN( len, sizeof(reply) );
+ CLIENT_WaitSimpleReply( &reply, sizeof(reply), NULL );
if (reply.handle == -1) return 0;
SYSTEM_LOCK();
@@ -96,8 +88,7 @@
req.access = access;
req.inherit = inherit;
CLIENT_SendRequest( REQ_OPEN_NAMED_OBJ, -1, 2, &req, sizeof(req), name, len );
- CLIENT_WaitReply( &len, NULL, 1, &reply, sizeof(reply) );
- CHECK_LEN( len, sizeof(reply) );
+ CLIENT_WaitSimpleReply( &reply, sizeof(reply), NULL );
if (reply.handle != -1)
{
SYSTEM_LOCK();
@@ -173,20 +164,6 @@
/***********************************************************************
- * EVENT_Destroy
- */
-static void EVENT_Destroy( K32OBJ *obj )
-{
- EVENT *event = (EVENT *)obj;
- assert( obj->type == K32OBJ_EVENT );
- obj->type = K32OBJ_UNKNOWN;
- HeapFree( SystemHeap, 0, event );
-}
-
-
-
-
-/***********************************************************************
* NOTE: The Win95 VWin32_Event routines given below are really low-level
* routines implemented directly by VWin32. The user-mode libraries
* implement Win32 synchronisation routines on top of these low-level
diff --git a/scheduler/k32obj.c b/scheduler/k32obj.c
index a0b8e82..3d67e95 100644
--- a/scheduler/k32obj.c
+++ b/scheduler/k32obj.c
@@ -21,23 +21,25 @@
extern const K32OBJ_OPS CONSOLE_Ops;
extern const K32OBJ_OPS SNAPSHOT_Ops;
-/* The following are fully implemented in the server and could be removed */
-extern const K32OBJ_OPS SEMAPHORE_Ops;
-extern const K32OBJ_OPS EVENT_Ops;
-extern const K32OBJ_OPS MUTEX_Ops;
-extern const K32OBJ_OPS PIPE_Ops;
-
static const K32OBJ_OPS K32OBJ_NullOps =
{
NULL /* destroy */
};
+static void K32OBJ_Destroy( K32OBJ *obj );
+
+static const K32OBJ_OPS K32OBJ_DefaultOps =
+{
+ K32OBJ_Destroy /* destroy */
+};
+
+
const K32OBJ_OPS * const K32OBJ_Ops[K32OBJ_NBOBJECTS] =
{
NULL,
- &SEMAPHORE_Ops, /* K32OBJ_SEMAPHORE */
- &EVENT_Ops, /* K32OBJ_EVENT */
- &MUTEX_Ops, /* K32OBJ_MUTEX */
+ &K32OBJ_DefaultOps, /* K32OBJ_SEMAPHORE */
+ &K32OBJ_DefaultOps, /* K32OBJ_EVENT */
+ &K32OBJ_DefaultOps, /* K32OBJ_MUTEX */
&K32OBJ_NullOps, /* K32OBJ_CRITICAL_SECTION */
&PROCESS_Ops, /* K32OBJ_PROCESS */
&THREAD_Ops, /* K32OBJ_THREAD */
@@ -48,7 +50,7 @@
&MEM_MAPPED_FILE_Ops, /* K32OBJ_MEM_MAPPED_FILE */
&K32OBJ_NullOps, /* K32OBJ_SERIAL */
&DEVICE_Ops, /* K32OBJ_DEVICE_IOCTL */
- &PIPE_Ops, /* K32OBJ_PIPE */
+ &K32OBJ_DefaultOps, /* K32OBJ_PIPE */
&K32OBJ_NullOps, /* K32OBJ_MAILSLOT */
&K32OBJ_NullOps, /* K32OBJ_TOOLHELP_SNAPSHOT */
&K32OBJ_NullOps /* K32OBJ_SOCKET */
@@ -113,6 +115,18 @@
/***********************************************************************
+ * K32OBJ_Destroy
+ *
+ * Generic destroy functions for objects that don't need any special treatment.
+ */
+static void K32OBJ_Destroy( K32OBJ *obj )
+{
+ obj->type = K32OBJ_UNKNOWN;
+ HeapFree( SystemHeap, 0, obj );
+}
+
+
+/***********************************************************************
* K32OBJ_IsValid
*
* Check if a pointer is a valid kernel object
diff --git a/scheduler/mutex.c b/scheduler/mutex.c
index 05c72ed..83f1917 100644
--- a/scheduler/mutex.c
+++ b/scheduler/mutex.c
@@ -19,13 +19,6 @@
K32OBJ header;
} MUTEX;
-static void MUTEX_Destroy( K32OBJ *obj );
-
-const K32OBJ_OPS MUTEX_Ops =
-{
- MUTEX_Destroy /* destroy */
-};
-
/***********************************************************************
* CreateMutex32A (KERNEL32.166)
@@ -43,8 +36,7 @@
req.inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle);
CLIENT_SendRequest( REQ_CREATE_MUTEX, -1, 2, &req, sizeof(req), name, len );
- CLIENT_WaitReply( &len, NULL, 1, &reply, sizeof(reply) );
- CHECK_LEN( len, sizeof(reply) );
+ CLIENT_WaitSimpleReply( &reply, sizeof(reply), NULL );
if (reply.handle == -1) return 0;
SYSTEM_LOCK();
@@ -86,8 +78,7 @@
req.access = access;
req.inherit = inherit;
CLIENT_SendRequest( REQ_OPEN_NAMED_OBJ, -1, 2, &req, sizeof(req), name, len );
- CLIENT_WaitReply( &len, NULL, 1, &reply, sizeof(reply) );
- CHECK_LEN( len, sizeof(reply) );
+ CLIENT_WaitSimpleReply( &reply, sizeof(reply), NULL );
if (reply.handle != -1)
{
SYSTEM_LOCK();
@@ -130,15 +121,3 @@
CLIENT_SendRequest( REQ_RELEASE_MUTEX, -1, 1, &req, sizeof(req) );
return !CLIENT_WaitReply( NULL, NULL, 0 );
}
-
-
-/***********************************************************************
- * MUTEX_Destroy
- */
-static void MUTEX_Destroy( K32OBJ *obj )
-{
- MUTEX *mutex = (MUTEX *)obj;
- assert( obj->type == K32OBJ_MUTEX );
- obj->type = K32OBJ_UNKNOWN;
- HeapFree( SystemHeap, 0, mutex );
-}
diff --git a/scheduler/pipe.c b/scheduler/pipe.c
index 94279fb..0847ec5 100644
--- a/scheduler/pipe.c
+++ b/scheduler/pipe.c
@@ -19,13 +19,6 @@
K32OBJ header;
} PIPE;
-static void PIPE_Destroy( K32OBJ *obj );
-
-const K32OBJ_OPS PIPE_Ops =
-{
- PIPE_Destroy /* destroy */
-};
-
/***********************************************************************
* CreatePipe (KERNEL32.170)
@@ -71,16 +64,3 @@
SYSTEM_UNLOCK();
return TRUE;
}
-
-
-/***********************************************************************
- * PIPE_Destroy
- */
-static void PIPE_Destroy( K32OBJ *obj )
-{
- PIPE *pipe = (PIPE *)obj;
- assert( obj->type == K32OBJ_PIPE );
- obj->type = K32OBJ_UNKNOWN;
- HeapFree( SystemHeap, 0, pipe );
-}
-
diff --git a/scheduler/semaphore.c b/scheduler/semaphore.c
index 561d536..24a70db 100644
--- a/scheduler/semaphore.c
+++ b/scheduler/semaphore.c
@@ -19,13 +19,6 @@
K32OBJ header;
} SEMAPHORE;
-static void SEMAPHORE_Destroy( K32OBJ *obj );
-
-const K32OBJ_OPS SEMAPHORE_Ops =
-{
- SEMAPHORE_Destroy /* destroy */
-};
-
/***********************************************************************
* CreateSemaphore32A (KERNEL32.174)
@@ -52,8 +45,7 @@
req.inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle);
CLIENT_SendRequest( REQ_CREATE_SEMAPHORE, -1, 2, &req, sizeof(req), name, len );
- CLIENT_WaitReply( &len, NULL, 1, &reply, sizeof(reply) );
- CHECK_LEN( len, sizeof(reply) );
+ CLIENT_WaitSimpleReply( &reply, sizeof(reply), NULL );
if (reply.handle == -1) return 0;
SYSTEM_LOCK();
@@ -95,8 +87,7 @@
req.access = access;
req.inherit = inherit;
CLIENT_SendRequest( REQ_OPEN_NAMED_OBJ, -1, 2, &req, sizeof(req), name, len );
- CLIENT_WaitReply( &len, NULL, 1, &reply, sizeof(reply) );
- CHECK_LEN( len, sizeof(reply) );
+ CLIENT_WaitSimpleReply( &reply, sizeof(reply), NULL );
if (reply.handle != -1)
{
SYSTEM_LOCK();
@@ -133,7 +124,6 @@
{
struct release_semaphore_request req;
struct release_semaphore_reply reply;
- int len;
if (count < 0)
{
@@ -145,21 +135,7 @@
if (req.handle == -1) return FALSE;
req.count = (unsigned int)count;
CLIENT_SendRequest( REQ_RELEASE_SEMAPHORE, -1, 1, &req, sizeof(req) );
- if (CLIENT_WaitReply( &len, NULL, 1, &reply, sizeof(reply) )) return FALSE;
- CHECK_LEN( len, sizeof(reply) );
+ if (CLIENT_WaitSimpleReply( &reply, sizeof(reply), NULL )) return FALSE;
if (previous) *previous = reply.prev_count;
return TRUE;
}
-
-
-/***********************************************************************
- * SEMAPHORE_Destroy
- */
-static void SEMAPHORE_Destroy( K32OBJ *obj )
-{
- SEMAPHORE *sem = (SEMAPHORE *)obj;
- assert( obj->type == K32OBJ_SEMAPHORE );
- /* There cannot be any thread on the list since the ref count is 0 */
- obj->type = K32OBJ_UNKNOWN;
- HeapFree( SystemHeap, 0, sem );
-}
diff --git a/win32/console.c b/win32/console.c
index ae53a8b..31c9d87 100644
--- a/win32/console.c
+++ b/win32/console.c
@@ -60,7 +60,6 @@
LPSTR title; /* title of console */
INPUT_RECORD *irs; /* buffered input records */
int nrofirs;/* nr of buffered input records */
- THREAD_QUEUE wait_queue;
} CONSOLE;
static void CONSOLE_Destroy( K32OBJ *obj );
@@ -644,7 +643,6 @@
{
struct create_console_request req;
struct create_console_reply reply;
- int len;
PDB32 *pdb = PROCESS_Current();
CONSOLE *console;
HANDLE32 hIn, hOut, hErr;
@@ -674,7 +672,6 @@
console->pid = -1;
console->title = NULL;
console->nrofirs = 0;
- console->wait_queue = NULL;
console->irs = HeapAlloc(GetProcessHeap(),0,1);;
console->mode = ENABLE_PROCESSED_INPUT
| ENABLE_LINE_INPUT
@@ -685,13 +682,12 @@
console->hread = console->hwrite = -1;
CLIENT_SendRequest( REQ_CREATE_CONSOLE, -1, 1, &req, sizeof(req) );
- if (CLIENT_WaitReply( &len, NULL, 1, &reply, sizeof(reply) ) != ERROR_SUCCESS)
+ if (CLIENT_WaitSimpleReply( &reply, sizeof(reply), NULL ) != ERROR_SUCCESS)
{
K32OBJ_DecCount(&console->header);
SYSTEM_UNLOCK();
return FALSE;
}
- CHECK_LEN( len, sizeof(reply) );
console->hread = reply.handle_read;
console->hwrite = reply.handle_write;