From bd5db506a79eed8551dd8acad93476e5ba49aa14 Mon Sep 17 00:00:00 2001 From: Perry Werneck Date: Fri, 10 Jan 2020 14:50:59 -0300 Subject: [PATCH] Fixing bug detected when using multiple sessions in the same process. --- .gitignore | 1 - client/src/session/remote/linux/session.cc | 6 +++++- client/src/testprogram/testprogram.cc | 2 +- server/link.sh | 14 ++++++++++++++ server/src/core/getproperties.c | 2 +- server/src/core/linux/start.c | 13 ++++++++++--- server/src/core/methods/methods.c | 2 +- server/src/core/setproperties.c | 2 +- server/src/include/ipc-glib.h | 3 ++- server/src/plugin/plugin.c | 2 +- 10 files changed, 36 insertions(+), 11 deletions(-) create mode 100755 server/link.sh diff --git a/.gitignore b/.gitignore index 3a29553..bef97c3 100644 --- a/.gitignore +++ b/.gitignore @@ -30,4 +30,3 @@ doxygen/html *.lib *.exp - diff --git a/client/src/session/remote/linux/session.cc b/client/src/session/remote/linux/session.cc index 075f540..953624b 100644 --- a/client/src/session/remote/linux/session.cc +++ b/client/src/session/remote/linux/session.cc @@ -87,7 +87,11 @@ std::transform(this->name.begin(), this->name.end(), this->name.begin(),[](unsigned char c){ return std::tolower(c); }); - this->path = "/br/com/bb/tn3270/session"; + this->path = "/br/com/bb/"; + this->path += string(id,(sep - id)); + this->path += "/"; + this->path += (sep+1); + this->interface = "br.com.bb.tn3270.session"; debug("D-Bus Object name=\"",this->name,"\" D-Bus Object path=\"",this->path,"\""); diff --git a/client/src/testprogram/testprogram.cc b/client/src/testprogram/testprogram.cc index 74da6b5..d9fc1e9 100644 --- a/client/src/testprogram/testprogram.cc +++ b/client/src/testprogram/testprogram.cc @@ -177,7 +177,7 @@ int main(int argc, char **argv) { - const char * session = ""; // ":a"; + const char * session = ":a"; #ifndef _WIN32 #pragma GCC diagnostic push diff --git a/server/link.sh b/server/link.sh new file mode 100755 index 0000000..f00e1e0 --- /dev/null +++ b/server/link.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +make clean +if [ "$?" != "0" ]; then + exit -1 +fi + +make Debug +if [ "$?" != "0" ]; then + exit -1 +fi + +sudo ln -sf $(readlink -f ../.bin/Debug/ipcserver.so) /usr/lib64/$(pkg-config --variable=product_name lib3270)-plugins/ipcserver.so + diff --git a/server/src/core/getproperties.c b/server/src/core/getproperties.c index c55ae81..ca44154 100644 --- a/server/src/core/getproperties.c +++ b/server/src/core/getproperties.c @@ -46,7 +46,7 @@ GVariant * ipc3270_get_property(GObject *object, const gchar *property_name, GEr errno = 0; // Just in case. - lib3270_trace_event(hSession,"GetProperty(%s) called on session %c\n",property_name,lib3270_get_session_id(hSession)); + lib3270_write_event_trace(hSession,"GetProperty(%s) called on session %c\n",property_name,lib3270_get_session_id(hSession)); // Boolean properties const LIB3270_INT_PROPERTY * boolprop = lib3270_get_boolean_properties_list(); diff --git a/server/src/core/linux/start.c b/server/src/core/linux/start.c index 4b51633..fcf0492 100644 --- a/server/src/core/linux/start.c +++ b/server/src/core/linux/start.c @@ -128,11 +128,12 @@ static gboolean register_object(ipc3270 *ipc, const char *name, char id) { gchar *ptr; g_autofree gchar *object_name = g_strdup_printf(PW3270_IPC_SESSION_BUS_NAME,name,id); + g_autofree gchar *object_path = g_strdup_printf(PW3270_IPC_SESSION_BUS_PATH,name,id); for(ptr=object_name;*ptr;ptr++) *ptr = g_ascii_tolower(*ptr); - debug("Requesting \"%s\"",object_name); + debug("Requesting object \"%s\"",object_name); // https://dbus.freedesktop.org/doc/dbus-specification.html GVariant * response = @@ -187,10 +188,12 @@ static gboolean register_object(ipc3270 *ipc, const char *name, char id) { GDBusNodeInfo * introspection_data = g_dbus_node_info_new_for_xml(introspection_xml, NULL); + debug("interface=\"%s\" path=\"%s\"",PW3270_IPC_SESSION_INTERFACE_NAME,object_path); + // Register object-id ipc->dbus.id = g_dbus_connection_register_object ( ipc->dbus.connection, - PW3270_IPC_SESSION_OBJECT_PATH, + object_path, introspection_data->interfaces[0], &interface_vtable, ipc, @@ -203,7 +206,11 @@ static gboolean register_object(ipc3270 *ipc, const char *name, char id) { if(error) { - g_message("Can't register object \"%s\": %s",object_name,error->message); + g_message("Can't register object \"%s\" with interface \"%s\" and path \"%s\": %s", + object_name, + PW3270_IPC_SESSION_INTERFACE_NAME, + object_path, + error->message); g_error_free(error); return FALSE; diff --git a/server/src/core/methods/methods.c b/server/src/core/methods/methods.c index 608ae3a..6cdde71 100644 --- a/server/src/core/methods/methods.c +++ b/server/src/core/methods/methods.c @@ -81,7 +81,7 @@ int ipc3270_method_call(GObject *object, const gchar *method_name, GVariant *req debug("%s(%s,request=%p,response=%p)",__FUNCTION__,method_name,request,response); - lib3270_trace_event(hSession,"Method %s called on session %c\n",method_name,lib3270_get_session_id(hSession)); + lib3270_write_event_trace(hSession,"Method %s called on session %c\n",method_name,lib3270_get_session_id(hSession)); for(ix = 0; ix < G_N_ELEMENTS(methods); ix++) { diff --git a/server/src/core/setproperties.c b/server/src/core/setproperties.c index 861f401..5685a71 100644 --- a/server/src/core/setproperties.c +++ b/server/src/core/setproperties.c @@ -50,7 +50,7 @@ gboolean ipc3270_set_property(GObject *object, const gchar *property_name, GVari return FALSE; } - lib3270_trace_event(hSession,"SetProperty(%s) called on session %c\n",property_name,lib3270_get_session_id(hSession)); + lib3270_write_event_trace(hSession,"SetProperty(%s) called on session %c\n",property_name,lib3270_get_session_id(hSession)); // Boolean properties const LIB3270_INT_PROPERTY * boolprop = lib3270_get_boolean_properties_list(); diff --git a/server/src/include/ipc-glib.h b/server/src/include/ipc-glib.h index 98d2652..bee9e20 100644 --- a/server/src/include/ipc-glib.h +++ b/server/src/include/ipc-glib.h @@ -46,8 +46,9 @@ #else #define PW3270_IPC_SESSION_BUS_NAME "br.com.bb.%s.%c" + #define PW3270_IPC_SESSION_BUS_PATH "/br/com/bb/%s/%c" + #define PW3270_IPC_SESSION_INTERFACE_NAME "br.com.bb.tn3270.session" - #define PW3270_IPC_SESSION_OBJECT_PATH "/br/com/bb/tn3270/session" #define PW3270_IPC_SERVICE_BUS_NAME "br.com.bb.tn3270.service" #define PW3270_IPC_SERVICE_INTERFACE_NAME "br.com.bb.tn3270.service" diff --git a/server/src/plugin/plugin.c b/server/src/plugin/plugin.c index 411ed0b..5c3e972 100644 --- a/server/src/plugin/plugin.c +++ b/server/src/plugin/plugin.c @@ -98,7 +98,7 @@ char id = lib3270_get_session_id(v3270_get_session(terminal)); if(id) { - g_autofree gchar * widget_name = g_strdup_printf("%s:%c",v3270_get_session_name(terminal),id); + g_autofree gchar * widget_name = g_strdup_printf("%s:%c",session_name,id); v3270_set_session_name(terminal, widget_name); } -- libgit2 0.21.2