Skip to content
This repository has been archived by the owner on Sep 13, 2024. It is now read-only.

Commit

Permalink
Add protection against closed sockets.
Browse files Browse the repository at this point in the history
  • Loading branch information
freakboy3742 committed May 4, 2024
1 parent ce7837e commit 5ce27ae
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/gbulb/glib_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -659,39 +659,44 @@ def sock_recv(self, sock, nbytes, flags=0):
channel = self._channel_from_socket(sock)

def read_func(channel, nbytes):
return sock.recv(nbytes, flags)
if not sock._closed:
return sock.recv(nbytes, flags)

return self._channel_read(channel, nbytes, read_func)

def sock_recv_into(self, sock, buf, flags=0):
channel = self._channel_from_socket(sock)

def read_func(channel, nbytes):
return sock.recv_into(buf, flags)
if not sock._closed:
return sock.recv_into(buf, flags)

return self._channel_read(channel, len(buf), read_func)

def sock_recvfrom(self, sock, nbytes, flags=0):
channel = self._channel_from_socket(sock)

def read_func(channel, nbytes):
return sock.recvfrom(nbytes, flags)
if not sock._closed:
return sock.recvfrom(nbytes, flags)

return self._channel_read(channel, nbytes, read_func)

def sock_sendall(self, sock, buf, flags=0):
channel = self._channel_from_socket(sock)

def write_func(channel, buf):
return sock.send(buf, flags)
if not sock._closed:
return sock.send(buf, flags)

return self._channel_write(channel, buf, write_func)

def sock_sendallto(self, sock, buf, addr, flags=0):
channel = self._channel_from_socket(sock)

def write_func(channel, buf):
return sock.sendto(buf, flags, addr)
if not sock._closed:
return sock.sendto(buf, flags, addr)

return self._channel_write(channel, buf, write_func)

Expand Down

0 comments on commit 5ce27ae

Please sign in to comment.