Skip to content

Commit

Permalink
Merge pull request squeaky-pl#134 from ifplusor/fix-122
Browse files Browse the repository at this point in the history
Fixes squeaky-pl#122, upgrade uvloop to 0.9+
  • Loading branch information
squeaky-pl authored Nov 3, 2018
2 parents d68484e + 847b628 commit 480a819
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 36 deletions.
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
keywords=['web', 'asyncio'],
platforms='x86_64 Linux and MacOS X',
install_requires=[
'uvloop<0.9.0',
'uvloop>=0.9.0',
],
entry_points="""
[console_scripts]
Expand All @@ -49,6 +49,7 @@
'Programming Language :: C',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: Implementation :: CPython',
'Topic :: Internet :: WWW/HTTP'
],
Expand Down
35 changes: 0 additions & 35 deletions src/japronto/protocol/cprotocol.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ static PyObject* Parser;
static PyObject* PyRequest;
static PyObject* RouteNotFoundException;

static PyObject* socket_str;

static Request_CAPI* request_capi;
static Matcher_CAPI* matcher_capi;
static Response_CAPI* response_capi;
Expand Down Expand Up @@ -165,19 +163,6 @@ Protocol_init(Protocol* self, PyObject *args, PyObject *kw)
}


// copied from Modules/socketmodule.h
// FIXME on Windows SOCKET_T is a different type
typedef int SOCKET_T;
typedef struct {
PyObject_HEAD
SOCKET_T sock_fd;
// more things here that we dont need
} PySocketSockObject;


#include <netinet/in.h>
#include <netinet/tcp.h>

static PyObject*
Protocol_connection_made(Protocol* self, PyObject* transport)
{
Expand All @@ -189,24 +174,10 @@ Protocol_connection_made(Protocol* self, PyObject* transport)
self->false_cnt = Py_REFCNT(Py_False);
#endif

PyObject* get_extra_info = NULL;
PySocketSockObject* socket = NULL;
PyObject* connections = NULL;
self->transport = transport;
Py_INCREF(self->transport);

if(!(get_extra_info = PyObject_GetAttrString(transport, "get_extra_info")))
goto error;

if(!(socket = (PySocketSockObject*)PyObject_CallFunctionObjArgs(
get_extra_info, socket_str, NULL)))
goto error;

const int on = 1;

if(setsockopt(socket->sock_fd, IPPROTO_TCP, TCP_NODELAY, &on, sizeof(on)) != 0)
goto error;

if(!(self->write = PyObject_GetAttrString(transport, "write")))
goto error;

Expand Down Expand Up @@ -234,8 +205,6 @@ Protocol_connection_made(Protocol* self, PyObject* transport)

finally:
Py_XDECREF(connections);
Py_XDECREF(socket);
Py_XDECREF(get_extra_info);
Py_RETURN_NONE;
}

Expand Down Expand Up @@ -913,7 +882,6 @@ PyInit_cprotocol(void)
PyObject* api_capsule = NULL;
PyObject* crequest = NULL;
PyObject* route = NULL;
socket_str = NULL;

if (PyType_Ready(&ProtocolType) < 0)
goto error;
Expand Down Expand Up @@ -968,9 +936,6 @@ PyInit_cprotocol(void)
if(!response_capi)
goto error;

if(!(socket_str = PyUnicode_FromString("socket")))
goto error;

Py_INCREF(&ProtocolType);
PyModule_AddObject(m, "Protocol", (PyObject*)&ProtocolType);

Expand Down

0 comments on commit 480a819

Please sign in to comment.