summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/fhandler.h
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2012-06-03 18:02:45 +0000
committerChristopher Faylor <me@cgf.cx>2012-06-03 18:02:45 +0000
commit3143cb7c00fc1b6f4d75a83ac28f3bfbc5d2e658 (patch)
treefb4a3fbfc0eea1168646125aca7fd53478418b00 /winsup/cygwin/fhandler.h
parentff80d22a7c3d0d330c2892686aa694a080b109cb (diff)
downloadcygnal-3143cb7c00fc1b6f4d75a83ac28f3bfbc5d2e658.tar.gz
cygnal-3143cb7c00fc1b6f4d75a83ac28f3bfbc5d2e658.tar.bz2
cygnal-3143cb7c00fc1b6f4d75a83ac28f3bfbc5d2e658.zip
* 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/fhandler.h')
-rw-r--r--winsup/cygwin/fhandler.h11
1 files changed, 2 insertions, 9 deletions
diff --git a/winsup/cygwin/fhandler.h b/winsup/cygwin/fhandler.h
index 84f6e4c3f..72f8d8429 100644
--- a/winsup/cygwin/fhandler.h
+++ b/winsup/cygwin/fhandler.h
@@ -182,15 +182,8 @@ class fhandler_base
HANDLE read_state;
public:
- long refcnt(long i = 0)
- {
- debug_only_printf ("%p, %s, i %d, refcnt %ld", this, get_name (), i, _refcnt + i);
- /* This MUST be an interlocked operation. If multiple threads access the
- same descriptor in quick succession, a context switch can interrupt
- the += operation and we wrongly end up with a refcnt of 0 in the
- cygheap_fdget destructor. */
- return i ? InterlockedAdd (&_refcnt, i) : _refcnt;
- }
+ long inc_refcnt () {return InterlockedIncrement (&_refcnt);}
+ long dec_refcnt () {return InterlockedDecrement (&_refcnt);}
class fhandler_base *archetype;
int usecount;