Skip to content

Commit ec4ccb5

Browse files
author
Nick Anderson
committed
Revert "windows: updating close logic for server and client pipes (osquery#53)"
This reverts commit cb4df96.
1 parent cb4df96 commit ec4ccb5

File tree

1 file changed

+10
-17
lines changed

1 file changed

+10
-17
lines changed

osquery/TPipe.py

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def close(self):
3232
in the same way
3333
"""
3434
if self._handle is not None:
35-
win32file.CloseHandle(self._handle)
35+
win32pipe.DisconnectNamedPipe(self._handle)
3636
self._handle = None
3737

3838

@@ -67,10 +67,13 @@ def open(self):
6767
while conns < self._max_conn_attempts:
6868
try:
6969
h = win32file.CreateFile(
70-
self._pipe_name,
71-
win32file.GENERIC_READ | win32file.GENERIC_WRITE, 0, None,
72-
win32file.OPEN_EXISTING, win32file.FILE_FLAG_OVERLAPPED,
73-
None)
70+
self._pipe_name,
71+
win32file.GENERIC_READ | win32file.GENERIC_WRITE,
72+
0,
73+
None,
74+
win32file.OPEN_EXISTING,
75+
win32file.FILE_FLAG_OVERLAPPED,
76+
None)
7477
except pywintypes.error as e:
7578
if e.winerror != winerror.ERROR_PIPE_BUSY:
7679
raise TTransportException(
@@ -195,8 +198,8 @@ def create_named_pipe(self):
195198

196199
self._handle = win32pipe.CreateNamedPipe(
197200
self._pipe_name, openMode, pipeMode,
198-
win32pipe.PIPE_UNLIMITED_INSTANCES, self._buff_size,
199-
self._buff_size, win32pipe.NMPWAIT_WAIT_FOREVER, saAttr)
201+
win32pipe.PIPE_UNLIMITED_INSTANCES, self._buff_size, self._buff_size,
202+
win32pipe.NMPWAIT_WAIT_FOREVER, saAttr)
200203

201204
err = win32api.GetLastError()
202205
if self._handle.handle == winerror.ERROR_INVALID_HANDLE:
@@ -220,13 +223,3 @@ def initiate_named_connect(self):
220223
if ret == winerror.ERROR_PIPE_CONNECTED:
221224
win32event.SetEvent(self._overlapped.hEvent)
222225
break
223-
224-
def close(self):
225-
"""
226-
The server must ensure to disconnect so that subsequent reconnect
227-
attempts are successful
228-
"""
229-
if self._handle is not None:
230-
win32pipe.DisconnectNamedPipe(self._handle)
231-
win32file.CloseHandle(self._handle)
232-
self._handle = None

0 commit comments

Comments
 (0)