Cygwin: [gs]et_io_handle(): renamed to [gs]et_handle().

- Unify get_io_handle() and get_handle() to get_handle().
  Both of them returned same value; io_handle.
- Rename set_io_handle() to set_handle().
This commit is contained in:
Takashi Yano 2019-03-30 16:12:02 +09:00 committed by Corinna Vinschen
parent 023c107a22
commit a9c661a94d
14 changed files with 87 additions and 86 deletions

View File

@ -647,7 +647,7 @@ build_fh_pc (path_conv& pc)
else if ((fh->archetype = cygheap->fdtab.find_archetype (fh->dev ()))) else if ((fh->archetype = cygheap->fdtab.find_archetype (fh->dev ())))
{ {
debug_printf ("found an archetype for %s(%d/%d) io_handle %p", fh->get_name (), fh->dev ().get_major (), fh->dev ().get_minor (), debug_printf ("found an archetype for %s(%d/%d) io_handle %p", fh->get_name (), fh->dev ().get_major (), fh->dev ().get_minor (),
fh->archetype->get_io_handle ()); fh->archetype->get_handle ());
if (!fh->get_name ()) if (!fh->get_name ())
fh->set_name (fh->archetype->dev ().name ()); fh->set_name (fh->archetype->dev ().name ());
} }
@ -688,7 +688,7 @@ dtable::dup_worker (fhandler_base *oldfh, int flags)
else else
{ {
if (!oldfh->archetype) if (!oldfh->archetype)
newfh->set_io_handle (NULL); newfh->set_handle (NULL);
newfh->pc.reset_conv_handle (); newfh->pc.reset_conv_handle ();
if (oldfh->dup (newfh, flags)) if (oldfh->dup (newfh, flags))
@ -708,7 +708,7 @@ dtable::dup_worker (fhandler_base *oldfh, int flags)
/* The O_CLOEXEC flag enforces close-on-exec behaviour. */ /* The O_CLOEXEC flag enforces close-on-exec behaviour. */
newfh->set_close_on_exec (!!(flags & O_CLOEXEC)); newfh->set_close_on_exec (!!(flags & O_CLOEXEC));
debug_printf ("duped '%s' old %p, new %p", oldfh->get_name (), debug_printf ("duped '%s' old %p, new %p", oldfh->get_name (),
oldfh->get_io_handle (), newfh->get_io_handle ()); oldfh->get_handle (), newfh->get_handle ());
} }
} }
return newfh; return newfh;
@ -765,7 +765,7 @@ dtable::dup3 (int oldfd, int newfd, int flags)
} }
debug_printf ("newfh->io_handle %p, oldfh->io_handle %p, new win32_name %p, old win32_name %p", debug_printf ("newfh->io_handle %p, oldfh->io_handle %p, new win32_name %p, old win32_name %p",
newfh->get_io_handle (), fds[oldfd]->get_io_handle (), newfh->get_win32_name (), fds[oldfd]->get_win32_name ()); newfh->get_handle (), fds[oldfd]->get_handle (), newfh->get_win32_name (), fds[oldfd]->get_win32_name ());
if (!not_open (newfd)) if (!not_open (newfd))
close (newfd); close (newfd);
@ -891,12 +891,12 @@ dtable::fixup_after_exec ()
/* Close the handle if it's close-on-exec or if an error was detected /* Close the handle if it's close-on-exec or if an error was detected
(typically with opening a console in a gui app) by fixup_after_exec. (typically with opening a console in a gui app) by fixup_after_exec.
*/ */
if (fh->close_on_exec () || (!fh->nohandle () && !fh->get_io_handle ())) if (fh->close_on_exec () || (!fh->nohandle () && !fh->get_handle ()))
fixup_close (i, fh); fixup_close (i, fh);
else if (fh->get_popen_pid ()) else if (fh->get_popen_pid ())
close (i); close (i);
else if (i == 0) else if (i == 0)
SetStdHandle (std_consts[i], fh->get_io_handle ()); SetStdHandle (std_consts[i], fh->get_handle ());
else if (i <= 2) else if (i <= 2)
SetStdHandle (std_consts[i], fh->get_output_handle ()); SetStdHandle (std_consts[i], fh->get_output_handle ());
} }
@ -913,7 +913,7 @@ dtable::fixup_after_fork (HANDLE parent)
{ {
debug_printf ("fd %d (%s)", i, fh->get_name ()); debug_printf ("fd %d (%s)", i, fh->get_name ());
fh->fixup_after_fork (parent); fh->fixup_after_fork (parent);
if (!fh->nohandle () && !fh->get_io_handle ()) if (!fh->nohandle () && !fh->get_handle ())
{ {
/* This should actually never happen but it's here to make sure /* This should actually never happen but it's here to make sure
we don't crash due to access of an unopened file handle. */ we don't crash due to access of an unopened file handle. */
@ -922,7 +922,7 @@ dtable::fixup_after_fork (HANDLE parent)
} }
} }
if (i == 0) if (i == 0)
SetStdHandle (std_consts[i], fh->get_io_handle ()); SetStdHandle (std_consts[i], fh->get_handle ());
else if (i <= 2) else if (i <= 2)
SetStdHandle (std_consts[i], fh->get_output_handle ()); SetStdHandle (std_consts[i], fh->get_output_handle ());
} }

