Optimization for the "--no-unix-sockets" case.
This commit is contained in:
@@ -738,42 +738,40 @@ fail:
|
|||||||
static PyObject *
|
static PyObject *
|
||||||
nxt_py_asgi_create_address(nxt_unit_sptr_t *sptr, uint8_t len, uint16_t port)
|
nxt_py_asgi_create_address(nxt_unit_sptr_t *sptr, uint8_t len, uint16_t port)
|
||||||
{
|
{
|
||||||
|
#if (NXT_HAVE_UNIX_DOMAIN)
|
||||||
size_t prefix_len;
|
size_t prefix_len;
|
||||||
nxt_str_t addr;
|
|
||||||
PyObject *pair, *v;
|
PyObject *pair, *v;
|
||||||
|
nxt_str_t addr;
|
||||||
|
|
||||||
addr.length = len;
|
addr.length = len;
|
||||||
addr.start = nxt_unit_sptr_get(sptr);
|
addr.start = nxt_unit_sptr_get(sptr);
|
||||||
|
|
||||||
prefix_len = nxt_length("unix:");
|
prefix_len = nxt_length("unix:");
|
||||||
if (!nxt_str_start(&addr, "unix:", prefix_len)) {
|
if (nxt_str_start(&addr, "unix:", prefix_len)) {
|
||||||
return nxt_py_asgi_create_ip_address(sptr, len, port);
|
|
||||||
|
pair = PyTuple_New(2);
|
||||||
|
if (nxt_slow_path(pair == NULL)) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
addr.start += prefix_len;
|
||||||
|
addr.length -= prefix_len;
|
||||||
|
|
||||||
|
v = PyString_FromStringAndSize((const char *) addr.start, addr.length);
|
||||||
|
if (nxt_slow_path(v == NULL)) {
|
||||||
|
Py_DECREF(pair);
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
PyTuple_SET_ITEM(pair, 0, v);
|
||||||
|
PyTuple_SET_ITEM(pair, 1, Py_None);
|
||||||
|
|
||||||
|
return pair;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if NXT_HAVE_UNIX_DOMAIN
|
|
||||||
pair = PyTuple_New(2);
|
|
||||||
if (nxt_slow_path(pair == NULL)) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
addr.start += prefix_len;
|
|
||||||
addr.length -= prefix_len;
|
|
||||||
|
|
||||||
v = PyString_FromStringAndSize((const char *) addr.start, addr.length);
|
|
||||||
if (nxt_slow_path(v == NULL)) {
|
|
||||||
Py_DECREF(pair);
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
PyTuple_SET_ITEM(pair, 0, v);
|
|
||||||
PyTuple_SET_ITEM(pair, 1, Py_None);
|
|
||||||
|
|
||||||
return pair;
|
|
||||||
|
|
||||||
#else
|
|
||||||
return NULL;
|
|
||||||
#endif
|
#endif
|
||||||
|
return nxt_py_asgi_create_ip_address(sptr, len, port);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user