forked from mirrors/kore
pysock: call disable read/write only when needed
This commit is contained in:
parent
d41054bd26
commit
2217c7a2c8
10
src/python.c
10
src/python.c
|
@ -1657,7 +1657,7 @@ pysocket_alloc(void)
|
|||
static void
|
||||
pysocket_dealloc(struct pysocket *sock)
|
||||
{
|
||||
if (sock->scheduled) {
|
||||
if (sock->scheduled && sock->fd == -1) {
|
||||
kore_platform_disable_read(sock->fd);
|
||||
#if !defined(__linux__)
|
||||
kore_platform_disable_write(sock->fd);
|
||||
|
@ -1838,6 +1838,14 @@ pysocket_connect(struct pysocket *sock, PyObject *args)
|
|||
static PyObject *
|
||||
pysocket_close(struct pysocket *sock, PyObject *args)
|
||||
{
|
||||
if (sock->scheduled) {
|
||||
sock->scheduled = 0;
|
||||
kore_platform_disable_read(sock->fd);
|
||||
#if !defined(__linux__)
|
||||
kore_platform_disable_write(sock->fd);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (sock->socket != NULL) {
|
||||
Py_DECREF(sock->socket);
|
||||
sock->socket = NULL;
|
||||
|
|
Loading…
Reference in New Issue