Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • cellframe/python-cellframe
1 result
Show changes
Commits on Source (5)
......@@ -41,7 +41,7 @@ BOOL WINAPI consoleHandler(DWORD dwType){
void sigfunc(int sig){
if (sig == SIGINT){
log_it(L_NOTICE, "Handler Ctrl+C");
dap_server_loop_stop();
dap_events_stop_all();
deinit_modules();
}
}
......
#pragma once
#define PY_SSIZE_T_CLEAN
#include "Python.h"
#include "dap_server_python.h"
#include "dap_server.h"
#include "dap_client_remote.h"
#include "dap_events.h"
#include "dap_common.h"
#include "dap_events_python.h"
......@@ -24,7 +24,6 @@ PyObject *dap_server_core_loop(PyObject *self, PyObject *args);
PyObject *dap_server_core_listen(PyObject *self, PyObject *args);
static PyMethodDef ServerCorePythonMethods[] = {
{"loop", dap_server_core_loop, METH_VARARGS | METH_STATIC, ""},
{"listen", dap_server_core_listen, METH_VARARGS | METH_STATIC, ""},
{NULL, NULL, 0, NULL}
};
......
......@@ -20,7 +20,7 @@ PyObject *dap_events_socket_remove_and_delete_py(PyDapEventsObject *self, PyObje
bool preserve_inheritor = true;
if (in_bool == Py_False)
preserve_inheritor = false;
dap_events_socket_remove_and_delete(((PyDapEventsSocketObject*)in_obj)->t_events_socket, preserve_inheritor);
dap_events_socket_remove_and_delete_mt(((PyDapEventsSocketObject*)in_obj)->t_events_socket->worker,((PyDapEventsSocketObject*)in_obj)->t_events_socket);
return PyLong_FromLong(0);
}
......@@ -29,7 +29,7 @@ PyObject *dap_events_socket_kill_socket_py(PyDapEventsObject *self, PyObject *ar
if (!PyArg_ParseTuple(args, "O", &in_obj)){
return NULL;
}
dap_events_socket_kill_socket(((PyDapEventsSocketObject*)in_obj)->t_events_socket);
dap_events_socket_remove_and_delete_mt(((PyDapEventsSocketObject*)in_obj)->t_events_socket->worker,((PyDapEventsSocketObject*)in_obj)->t_events_socket);
return PyLong_FromLong(0);
}
......
......@@ -6,7 +6,7 @@ PyObject *dap_events_socket_create_after_py(PyDapEventsSocketObject *self){
if (self->t_events_socket == NULL){
return NULL;
}
dap_events_socket_create_after(self->t_events_socket);
dap_worker_add_events_socket_auto(self->t_events_socket);
return PyLong_FromLong(0);
}
......@@ -19,7 +19,7 @@ PyObject *dap_events_socket_find_py(PyDapEventsSocketObject *self, PyObject *arg
if (!PyArg_ParseTuple(args, "i|O", &socket, &in_object)){
return NULL;
}
self->t_events_socket = dap_events_socket_find(socket, ((PyDapEventsObject*)in_object)->t_events);
self->t_events_socket = dap_events_socket_find_unsafe(socket, ((PyDapEventsObject*)in_object)->t_events);
return PyLong_FromLong(0);
}
PyObject *dap_events_socket_set_readable_py(PyDapEventsSocketObject *self, PyObject *args){
......@@ -33,7 +33,7 @@ PyObject *dap_events_socket_set_readable_py(PyDapEventsSocketObject *self, PyObj
bool is_ready = true;
if (l_is_ready == Py_False)
is_ready = false;
dap_events_socket_set_readable(self->t_events_socket, is_ready);
dap_events_socket_set_readable_unsafe(self->t_events_socket, is_ready);
return PyLong_FromLong(0);
}
PyObject *dap_events_socket_set_writable_py(PyDapEventsSocketObject *self, PyObject *args){
......@@ -47,7 +47,7 @@ PyObject *dap_events_socket_set_writable_py(PyDapEventsSocketObject *self, PyObj
bool is_ready = true;
if (l_is_ready == Py_False)
is_ready = false;
dap_events_socket_set_writable(self->t_events_socket, is_ready);
dap_events_socket_set_writable_unsafe(self->t_events_socket, is_ready);
return PyLong_FromLong(0);
}
......@@ -61,7 +61,7 @@ PyObject *dap_events_socket_write_py(PyDapEventsSocketObject *self, PyObject *ar
return NULL;
}
char *in_v_bytes = PyBytes_AsString((PyObject*)in_bytes);
size_t res_size = dap_events_socket_write(self->t_events_socket,
size_t res_size = dap_events_socket_write_unsafe(self->t_events_socket,
in_v_bytes, in_size);
return Py_BuildValue("n", res_size);
}
......@@ -78,7 +78,7 @@ PyObject *dap_events_socket_write_f_py(PyDapEventsSocketObject *self, PyObject *
if (!PyArg_VaParse(args, format, ap)){
return NULL;
}
size_t res_size = dap_events_socket_write_f(self->t_events_socket, format, ap);
size_t res_size = dap_events_socket_write_f_unsafe(self->t_events_socket, format, ap);
return Py_BuildValue("n", res_size);
}
PyObject *dap_events_socket_read_py(PyDapEventsSocketObject *self, PyObject *args){
......@@ -90,7 +90,7 @@ PyObject *dap_events_socket_read_py(PyDapEventsSocketObject *self, PyObject *arg
return NULL;
}
void *res = DAP_NEW_SIZE(void*, in_size);
size_t res_size = dap_events_socket_read(self->t_events_socket, res, in_size);
size_t res_size = dap_events_socket_pop_from_buf_in(self->t_events_socket, res, in_size);
PyBytesObject *res_obj = (PyBytesObject*)PyBytes_FromString(res);
return Py_BuildValue("nS", res_size, res_obj);
}
......@@ -106,7 +106,7 @@ PyObject *dap_events_socket_delete_py(PyDapEventsSocketObject *self, PyObject *a
bool boolean = true;
if (in_bool == Py_False)
boolean = false;
dap_events_socket_delete(self->t_events_socket, boolean);
dap_events_socket_remove_and_delete_mt(self->t_events_socket->worker, self->t_events_socket);
return PyLong_FromLong(0);
}
......
......@@ -3,41 +3,30 @@
#define LOG_TAG "libdap-server-core-python"
int dap_server_core_init(uint32_t l_thread_cnt, size_t conn_t){
int result = dap_server_init(l_thread_cnt);
int result = dap_server_init();
if ( result != 0 ) {
log_it( L_CRITICAL, "Can't init socket server module" );
}
dap_events_init(l_thread_cnt, conn_t);
dap_client_remote_init();
return result;
}
void dap_server_core_deinit(void){
dap_client_remote_deinit();
dap_server_deinit();
dap_events_deinit();
}
PyObject *dap_server_core_loop(PyObject *self, PyObject *args){
PyObject *obj_server;
if (!PyArg_ParseTuple(args, "O", &obj_server)){
return NULL;
}
int32_t result = dap_server_loop(((PyDapServerObject*)obj_server)->t_server);
log_it( result ? L_CRITICAL : L_NOTICE, "Server loop stopped with return code %d", ((PyDapServerObject*)obj_server)->t_server );
return PyLong_FromLong(result);
}
PyObject *dap_server_core_listen(PyObject *self, PyObject *args){
const char *addr;
uint16_t port;
uint16_t type;
if (!PyArg_ParseTuple(args, "s|H|H", &addr, &port, &type)){
PyObject *events;
if (!PyArg_ParseTuple(args, "O|s|H|H", &events, &addr, &port, &type)){
return NULL;
}
if (type > 1)
return NULL;
PyObject *obj = _PyObject_New(&dapServer_dapServerType);
((PyDapServerObject*)obj)->t_server = dap_server_listen(addr, port, type);
((PyDapServerObject*)obj)->t_server = dap_server_new(((PyDapEventsObject*)events)->t_events, addr, port, type);
return Py_BuildValue("O", obj);
}
......@@ -70,7 +70,7 @@ class CMakeBuild(build_ext):
setup(
name="CellFrame",
version="0.9-post15",
version="0.10-post1",
description="CellFrame SDK",
author='Demlabs (2007-2020)',
license="GNU GPLv3",
......