projects
/
mono.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge pull request #3264 from esdrubal/tzi_dst
[mono.git]
/
mono
/
io-layer
/
locking.c
diff --git
a/mono/io-layer/locking.c
b/mono/io-layer/locking.c
index 57b18ca662e936243e78c14908fb6cf87d26cc4a..001df9bef7e9273d726f2999880915377f1cb9ef 100644
(file)
--- a/
mono/io-layer/locking.c
+++ b/
mono/io-layer/locking.c
@@
-6,6
+6,7
@@
*
* (C) 2002 Ximian, Inc.
* Copyright (c) 2002-2009 Novell, Inc.
*
* (C) 2002 Ximian, Inc.
* Copyright (c) 2002-2009 Novell, Inc.
+ * Licensed under the MIT license. See LICENSE file in the project root for full license information.
*/
#include <config.h>
#include <stdio.h>
*/
#include <config.h>
#include <stdio.h>
@@
-14,14
+15,10
@@
#include <errno.h>
#include <mono/io-layer/wapi.h>
#include <mono/io-layer/wapi-private.h>
#include <errno.h>
#include <mono/io-layer/wapi.h>
#include <mono/io-layer/wapi-private.h>
-#include <mono/io-layer/handles-private.h>
#include <mono/io-layer/io-private.h>
#include <mono/io-layer/io-private.h>
-
-#if 0
-// #define DEBUG(...) g_message(__VA_ARGS__)
-#else
-#define DEBUG(...)
-#endif
+#include <mono/io-layer/io-trace.h>
+#include <mono/utils/mono-logger-internals.h>
+#include <mono/utils/w32handle.h>
gboolean
_wapi_lock_file_region (int fd, off_t offset, off_t length)
gboolean
_wapi_lock_file_region (int fd, off_t offset, off_t length)
@@
-34,6
+31,11
@@
_wapi_lock_file_region (int fd, off_t offset, off_t length)
struct flock lock_data;
int ret;
struct flock lock_data;
int ret;
+ if (offset < 0 || length < 0) {
+ SetLastError (ERROR_INVALID_PARAMETER);
+ return(FALSE);
+ }
+
lock_data.l_type = F_WRLCK;
lock_data.l_whence = SEEK_SET;
lock_data.l_start = offset;
lock_data.l_type = F_WRLCK;
lock_data.l_whence = SEEK_SET;
lock_data.l_start = offset;
@@
-43,7
+45,7
@@
_wapi_lock_file_region (int fd, off_t offset, off_t length)
ret = fcntl (fd, F_SETLK, &lock_data);
} while(ret == -1 && errno == EINTR);
ret = fcntl (fd, F_SETLK, &lock_data);
} while(ret == -1 && errno == EINTR);
-
DEBUG (
"%s: fcntl returns %d", __func__, ret);
+
MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER,
"%s: fcntl returns %d", __func__, ret);
if (ret == -1) {
/*
if (ret == -1) {
/*
@@
-88,7
+90,7
@@
_wapi_unlock_file_region (int fd, off_t offset, off_t length)
ret = fcntl (fd, F_SETLK, &lock_data);
} while(ret == -1 && errno == EINTR);
ret = fcntl (fd, F_SETLK, &lock_data);
} while(ret == -1 && errno == EINTR);
-
DEBUG (
"%s: fcntl returns %d", __func__, ret);
+
MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER,
"%s: fcntl returns %d", __func__, ret);
if (ret == -1) {
/*
if (ret == -1) {
/*
@@
-123,7
+125,7
@@
LockFile (gpointer handle, guint32 offset_low, guint32 offset_high,
off_t offset, length;
int fd = GPOINTER_TO_UINT(handle);
off_t offset, length;
int fd = GPOINTER_TO_UINT(handle);
- ok =
_wapi_lookup_handle (handle, WAPI_
HANDLE_FILE,
+ ok =
mono_w32handle_lookup (handle, MONO_W32
HANDLE_FILE,
(gpointer *)&file_handle);
if (ok == FALSE) {
g_warning ("%s: error looking up file handle %p", __func__,
(gpointer *)&file_handle);
if (ok == FALSE) {
g_warning ("%s: error looking up file handle %p", __func__,
@@
-135,7
+137,7
@@
LockFile (gpointer handle, guint32 offset_low, guint32 offset_high,
if (!(file_handle->fileaccess & GENERIC_READ) &&
!(file_handle->fileaccess & GENERIC_WRITE) &&
!(file_handle->fileaccess & GENERIC_ALL)) {
if (!(file_handle->fileaccess & GENERIC_READ) &&
!(file_handle->fileaccess & GENERIC_WRITE) &&
!(file_handle->fileaccess & GENERIC_ALL)) {
-
DEBUG (
"%s: handle %p doesn't have GENERIC_READ or GENERIC_WRITE access: %u", __func__, handle, file_handle->fileaccess);
+
MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER,
"%s: handle %p doesn't have GENERIC_READ or GENERIC_WRITE access: %u", __func__, handle, file_handle->fileaccess);
SetLastError (ERROR_ACCESS_DENIED);
return(FALSE);
}
SetLastError (ERROR_ACCESS_DENIED);
return(FALSE);
}
@@
-144,12
+146,16
@@
LockFile (gpointer handle, guint32 offset_low, guint32 offset_high,
offset = ((gint64)offset_high << 32) | offset_low;
length = ((gint64)length_high << 32) | length_low;
offset = ((gint64)offset_high << 32) | offset_low;
length = ((gint64)length_high << 32) | length_low;
-
DEBUG (
"%s: Locking handle %p, offset %lld, length %lld", __func__, handle, offset, length);
+
MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER,
"%s: Locking handle %p, offset %lld, length %lld", __func__, handle, offset, length);
#else
#else
+ if (offset_high > 0 || length_high > 0) {
+ SetLastError (ERROR_INVALID_PARAMETER);
+ return (FALSE);
+ }
offset = offset_low;
length = length_low;
offset = offset_low;
length = length_low;
-
DEBUG (
"%s: Locking handle %p, offset %ld, length %ld", __func__,
+
MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER,
"%s: Locking handle %p, offset %ld, length %ld", __func__,
handle, offset, length);
#endif
handle, offset, length);
#endif
@@
-166,7
+172,7
@@
UnlockFile (gpointer handle, guint32 offset_low,
off_t offset, length;
int fd = GPOINTER_TO_UINT(handle);
off_t offset, length;
int fd = GPOINTER_TO_UINT(handle);
- ok =
_wapi_lookup_handle (handle, WAPI_
HANDLE_FILE,
+ ok =
mono_w32handle_lookup (handle, MONO_W32
HANDLE_FILE,
(gpointer *)&file_handle);
if (ok == FALSE) {
g_warning ("%s: error looking up file handle %p", __func__,
(gpointer *)&file_handle);
if (ok == FALSE) {
g_warning ("%s: error looking up file handle %p", __func__,
@@
-178,7
+184,7
@@
UnlockFile (gpointer handle, guint32 offset_low,
if (!(file_handle->fileaccess & GENERIC_READ) &&
!(file_handle->fileaccess & GENERIC_WRITE) &&
!(file_handle->fileaccess & GENERIC_ALL)) {
if (!(file_handle->fileaccess & GENERIC_READ) &&
!(file_handle->fileaccess & GENERIC_WRITE) &&
!(file_handle->fileaccess & GENERIC_ALL)) {
-
DEBUG (
"%s: handle %p doesn't have GENERIC_READ or GENERIC_WRITE access: %u", __func__, handle, file_handle->fileaccess);
+
MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER,
"%s: handle %p doesn't have GENERIC_READ or GENERIC_WRITE access: %u", __func__, handle, file_handle->fileaccess);
SetLastError (ERROR_ACCESS_DENIED);
return(FALSE);
}
SetLastError (ERROR_ACCESS_DENIED);
return(FALSE);
}
@@
-187,12
+193,12
@@
UnlockFile (gpointer handle, guint32 offset_low,
offset = ((gint64)offset_high << 32) | offset_low;
length = ((gint64)length_high << 32) | length_low;
offset = ((gint64)offset_high << 32) | offset_low;
length = ((gint64)length_high << 32) | length_low;
-
DEBUG (
"%s: Unlocking handle %p, offset %lld, length %lld", __func__, handle, offset, length);
+
MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER,
"%s: Unlocking handle %p, offset %lld, length %lld", __func__, handle, offset, length);
#else
offset = offset_low;
length = length_low;
#else
offset = offset_low;
length = length_low;
-
DEBUG (
"%s: Unlocking handle %p, offset %ld, length %ld", __func__, handle, offset, length);
+
MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER,
"%s: Unlocking handle %p, offset %ld, length %ld", __func__, handle, offset, length);
#endif
return(_wapi_unlock_file_region (fd, offset, length));
#endif
return(_wapi_unlock_file_region (fd, offset, length));