mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-26 07:26:15 +01:00
23d80a04da
Any file handle created with FLAG_OVERLAPPED must have ReadFile()/WriteFile() called with an OVERLAPPED structure. Failing to do so will give unspecified results, invalid read/write or corruption. Without FLAG_OVERLAPPED, it is not possible to read and write concurrently, even with two seperate threads, created by 2 input and output gio streams. Also, only with FLAG_OVERLAPPED may an IO operation be asynchronous and thus be cancellable. We may want to call ReOpenFile() to make sure the FLAG is set, but this API is only available since Vista+. According to MSDN doc, adding the OVERLAPPED argument for IO operation on handles without FLAG_OVERLAPPED is allowed, and indeed the existing test still passes. v2: - update GetLastError() after _g_win32_overlap_wait_result () - split the unrelated ERROR_MORE_DATA handling https://bugzilla.gnome.org/show_bug.cgi?id=679288
52 lines
1.6 KiB
C
52 lines
1.6 KiB
C
/* GIO - GLib Input, Output and Streaming Library
|
|
*
|
|
* Copyright (C) 2006-2007 Red Hat, Inc.
|
|
*
|
|
* This library is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
* License as published by the Free Software Foundation; either
|
|
* version 2 of the License, or (at your option) any later version.
|
|
*
|
|
* This library is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
* Lesser General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Lesser General
|
|
* Public License along with this library; if not, write to the
|
|
* Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
|
* Boston, MA 02111-1307, USA.
|
|
*
|
|
* Author: Alexander Larsson <alexl@redhat.com>
|
|
*/
|
|
|
|
#ifndef __G_ASYNC_HELPER_H__
|
|
#define __G_ASYNC_HELPER_H__
|
|
|
|
#include <gio/gio.h>
|
|
|
|
#ifdef G_OS_WIN32
|
|
#include <windows.h>
|
|
#endif
|
|
|
|
G_BEGIN_DECLS
|
|
|
|
typedef gboolean (*GFDSourceFunc) (int fd,
|
|
GIOCondition condition,
|
|
gpointer user_data);
|
|
|
|
GSource *_g_fd_source_new (int fd,
|
|
gushort events,
|
|
GCancellable *cancellable);
|
|
|
|
#ifdef G_OS_WIN32
|
|
gboolean _g_win32_overlap_wait_result (HANDLE hfile,
|
|
OVERLAPPED *overlap,
|
|
DWORD *transferred,
|
|
GCancellable *cancellable);
|
|
#endif
|
|
|
|
G_END_DECLS
|
|
|
|
#endif /* __G_ASYNC_HELPER_H__ */
|