Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2012-06-03 22:02:45 +0400
committerChristopher Faylor <me@cgf.cx>2012-06-03 22:02:45 +0400
commit3143cb7c00fc1b6f4d75a83ac28f3bfbc5d2e658 (patch)
treefb4a3fbfc0eea1168646125aca7fd53478418b00 /winsup/cygwin/dtable.cc
parentff80d22a7c3d0d330c2892686aa694a080b109cb (diff)
* DevNotes: Add entry cgf-000011.
* fhandler.h (fhandler_base::refcnt): Delete. (fhandler_base::inc_refcnt): New function. (fhandler_base::dec_refcnt): New function. * cygheap.h (cygheap_fdnew::~cygheap_fdnew): Accommodate split of refcnt to inc_refcnt/dec_refcnt. (cygheap_fdget::cygheap_fdget): Ditto. (cygheap_fdget::~cygheap_fdget::cygheap_fdget): Ditto. * dtable.cc (dtable::release): Ditto. (cygwin_attach_handle_to_fd): Ditto. (dtable::init_std_file_from_handle): Ditto. (dtable::dup3): On success, return with fdtab locked. * dtable.h (dtable): Add dup_finish as a friend. * syscalls.cc (dup_finish): Define new function. Increment refcnt while fdtab is locked. (dup2): Use common dup_finish() to perform dup operation. (dup3): Ditto.
Diffstat (limited to 'winsup/cygwin/dtable.cc')
-rw-r--r--winsup/cygwin/dtable.cc11
1 files changed, 7 insertions, 4 deletions
diff --git a/winsup/cygwin/dtable.cc b/winsup/cygwin/dtable.cc
index fc3a502f9..059d782d0 100644
--- a/winsup/cygwin/dtable.cc
+++ b/winsup/cygwin/dtable.cc
@@ -243,7 +243,7 @@ dtable::release (int fd)
{
if (fds[fd]->need_fixup_before ())
dec_need_fixup_before ();
- fds[fd]->refcnt (-1);
+ fds[fd]->dec_refcnt ();
fds[fd] = NULL;
if (fd <= 2)
set_std_handle (fd);
@@ -259,7 +259,7 @@ cygwin_attach_handle_to_fd (char *name, int fd, HANDLE handle, mode_t bin,
if (!fh)
return -1;
cygheap->fdtab[fd] = fh;
- cygheap->fdtab[fd]->refcnt (1);
+ cygheap->fdtab[fd]->inc_refcnt ();
fh->init (handle, myaccess, bin ?: fh->pc_binmode ());
return fd;
}
@@ -398,7 +398,7 @@ dtable::init_std_file_from_handle (int fd, HANDLE handle)
fh->open_setup (openflags);
fh->usecount = 0;
cygheap->fdtab[fd] = fh;
- cygheap->fdtab[fd]->refcnt (1);
+ cygheap->fdtab[fd]->inc_refcnt ();
set_std_handle (fd);
paranoid_printf ("fd %d, handle %p", fd, handle);
}
@@ -713,6 +713,7 @@ dtable::dup3 (int oldfd, int newfd, int flags)
MALLOC_CHECK;
debug_printf ("dup3 (%d, %d, %p)", oldfd, newfd, flags);
lock ();
+ bool do_unlock = true;
if (not_open (oldfd))
{
@@ -760,6 +761,7 @@ dtable::dup3 (int oldfd, int newfd, int flags)
goto done;
}
+ do_unlock = false;
fds[newfd] = newfh;
if ((res = newfd) <= 2)
@@ -767,7 +769,8 @@ dtable::dup3 (int oldfd, int newfd, int flags)
done:
MALLOC_CHECK;
- unlock ();
+ if (do_unlock)
+ unlock ();
syscall_printf ("%R = dup3(%d, %d, %p)", res, oldfd, newfd, flags);
return res;