Deleted
Added
nxt_python_asgi.c (1715:95874fd97501) | nxt_python_asgi.c (1767:582a004c73f8) |
---|---|
1 2/* 3 * Copyright (C) NGINX, Inc. 4 */ 5 6 7#include <python/nxt_python.h> 8 --- 1117 unchanged lines hidden (view full) --- 1126 nxt_queue_remove(lnk); 1127 } 1128} 1129 1130 1131static PyObject * 1132nxt_py_asgi_port_read(PyObject *self, PyObject *args) 1133{ | 1 2/* 3 * Copyright (C) NGINX, Inc. 4 */ 5 6 7#include <python/nxt_python.h> 8 --- 1117 unchanged lines hidden (view full) --- 1126 nxt_queue_remove(lnk); 1127 } 1128} 1129 1130 1131static PyObject * 1132nxt_py_asgi_port_read(PyObject *self, PyObject *args) 1133{ |
1134 int rc; 1135 PyObject *arg; 1136 Py_ssize_t n; 1137 nxt_unit_ctx_t *ctx; 1138 nxt_unit_port_t *port; | 1134 int rc; 1135 PyObject *arg0, *arg1, *res; 1136 Py_ssize_t n; 1137 nxt_unit_ctx_t *ctx; 1138 nxt_unit_port_t *port; 1139 nxt_py_asgi_ctx_data_t *ctx_data; |
1139 1140 n = PyTuple_GET_SIZE(args); 1141 1142 if (n != 2) { 1143 nxt_unit_alert(NULL, 1144 "nxt_py_asgi_port_read: invalid number of arguments %d", 1145 (int) n); 1146 1147 return PyErr_Format(PyExc_TypeError, "invalid number of arguments"); 1148 } 1149 | 1140 1141 n = PyTuple_GET_SIZE(args); 1142 1143 if (n != 2) { 1144 nxt_unit_alert(NULL, 1145 "nxt_py_asgi_port_read: invalid number of arguments %d", 1146 (int) n); 1147 1148 return PyErr_Format(PyExc_TypeError, "invalid number of arguments"); 1149 } 1150 |
1150 arg = PyTuple_GET_ITEM(args, 0); 1151 if (nxt_slow_path(arg == NULL || PyLong_Check(arg) == 0)) { | 1151 arg0 = PyTuple_GET_ITEM(args, 0); 1152 if (nxt_slow_path(arg0 == NULL || PyLong_Check(arg0) == 0)) { |
1152 return PyErr_Format(PyExc_TypeError, 1153 "the first argument is not a long"); 1154 } 1155 | 1153 return PyErr_Format(PyExc_TypeError, 1154 "the first argument is not a long"); 1155 } 1156 |
1156 ctx = PyLong_AsVoidPtr(arg); | 1157 ctx = PyLong_AsVoidPtr(arg0); |
1157 | 1158 |
1158 arg = PyTuple_GET_ITEM(args, 1); 1159 if (nxt_slow_path(arg == NULL || PyLong_Check(arg) == 0)) { | 1159 arg1 = PyTuple_GET_ITEM(args, 1); 1160 if (nxt_slow_path(arg1 == NULL || PyLong_Check(arg1) == 0)) { |
1160 return PyErr_Format(PyExc_TypeError, 1161 "the second argument is not a long"); 1162 } 1163 | 1161 return PyErr_Format(PyExc_TypeError, 1162 "the second argument is not a long"); 1163 } 1164 |
1164 port = PyLong_AsVoidPtr(arg); | 1165 port = PyLong_AsVoidPtr(arg1); |
1165 | 1166 |
1166 nxt_unit_debug(ctx, "asgi_port_read %p %p", ctx, port); 1167 | |
1168 rc = nxt_unit_process_port_msg(ctx, port); 1169 | 1167 rc = nxt_unit_process_port_msg(ctx, port); 1168 |
1169 nxt_unit_debug(ctx, "asgi_port_read(%p,%p): %d", ctx, port, rc); 1170 |
|
1170 if (nxt_slow_path(rc == NXT_UNIT_ERROR)) { 1171 return PyErr_Format(PyExc_RuntimeError, 1172 "error processing port %d message", port->id.id); 1173 } 1174 | 1171 if (nxt_slow_path(rc == NXT_UNIT_ERROR)) { 1172 return PyErr_Format(PyExc_RuntimeError, 1173 "error processing port %d message", port->id.id); 1174 } 1175 |
1176 if (rc == NXT_UNIT_OK) { 1177 ctx_data = ctx->data; 1178 1179 res = PyObject_CallFunctionObjArgs(ctx_data->loop_call_soon, 1180 nxt_py_port_read, 1181 arg0, arg1, NULL); 1182 if (nxt_slow_path(res == NULL)) { 1183 nxt_unit_alert(ctx, "Python failed to call 'loop.call_soon'"); 1184 nxt_python_print_exception(); 1185 } 1186 1187 Py_XDECREF(res); 1188 } 1189 |
|
1175 Py_RETURN_NONE; 1176} 1177 1178 1179PyObject * 1180nxt_py_asgi_enum_headers(PyObject *headers, nxt_py_asgi_enum_header_cb cb, 1181 void *data) 1182{ --- 348 unchanged lines hidden --- | 1190 Py_RETURN_NONE; 1191} 1192 1193 1194PyObject * 1195nxt_py_asgi_enum_headers(PyObject *headers, nxt_py_asgi_enum_header_cb cb, 1196 void *data) 1197{ --- 348 unchanged lines hidden --- |