mirror of
git://sourceware.org/git/newlib-cygwin.git
synced 2025-02-28 12:05:47 +08:00
* transport_pipes.cc (pipe_instance_lock_once): Remove.
(pipe_instance_lock): Remove. (pipe_instance): Remove. (initialise_pipe_instance_lock): Remove. (transport_layer_pipes::accept): Drop entire pipe_instance handling. (transport_layer_pipes::close): Ditto.
This commit is contained in:
parent
5ed0628cf0
commit
6f125cff2b
@ -1,3 +1,12 @@
|
|||||||
|
2012-11-26 Corinna Vinschen <corinna@vinschen.de>
|
||||||
|
|
||||||
|
* transport_pipes.cc (pipe_instance_lock_once): Remove.
|
||||||
|
(pipe_instance_lock): Remove.
|
||||||
|
(pipe_instance): Remove.
|
||||||
|
(initialise_pipe_instance_lock): Remove.
|
||||||
|
(transport_layer_pipes::accept): Drop entire pipe_instance handling.
|
||||||
|
(transport_layer_pipes::close): Ditto.
|
||||||
|
|
||||||
2012-11-23 Corinna Vinschen <corinna@vinschen.de>
|
2012-11-23 Corinna Vinschen <corinna@vinschen.de>
|
||||||
|
|
||||||
* cygserver.cc (main): Call listen right after creating the
|
* cygserver.cc (main): Call listen right after creating the
|
||||||
|
@ -52,21 +52,6 @@ enum
|
|||||||
|
|
||||||
#ifndef __INSIDE_CYGWIN__
|
#ifndef __INSIDE_CYGWIN__
|
||||||
|
|
||||||
static pthread_once_t pipe_instance_lock_once = PTHREAD_ONCE_INIT;
|
|
||||||
static CRITICAL_SECTION pipe_instance_lock;
|
|
||||||
static long pipe_instance = 0;
|
|
||||||
|
|
||||||
static void
|
|
||||||
initialise_pipe_instance_lock ()
|
|
||||||
{
|
|
||||||
assert (pipe_instance == 0);
|
|
||||||
InitializeCriticalSection (&pipe_instance_lock);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* !__INSIDE_CYGWIN__ */
|
|
||||||
|
|
||||||
#ifndef __INSIDE_CYGWIN__
|
|
||||||
|
|
||||||
transport_layer_pipes::transport_layer_pipes (const HANDLE hPipe)
|
transport_layer_pipes::transport_layer_pipes (const HANDLE hPipe)
|
||||||
: _hPipe (hPipe),
|
: _hPipe (hPipe),
|
||||||
_is_accepted_endpoint (true),
|
_is_accepted_endpoint (true),
|
||||||
@ -143,26 +128,13 @@ transport_layer_pipes::accept (bool *const recoverable)
|
|||||||
assert (!_is_accepted_endpoint);
|
assert (!_is_accepted_endpoint);
|
||||||
assert (_is_listening_endpoint);
|
assert (_is_listening_endpoint);
|
||||||
|
|
||||||
pthread_once (&pipe_instance_lock_once, &initialise_pipe_instance_lock);
|
debug ("Try to create named pipe instance: %ls", _pipe_name);
|
||||||
|
|
||||||
EnterCriticalSection (&pipe_instance_lock);
|
|
||||||
|
|
||||||
// Read: http://www.securityinternals.com/research/papers/namedpipe.php
|
|
||||||
// See also the Microsoft security bulletins MS00-053 and MS01-031.
|
|
||||||
|
|
||||||
debug ("Try to create named pipe instance %ld: %ls",
|
|
||||||
pipe_instance + 1, _pipe_name);
|
|
||||||
|
|
||||||
const HANDLE accept_pipe =
|
const HANDLE accept_pipe =
|
||||||
CreateNamedPipeW (_pipe_name, PIPE_ACCESS_DUPLEX,
|
CreateNamedPipeW (_pipe_name, PIPE_ACCESS_DUPLEX,
|
||||||
PIPE_TYPE_BYTE | PIPE_WAIT, PIPE_UNLIMITED_INSTANCES,
|
PIPE_TYPE_BYTE | PIPE_WAIT, PIPE_UNLIMITED_INSTANCES,
|
||||||
0, 0, 1000, &sec_all_nih);
|
0, 0, 1000, &sec_all_nih);
|
||||||
|
|
||||||
if (accept_pipe != INVALID_HANDLE_VALUE)
|
|
||||||
InterlockedIncrement (&pipe_instance);
|
|
||||||
|
|
||||||
LeaveCriticalSection (&pipe_instance_lock);
|
|
||||||
|
|
||||||
if (accept_pipe == INVALID_HANDLE_VALUE)
|
if (accept_pipe == INVALID_HANDLE_VALUE)
|
||||||
{
|
{
|
||||||
debug_printf ("error creating pipe (%lu).", GetLastError ());
|
debug_printf ("error creating pipe (%lu).", GetLastError ());
|
||||||
@ -199,11 +171,7 @@ transport_layer_pipes::close ()
|
|||||||
{
|
{
|
||||||
(void) FlushFileBuffers (_hPipe); // Blocks until client reads.
|
(void) FlushFileBuffers (_hPipe); // Blocks until client reads.
|
||||||
(void) DisconnectNamedPipe (_hPipe);
|
(void) DisconnectNamedPipe (_hPipe);
|
||||||
EnterCriticalSection (&pipe_instance_lock);
|
|
||||||
(void) CloseHandle (_hPipe);
|
(void) CloseHandle (_hPipe);
|
||||||
assert (pipe_instance > 0);
|
|
||||||
InterlockedDecrement (&pipe_instance);
|
|
||||||
LeaveCriticalSection (&pipe_instance_lock);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
(void) CloseHandle (_hPipe);
|
(void) CloseHandle (_hPipe);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user