View File

@ -461,7 +461,7 @@ fhandler_base::open_with_arch (int flags, mode_t mode)
} }
else if (archetype) else if (archetype)
{ {
if (!archetype->get_io_handle ()) if (!archetype->get_handle ())
{ {
copyto (archetype); copyto (archetype);
archetype_usecount (1); archetype_usecount (1);
@ -522,7 +522,7 @@ fhandler_base::open_null (int flags)
__seterrno_from_nt_status (status); __seterrno_from_nt_status (status);
goto done; goto done;
} }
set_io_handle (fh); set_handle (fh);
set_flags (flags, pc.binmode ()); set_flags (flags, pc.binmode ());
res = 1; res = 1;
set_open_status (); set_open_status ();
@ -775,7 +775,7 @@ fhandler_base::open (int flags, mode_t mode)
} }
} }
set_io_handle (fh); set_handle (fh);
set_flags (flags, pc.binmode ()); set_flags (flags, pc.binmode ());
res = 1; res = 1;
@ -1298,7 +1298,7 @@ fhandler_base_overlapped::close ()
/* Cancelling seems to be necessary for cases where a reader is /* Cancelling seems to be necessary for cases where a reader is
still executing when a signal handler performs a close. */ still executing when a signal handler performs a close. */
if (!writer) if (!writer)
CancelIo (get_io_handle ()); CancelIo (get_handle ());
destroy_overlapped (); destroy_overlapped ();
res = fhandler_base::close (); res = fhandler_base::close ();
} }
@ -1382,7 +1382,7 @@ fhandler_base::fstatvfs (struct statvfs *sfs)
int int
fhandler_base::init (HANDLE f, DWORD a, mode_t bin) fhandler_base::init (HANDLE f, DWORD a, mode_t bin)
{ {
set_io_handle (f); set_handle (f);
access = a; access = a;
a &= GENERIC_READ | GENERIC_WRITE; a &= GENERIC_READ | GENERIC_WRITE;
int flags = 0; int flags = 0;
@ -1417,7 +1417,7 @@ fhandler_base::dup (fhandler_base *child, int)
} }
VerifyHandle (nh); VerifyHandle (nh);
child->set_io_handle (nh); child->set_handle (nh);
} }
return 0; return 0;
} }

View File

@ -227,7 +227,7 @@ class fhandler_base
virtual ~fhandler_base (); virtual ~fhandler_base ();
/* Non-virtual simple accessor functions. */ /* Non-virtual simple accessor functions. */
void set_io_handle (HANDLE x) { io_handle = x; } void set_handle (HANDLE x) { io_handle = x; }
dev_t& get_device () { return dev (); } dev_t& get_device () { return dev (); }
_major_t get_major () { return dev ().get_major (); } _major_t get_major () { return dev ().get_major (); }
@ -430,9 +430,9 @@ public:
/* Virtual accessor functions to hide the fact /* Virtual accessor functions to hide the fact
that some fd's have two handles. */ that some fd's have two handles. */
virtual HANDLE& get_handle () { return io_handle; } virtual HANDLE& get_handle () { return io_handle; }
virtual HANDLE& get_io_handle () { return io_handle; } virtual HANDLE& get_handle_cyg () { return io_handle; }
virtual HANDLE& get_io_handle_cyg () { return io_handle; }
virtual HANDLE& get_output_handle () { return io_handle; } virtual HANDLE& get_output_handle () { return io_handle; }
virtual HANDLE& get_output_handle_cyg () { return io_handle; }
virtual HANDLE get_stat_handle () { return pc.handle () ?: io_handle; } virtual HANDLE get_stat_handle () { return pc.handle () ?: io_handle; }
virtual HANDLE get_echo_handle () const { return NULL; } virtual HANDLE get_echo_handle () const { return NULL; }
virtual bool hit_eof () {return false;} virtual bool hit_eof () {return false;}
@ -1726,6 +1726,7 @@ class fhandler_termios: public fhandler_base
need_fork_fixup (true); need_fork_fixup (true);
} }
HANDLE& get_output_handle () { return output_handle; } HANDLE& get_output_handle () { return output_handle; }
HANDLE& get_output_handle_cyg () { return output_handle; }
line_edit_status line_edit (const char *rptr, size_t nread, termios&, line_edit_status line_edit (const char *rptr, size_t nread, termios&,
ssize_t *bytes_read = NULL); ssize_t *bytes_read = NULL);
void set_output_handle (HANDLE h) { output_handle = h; } void set_output_handle (HANDLE h) { output_handle = h; }
@ -2109,7 +2110,7 @@ class fhandler_pty_master: public fhandler_pty_common
public: public:
HANDLE get_echo_handle () const { return echo_r; } HANDLE get_echo_handle () const { return echo_r; }
HANDLE& get_io_handle_cyg () { return io_handle_cyg; } HANDLE& get_handle_cyg () { return io_handle_cyg; }
/* Constructor */ /* Constructor */
fhandler_pty_master (int); fhandler_pty_master (int);

View File

