Skip to content

Commit

Permalink
Review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Maksim Alzhanov committed Oct 3, 2024
1 parent e96c24c commit 47fb581
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions pymobiledevice3/tcp_forwarder.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def start(self, address='0.0.0.0'):
# as synchronous blocking
readable, writable, exceptional = select.select(self.inputs, [], self.inputs, self.TIMEOUT)
if self.stopped.is_set():
self.logger.info("Closing since stopped is set")
self.logger.debug("Closing since stopped is set")
break

closed_sockets = set()
Expand Down Expand Up @@ -95,18 +95,20 @@ def _handle_close_or_error(self, from_sock):

def _handle_data(self, from_sock, closed_sockets):
self.logger.debug("Handling data from %s", from_sock)
data = None
try:
data = from_sock.recv(1024)
except OSError:
self.logger.debug("oserror when reading from_sock")
self._handle_close_or_error(from_sock)
closed_sockets.add(from_sock)
closed_sockets.add(self.connections[from_sock])
return
# Socket closing is handled in another if block
pass

if len(data) == 0:
# no data means socket was closed
self.logger.info("No data was read from the socket")
if data is None or len(data) == 0:
if data is None:
# data is none means we had an error reading from socket
self.logger.debug("oserror when reading from_sock")
else:
# Empty data means socket was closed
self.logger.info("No data was read from the socket")
self._handle_close_or_error(from_sock)
closed_sockets.add(from_sock)
closed_sockets.add(self.connections[from_sock])
Expand Down

0 comments on commit 47fb581

Please sign in to comment.