@ -155,7 +155,7 @@ fhandler_console::set_unit ()
pc.file_attributes (FILE_ATTRIBUTE_NORMAL); pc.file_attributes (FILE_ATTRIBUTE_NORMAL);
else else
{ {
set_io_handle (NULL); set_handle (NULL);
set_output_handle (NULL); set_output_handle (NULL);
created = false; created = false;
} }
@ -298,7 +298,7 @@ fhandler_console::read (void *pv, size_t& buflen)
{ {
push_process_state process_state (PID_TTYIN); push_process_state process_state (PID_TTYIN);
HANDLE h = get_io_handle (); HANDLE h = get_handle ();
#define buf ((char *) pv) #define buf ((char *) pv)
@ -818,7 +818,7 @@ fhandler_console::open (int flags, mode_t)
tcinit (false); tcinit (false);
set_io_handle (NULL); set_handle (NULL);
set_output_handle (NULL); set_output_handle (NULL);
/* Open the input handle as handle_ */ /* Open the input handle as handle_ */
@ -831,7 +831,7 @@ fhandler_console::open (int flags, mode_t)
__seterrno (); __seterrno ();
return 0; return 0;
} }
set_io_handle (h); set_handle (h);
h = CreateFileW (L"CONOUT$", GENERIC_READ | GENERIC_WRITE, h = CreateFileW (L"CONOUT$", GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE, &sec_none, FILE_SHARE_READ | FILE_SHARE_WRITE, &sec_none,
@ -856,11 +856,11 @@ fhandler_console::open (int flags, mode_t)
set_open_status (); set_open_status ();
DWORD cflags; DWORD cflags;
if (GetConsoleMode (get_io_handle (), &cflags)) if (GetConsoleMode (get_handle (), &cflags))
SetConsoleMode (get_io_handle (), SetConsoleMode (get_handle (),
ENABLE_WINDOW_INPUT | ENABLE_MOUSE_INPUT | cflags); ENABLE_WINDOW_INPUT | ENABLE_MOUSE_INPUT | cflags);
debug_printf ("opened conin$ %p, conout$ %p", get_io_handle (), debug_printf ("opened conin$ %p, conout$ %p", get_handle (),
get_output_handle ()); get_output_handle ());
return 1; return 1;
@ -878,7 +878,7 @@ fhandler_console::open_setup (int flags)
int int
fhandler_console::close () fhandler_console::close ()
{ {
CloseHandle (get_io_handle ()); CloseHandle (get_handle ());
CloseHandle (get_output_handle ()); CloseHandle (get_output_handle ());
if (!have_execed) if (!have_execed)
free_console (); free_console ();
@ -948,7 +948,7 @@ fhandler_console::ioctl (unsigned int cmd, void *arg)
DWORD n; DWORD n;
int ret = 0; int ret = 0;
INPUT_RECORD inp[INREC_SIZE]; INPUT_RECORD inp[INREC_SIZE];
if (!PeekConsoleInputW (get_io_handle (), inp, INREC_SIZE, &n)) if (!PeekConsoleInputW (get_handle (), inp, INREC_SIZE, &n))
{ {
set_errno (EINVAL); set_errno (EINVAL);
return -1; return -1;
@ -972,7 +972,7 @@ fhandler_console::tcflush (int queue)
if (queue == TCIFLUSH if (queue == TCIFLUSH
|| queue == TCIOFLUSH) || queue == TCIOFLUSH)
{ {
if (!FlushConsoleInputBuffer (get_io_handle ())) if (!FlushConsoleInputBuffer (get_handle ()))
{ {
__seterrno (); __seterrno ();
res = -1; res = -1;
@ -1004,7 +1004,7 @@ fhandler_console::input_tcsetattr (int, struct termios const *t)
DWORD oflags; DWORD oflags;
if (!GetConsoleMode (get_io_handle (), &oflags)) if (!GetConsoleMode (get_handle (), &oflags))
oflags = 0; oflags = 0;
DWORD flags = 0; DWORD flags = 0;
@ -1050,7 +1050,7 @@ fhandler_console::input_tcsetattr (int, struct termios const *t)
res = 0; res = 0;
else else
{ {
res = SetConsoleMode (get_io_handle (), flags) ? 0 : -1; res = SetConsoleMode (get_handle (), flags) ? 0 : -1;
if (res < 0) if (res < 0)
__seterrno (); __seterrno ();
syscall_printf ("%d = tcsetattr(,%p) enable flags %y, c_lflag %y iflag %y", syscall_printf ("%d = tcsetattr(,%p) enable flags %y, c_lflag %y iflag %y",
@ -1080,7 +1080,7 @@ fhandler_console::tcgetattr (struct termios *t)
DWORD flags; DWORD flags;
if (!GetConsoleMode (get_io_handle (), &flags)) if (!GetConsoleMode (get_handle (), &flags))
{ {
__seterrno (); __seterrno ();
res = -1; res = -1;

View File

@ -212,7 +212,7 @@ fhandler_base::fstat_by_nfs_ea (struct stat *buf)
cyg_ldap cldap; cyg_ldap cldap;
bool ldap_open = false; bool ldap_open = false;
if (get_io_handle ()) if (get_handle ())
{ {
/* NFS stumbles over its own caching. If you write to the file, /* NFS stumbles over its own caching. If you write to the file,
a subsequent fstat does not return the actual size of the file, a subsequent fstat does not return the actual size of the file,
@ -220,8 +220,8 @@ fhandler_base::fstat_by_nfs_ea (struct stat *buf)
access through another handle invalidates the caching within the access through another handle invalidates the caching within the
NFS client. */ NFS client. */
if (get_access () & GENERIC_WRITE) if (get_access () & GENERIC_WRITE)
FlushFileBuffers (get_io_handle ()); FlushFileBuffers (get_handle ());
pc.get_finfo (get_io_handle ()); pc.get_finfo (get_handle ());
} }
buf->st_dev = nfs_attr->fsid; buf->st_dev = nfs_attr->fsid;
buf->st_ino = nfs_attr->fileid; buf->st_ino = nfs_attr->fileid;
@ -291,7 +291,7 @@ fhandler_base::fstat_by_handle (struct stat *buf)
/* If the file has been opened for other purposes than stat, we can't rely /* If the file has been opened for other purposes than stat, we can't rely
on the information stored in pc.fai. So we overwrite them here. */ on the information stored in pc.fai. So we overwrite them here. */
if (get_io_handle ()) if (get_handle ())
{ {
status = pc.get_finfo (h); status = pc.get_finfo (h);
if (!NT_SUCCESS (status)) if (!NT_SUCCESS (status))
@ -386,7 +386,7 @@ fhandler_base::fstat_fs (struct stat *buf)
nohandle (false); nohandle (false);
close_fs (); close_fs ();
nohandle (no_handle); nohandle (no_handle);
set_io_handle (NULL); set_handle (NULL);
} }
if (res) if (res)
res = fstat_by_name (buf); res = fstat_by_name (buf);
@ -1465,7 +1465,7 @@ fhandler_base::open_fs (int flags, mode_t mode)
/* The file info in pc is wrong at this point for newly created files. /* The file info in pc is wrong at this point for newly created files.
Refresh it before fetching any file info. */ Refresh it before fetching any file info. */
if (new_file) if (new_file)
pc.get_finfo (get_io_handle ()); pc.get_finfo (get_handle ());
if (pc.isgood_inode (pc.get_ino ())) if (pc.isgood_inode (pc.get_ino ()))
ino = pc.get_ino (); ino = pc.get_ino ();
@ -2615,7 +2615,7 @@ fhandler_disk_file::fs_ioc_setflags (uint64_t flags)
if (fh != get_handle ()) if (fh != get_handle ())
NtClose (fh); NtClose (fh);
NtClose (get_handle ()); NtClose (get_handle ());
set_io_handle (NULL); set_handle (NULL);
pc.get_wide_win32_path (path); pc.get_wide_win32_path (path);
cret = (flags & FS_ENCRYPT_FL) cret = (flags & FS_ENCRYPT_FL)
@ -2630,7 +2630,7 @@ fhandler_disk_file::fs_ioc_setflags (uint64_t flags)
__seterrno_from_nt_status (status); __seterrno_from_nt_status (status);
return -1; return -1;
} }
set_io_handle (fh); set_handle (fh);
if (!cret) if (!cret)
{ {
__seterrno (); __seterrno ();

View File

@ -266,7 +266,7 @@ fhandler_fifo::open_pipe ()
sharing = FILE_SHARE_READ | FILE_SHARE_WRITE; sharing = FILE_SHARE_READ | FILE_SHARE_WRITE;
status = NtOpenFile (&ph, access, &attr, &io, sharing, 0); status = NtOpenFile (&ph, access, &attr, &io, sharing, 0);
if (NT_SUCCESS (status)) if (NT_SUCCESS (status))
set_io_handle (ph); set_handle (ph);
return status; return status;
} }
@ -293,7 +293,7 @@ fhandler_fifo::add_client ()
HANDLE ph = create_pipe_instance (first); HANDLE ph = create_pipe_instance (first);
if (!ph) if (!ph)
goto errout; goto errout;
fh->set_io_handle (ph); fh->set_handle (ph);
fh->set_flags (get_flags ()); fh->set_flags (get_flags ());
if (fc.connect () < 0) if (fc.connect () < 0)
{ {
@ -486,7 +486,7 @@ fhandler_fifo::open (int flags, mode_t)
res = error_errno_set; res = error_errno_set;
goto out; goto out;
} }
set_io_handle (ph); set_handle (ph);
set_pipe_non_blocking (ph, true); set_pipe_non_blocking (ph, true);
if (!(fh = build_fh_dev (dev ()))) if (!(fh = build_fh_dev (dev ())))
{ {
@ -494,7 +494,7 @@ fhandler_fifo::open (int flags, mode_t)
res = error_errno_set; res = error_errno_set;
goto out; goto out;
} }
fh->set_io_handle (ph); fh->set_handle (ph);
fh->set_flags (flags); fh->set_flags (flags);
if (!(connect_evt = create_event ())) if (!(connect_evt = create_event ()))
{ {
@ -604,8 +604,8 @@ out:
CloseHandle (write_ready); CloseHandle (write_ready);
write_ready = NULL; write_ready = NULL;
} }
if (get_io_handle ()) if (get_handle ())
CloseHandle (get_io_handle ()); CloseHandle (get_handle ());
if (listen_client_thr) if (listen_client_thr)
CloseHandle (listen_client_thr); CloseHandle (listen_client_thr);
} }

View File

@ -97,7 +97,7 @@ fhandler_pipe::open (int flags, mode_t mode)
|| (rwflags == O_WRONLY && !(cfd->get_access () & GENERIC_WRITE))) || (rwflags == O_WRONLY && !(cfd->get_access () & GENERIC_WRITE)))
continue; continue;
cfd->copyto (this); cfd->copyto (this);
set_io_handle (NULL); set_handle (NULL);
pc.reset_conv_handle (); pc.reset_conv_handle ();
if (!cfd->dup (this, flags)) if (!cfd->dup (this, flags))
return 1; return 1;

View File

@ -116,7 +116,7 @@ fhandler_process_fd::fd_reopen (int flags, mode_t mode)
fh = fetch_fh (hdl, 0); fh = fetch_fh (hdl, 0);
if (!fh) if (!fh)
return NULL; return NULL;
fh->set_io_handle (hdl); fh->set_handle (hdl);
int ret = fh->open_with_arch (flags, mode); int ret = fh->open_with_arch (flags, mode);
CloseHandle (hdl); CloseHandle (hdl);
if (!ret) if (!ret)
@ -139,7 +139,7 @@ fhandler_process_fd::fstat (struct stat *statbuf)
fh = fetch_fh (hdl, 0); fh = fetch_fh (hdl, 0);
if (!fh) if (!fh)
return -1; return -1;
fh->set_io_handle (hdl); fh->set_handle (hdl);
int ret = fh->fstat (statbuf); int ret = fh->fstat (statbuf);
CloseHandle (hdl); CloseHandle (hdl);
delete fh; delete fh;
@ -155,7 +155,7 @@ fhandler_process_fd::link (const char *newpath)
fh = fetch_fh (hdl, FFH_LINKAT); fh = fetch_fh (hdl, FFH_LINKAT);
if (!fh) if (!fh)
return -1; return -1;
fh->set_io_handle (hdl); fh->set_handle (hdl);
int ret = fh->link (newpath); int ret = fh->link (newpath);
CloseHandle (hdl); CloseHandle (hdl);
delete fh; delete fh;

View File

@ -826,7 +826,7 @@ fhandler_registry::open (int flags, mode_t mode)
} }
else else
{ {
set_io_handle (fetch_hkey (i)); set_handle (fetch_hkey (i));
/* Marking as nohandle allows to call dup on pseudo registry /* Marking as nohandle allows to call dup on pseudo registry
handles. */ handles. */
if (get_handle () >= HKEY_CLASSES_ROOT) if (get_handle () >= HKEY_CLASSES_ROOT)
@ -881,7 +881,7 @@ fhandler_registry::open (int flags, mode_t mode)
else else
flags |= O_DIROPEN; flags |= O_DIROPEN;
set_io_handle (handle); set_handle (handle);
set_close_on_exec (!!(flags & O_CLOEXEC)); set_close_on_exec (!!(flags & O_CLOEXEC));
value_name = cwcsdup (dec_file); value_name = cwcsdup (dec_file);
@ -1118,7 +1118,7 @@ fhandler_registry::dup (fhandler_base *child, int flags)
allows fhandler_base::dup to succeed as usual for nohandle fhandlers. allows fhandler_base::dup to succeed as usual for nohandle fhandlers.
Here we just have to fix up by copying the pseudo handle value. */ Here we just have to fix up by copying the pseudo handle value. */
if ((HKEY) get_handle () >= HKEY_CLASSES_ROOT) if ((HKEY) get_handle () >= HKEY_CLASSES_ROOT)
fhs->set_io_handle (get_handle ()); fhs->set_handle (get_handle ());
if (value_name) if (value_name)
fhs->value_name = cwcsdup (value_name); fhs->value_name = cwcsdup (value_name);
return ret; return ret;

View File

@ -518,14 +518,14 @@ fhandler_socket_wsock::fixup_after_fork (HANDLE parent)
if (new_sock == INVALID_SOCKET) if (new_sock == INVALID_SOCKET)
{ {
set_winsock_errno (); set_winsock_errno ();
set_io_handle ((HANDLE) INVALID_SOCKET); set_handle ((HANDLE) INVALID_SOCKET);
} }
else else
{ {
/* Even though the original socket was not inheritable, the duplicated /* Even though the original socket was not inheritable, the duplicated
socket is potentially inheritable again. */ socket is potentially inheritable again. */
SetHandleInformation ((HANDLE) new_sock, HANDLE_FLAG_INHERIT, 0); SetHandleInformation ((HANDLE) new_sock, HANDLE_FLAG_INHERIT, 0);
set_io_handle ((HANDLE) new_sock); set_handle ((HANDLE) new_sock);
debug_printf ("WSASocket succeeded (%p)", new_sock); debug_printf ("WSASocket succeeded (%p)", new_sock);
} }
} }
@ -571,13 +571,13 @@ fhandler_socket_wsock::dup (fhandler_base *child, int flags)
cygheap->user.deimpersonate (); cygheap->user.deimpersonate ();
fhs->init_fixup_before (); fhs->init_fixup_before ();
fhs->set_io_handle (get_io_handle ()); fhs->set_handle (get_handle ());
int ret = fhs->fixup_before_fork_exec (GetCurrentProcessId ()); int ret = fhs->fixup_before_fork_exec (GetCurrentProcessId ());
cygheap->user.reimpersonate (); cygheap->user.reimpersonate ();
if (!ret) if (!ret)
{ {
fhs->fixup_after_fork (GetCurrentProcess ()); fhs->fixup_after_fork (GetCurrentProcess ());
if (fhs->get_io_handle() != (HANDLE) INVALID_SOCKET) if (fhs->get_handle() != (HANDLE) INVALID_SOCKET)
return 0; return 0;
} }
cygheap->fdtab.dec_need_fixup_before (); cygheap->fdtab.dec_need_fixup_before ();
@ -645,7 +645,7 @@ fhandler_socket_wsock::set_socket_handle (SOCKET sock, int af, int type,
} }
} }
} }
set_io_handle ((HANDLE) sock); set_handle ((HANDLE) sock);
set_addr_family (af); set_addr_family (af);
set_socket_type (type); set_socket_type (type);
if (!init_events ()) if (!init_events ())

View File

@ -938,7 +938,7 @@ fhandler_socket_unix::open_pipe (PUNICODE_STRING pipe_name, bool xchg_sock_info)
status = NtOpenFile (&ph, access, &attr, &io, sharing, 0); status = NtOpenFile (&ph, access, &attr, &io, sharing, 0);
if (NT_SUCCESS (status)) if (NT_SUCCESS (status))
{ {
set_io_handle (ph); set_handle (ph);
if (xchg_sock_info) if (xchg_sock_info)
send_sock_info (false); send_sock_info (false);
} }
@ -1365,7 +1365,7 @@ fhandler_socket_unix::socket (int af, int type, int protocol, int flags)
if (flags & SOCK_CLOEXEC) if (flags & SOCK_CLOEXEC)
set_close_on_exec (true); set_close_on_exec (true);
init_cred (); init_cred ();
set_io_handle (NULL); set_handle (NULL);
set_unique_id (); set_unique_id ();
set_ino (get_unique_id ()); set_ino (get_unique_id ());
return 0; return 0;
@ -1412,7 +1412,7 @@ fhandler_socket_unix::socketpair (int af, int type, int protocol, int flags,
pipe = create_pipe (true); pipe = create_pipe (true);
if (!pipe) if (!pipe)
goto create_pipe_failed; goto create_pipe_failed;
set_io_handle (pipe); set_handle (pipe);
sun_path (&sun); sun_path (&sun);
fh->peer_sun_path (&sun); fh->peer_sun_path (&sun);
connect_state (listener); connect_state (listener);
@ -1483,12 +1483,12 @@ fhandler_socket_unix::bind (const struct sockaddr *name, int namelen)
binding_state (unbound); binding_state (unbound);
return -1; return -1;
} }
set_io_handle (pipe); set_handle (pipe);
} }
backing_file_handle = unnamed ? autobind (&sun) : create_file (&sun); backing_file_handle = unnamed ? autobind (&sun) : create_file (&sun);
if (!backing_file_handle) if (!backing_file_handle)
{ {
set_io_handle (NULL); set_handle (NULL);
if (pipe) if (pipe)
NtClose (pipe); NtClose (pipe);
binding_state (unbound); binding_state (unbound);
@ -1538,7 +1538,7 @@ fhandler_socket_unix::listen (int backlog)
connect_state (unconnected); connect_state (unconnected);
return -1; return -1;
} }
set_io_handle (pipe); set_handle (pipe);
state_lock (); state_lock ();
set_cred (); set_cred ();
state_unlock (); state_unlock ();
@ -1575,7 +1575,7 @@ fhandler_socket_unix::accept4 (struct sockaddr *peer, int *len, int flags)
else else
{ {
/* Set new io handle. */ /* Set new io handle. */
set_io_handle (new_inst); set_handle (new_inst);
io_unlock (); io_unlock ();
/* Prepare new file descriptor. */ /* Prepare new file descriptor. */
cygheap_fdnew fd; cygheap_fdnew fd;
@ -1600,7 +1600,7 @@ fhandler_socket_unix::accept4 (struct sockaddr *peer, int *len, int flags)
sock->pc.set_nt_native_path (pc.get_nt_native_path ()); sock->pc.set_nt_native_path (pc.get_nt_native_path ());
sock->connect_state (connected); sock->connect_state (connected);
sock->binding_state (binding_state ()); sock->binding_state (binding_state ());
sock->set_io_handle (accepted); sock->set_handle (accepted);
sock->sun_path (sun_path ()); sock->sun_path (sun_path ());
sock->sock_cred (sock_cred ()); sock->sock_cred (sock_cred ());

View File

@ -235,7 +235,7 @@ fhandler_pty_master::process_slave_output (char *buf, size_t len, int pktmode_on
/* Check echo pipe first. */ /* Check echo pipe first. */
if (::bytes_available (echo_cnt, echo_r) && echo_cnt > 0) if (::bytes_available (echo_cnt, echo_r) && echo_cnt > 0)
break; break;
if (!::bytes_available (n, get_io_handle_cyg ())) if (!::bytes_available (n, get_handle_cyg ()))
goto err; goto err;
if (n) if (n)
break; break;
@ -296,7 +296,7 @@ fhandler_pty_master::process_slave_output (char *buf, size_t len, int pktmode_on
goto err; goto err;
} }
} }
else if (!ReadFile (get_io_handle_cyg (), outbuf, rlen, &n, NULL)) else if (!ReadFile (get_handle_cyg (), outbuf, rlen, &n, NULL))
{ {
termios_printf ("ReadFile failed, %E"); termios_printf ("ReadFile failed, %E");
goto err; goto err;
@ -494,7 +494,7 @@ fhandler_pty_slave::open (int flags, mode_t)
termios_printf ("duplicated to_master_cyg %p->%p from pty_owner", termios_printf ("duplicated to_master_cyg %p->%p from pty_owner",
get_ttyp ()->to_master_cyg (), to_master_cyg_local); get_ttyp ()->to_master_cyg (), to_master_cyg_local);
set_io_handle (from_master_local); set_handle (from_master_local);
set_output_handle (to_master_local); set_output_handle (to_master_local);
set_output_handle_cyg (to_master_cyg_local); set_output_handle_cyg (to_master_cyg_local);
@ -1347,11 +1347,11 @@ fhandler_pty_master::close ()
if (!ForceCloseHandle (to_master)) if (!ForceCloseHandle (to_master))
termios_printf ("error closing to_master %p, %E", to_master); termios_printf ("error closing to_master %p, %E", to_master);
from_master = to_master = NULL; from_master = to_master = NULL;
if (!ForceCloseHandle (get_io_handle_cyg ())) if (!ForceCloseHandle (get_handle_cyg ()))
termios_printf ("error closing io_handle_cyg %p, %E", get_io_handle_cyg ()); termios_printf ("error closing io_handle_cyg %p, %E", get_handle_cyg ());
if (!ForceCloseHandle (to_master_cyg)) if (!ForceCloseHandle (to_master_cyg))
termios_printf ("error closing to_master_cyg %p, %E", to_master_cyg); termios_printf ("error closing to_master_cyg %p, %E", to_master_cyg);
get_io_handle_cyg () = to_master_cyg = NULL; get_handle_cyg () = to_master_cyg = NULL;
ForceCloseHandle (echo_r); ForceCloseHandle (echo_r);
ForceCloseHandle (echo_w); ForceCloseHandle (echo_w);
echo_r = echo_w = NULL; echo_r = echo_w = NULL;
@ -1458,7 +1458,7 @@ fhandler_pty_master::ioctl (unsigned int cmd, void *arg)
case FIONREAD: case FIONREAD:
{ {
DWORD n; DWORD n;
if (!::bytes_available (n, get_io_handle_cyg ())) if (!::bytes_available (n, get_handle_cyg ()))
{ {
set_errno (EINVAL); set_errno (EINVAL);
return -1; return -1;
@ -1662,7 +1662,7 @@ fhandler_pty_master::pty_master_fwd_thread ()
termios_printf("Started."); termios_printf("Started.");
for (;;) for (;;)
{ {
if (!ReadFile (get_io_handle (), outbuf, sizeof outbuf, &rlen, NULL)) if (!ReadFile (get_handle (), outbuf, sizeof outbuf, &rlen, NULL))
{ {
termios_printf ("ReadFile for forwarding failed, %E"); termios_printf ("ReadFile for forwarding failed, %E");
break; break;
@ -1715,7 +1715,7 @@ fhandler_pty_master::setup ()
char pipename[sizeof("ptyNNNN-to-master-cyg")]; char pipename[sizeof("ptyNNNN-to-master-cyg")];
__small_sprintf (pipename, "pty%d-to-master", unit); __small_sprintf (pipename, "pty%d-to-master", unit);
res = fhandler_pipe::create (&sec_none, &get_io_handle (), &to_master, res = fhandler_pipe::create (&sec_none, &get_handle (), &to_master,
fhandler_pty_common::pipesize, pipename, 0); fhandler_pty_common::pipesize, pipename, 0);
if (res) if (res)
{ {
@ -1724,7 +1724,7 @@ fhandler_pty_master::setup ()
} }
__small_sprintf (pipename, "pty%d-to-master-cyg", unit); __small_sprintf (pipename, "pty%d-to-master-cyg", unit);
res = fhandler_pipe::create (&sec_none, &get_io_handle_cyg (), &to_master_cyg, res = fhandler_pipe::create (&sec_none, &get_handle_cyg (), &to_master_cyg,
fhandler_pty_common::pipesize, pipename, 0); fhandler_pty_common::pipesize, pipename, 0);
if (res) if (res)
{ {
@ -1732,7 +1732,7 @@ fhandler_pty_master::setup ()
goto err; goto err;
} }
ProtectHandle1 (get_io_handle (), from_pty); ProtectHandle1 (get_handle (), from_pty);
__small_sprintf (pipename, "pty%d-echoloop", unit); __small_sprintf (pipename, "pty%d-echoloop", unit);
res = fhandler_pipe::create (&sec_none, &echo_r, &echo_w, res = fhandler_pipe::create (&sec_none, &echo_r, &echo_w,
@ -1807,14 +1807,14 @@ fhandler_pty_master::setup ()
dev ().parse (DEV_PTYM_MAJOR, unit); dev ().parse (DEV_PTYM_MAJOR, unit);
termios_printf ("this %p, pty%d opened - from_pty <%p,%p>, to_pty %p", termios_printf ("this %p, pty%d opened - from_pty <%p,%p>, to_pty %p",
this, unit, get_io_handle (), get_io_handle_cyg (), this, unit, get_handle (), get_handle_cyg (),
get_output_handle ()); get_output_handle ());
return true; return true;
err: err:
__seterrno (); __seterrno ();
close_maybe (get_io_handle ()); close_maybe (get_handle ());
close_maybe (get_io_handle_cyg ()); close_maybe (get_handle_cyg ());
close_maybe (get_output_handle ()); close_maybe (get_output_handle ());
close_maybe (input_available_event); close_maybe (input_available_event);
close_maybe (output_mutex); close_maybe (output_mutex);

View File

@ -516,7 +516,7 @@ mmap_record::alloc_fh ()
{ {
if (anonymous ()) if (anonymous ())
{ {
fh_anonymous.set_io_handle (INVALID_HANDLE_VALUE); fh_anonymous.set_handle (INVALID_HANDLE_VALUE);
fh_anonymous.set_access (GENERIC_READ | GENERIC_WRITE | GENERIC_EXECUTE); fh_anonymous.set_access (GENERIC_READ | GENERIC_WRITE | GENERIC_EXECUTE);
return &fh_anonymous; return &fh_anonymous;
} }
@ -901,7 +901,7 @@ mmap64 (void *addr, size_t len, int prot, int flags, int fd, off_t off)
size_t pagesize = wincap.allocation_granularity (); size_t pagesize = wincap.allocation_granularity ();
fh_anonymous.set_io_handle (INVALID_HANDLE_VALUE); fh_anonymous.set_handle (INVALID_HANDLE_VALUE);
fh_anonymous.set_access (GENERIC_READ | GENERIC_WRITE | GENERIC_EXECUTE); fh_anonymous.set_access (GENERIC_READ | GENERIC_WRITE | GENERIC_EXECUTE);
/* EINVAL error conditions. */ /* EINVAL error conditions. */
@ -1033,7 +1033,7 @@ mmap64 (void *addr, size_t len, int prot, int flags, int fd, off_t off)
fh_disk_file = new (ccalloc (HEAP_FHANDLER, 1, sizeof *fh_disk_file)) fh_disk_file = new (ccalloc (HEAP_FHANDLER, 1, sizeof *fh_disk_file))
fhandler_disk_file; fhandler_disk_file;
fh_disk_file->set_name (fh->pc); fh_disk_file->set_name (fh->pc);
fh_disk_file->set_io_handle (h); fh_disk_file->set_handle (h);
fh_disk_file->set_access (fh->get_access () | GENERIC_EXECUTE); fh_disk_file->set_access (fh->get_access () | GENERIC_EXECUTE);
fh = fh_disk_file; fh = fh_disk_file;
} }

View File

@ -74,7 +74,7 @@ details. */
}) })
#define set_handle_or_return_if_not_open(h, s) \ #define set_handle_or_return_if_not_open(h, s) \
h = (s)->fh->get_io_handle_cyg (); \ h = (s)->fh->get_handle_cyg (); \
if (cygheap->fdtab.not_open ((s)->fd)) \ if (cygheap->fdtab.not_open ((s)->fd)) \
{ \ { \
(s)->thread_errno = EBADF; \ (s)->thread_errno = EBADF; \
@ -1459,7 +1459,7 @@ fhandler_base::select_read (select_stuff *ss)
s->startup = no_startup; s->startup = no_startup;
s->verify = verify_ok; s->verify = verify_ok;
} }
s->h = get_io_handle_cyg (); s->h = get_handle_cyg ();
s->read_selected = true; s->read_selected = true;
s->read_ready = true; s->read_ready = true;
return s; return s;
@ -1474,7 +1474,7 @@ fhandler_base::select_write (select_stuff *ss)
s->startup = no_startup; s->startup = no_startup;
s->verify = verify_ok; s->verify = verify_ok;
} }
s->h = get_handle (); s->h = get_output_handle_cyg ();
s->write_selected = true; s->write_selected = true;
s->write_ready = true; s->write_ready = true;
return s; return s;
@ -1747,7 +1747,7 @@ fhandler_socket_unix::select_read (select_stuff *ss)
s->startup = no_startup; s->startup = no_startup;
s->verify = verify_ok; s->verify = verify_ok;
} }
s->h = get_io_handle_cyg (); s->h = get_handle_cyg ();
s->read_selected = true; s->read_selected = true;
s->read_ready = true; s->read_ready = true;
return s; return s;