Commit bd5db506a79eed8551dd8acad93476e5ba49aa14

Authored by Perry Werneck
1 parent 4b0b7e0c
Exists in master and in 1 other branch develop

Fixing bug detected when using multiple sessions in the same process.

@@ -30,4 +30,3 @@ doxygen/html @@ -30,4 +30,3 @@ doxygen/html
30 *.lib 30 *.lib
31 *.exp 31 *.exp
32 32
33 -  
client/src/session/remote/linux/session.cc
@@ -87,7 +87,11 @@ @@ -87,7 +87,11 @@
87 87
88 std::transform(this->name.begin(), this->name.end(), this->name.begin(),[](unsigned char c){ return std::tolower(c); }); 88 std::transform(this->name.begin(), this->name.end(), this->name.begin(),[](unsigned char c){ return std::tolower(c); });
89 89
90 - this->path = "/br/com/bb/tn3270/session"; 90 + this->path = "/br/com/bb/";
  91 + this->path += string(id,(sep - id));
  92 + this->path += "/";
  93 + this->path += (sep+1);
  94 +
91 this->interface = "br.com.bb.tn3270.session"; 95 this->interface = "br.com.bb.tn3270.session";
92 96
93 debug("D-Bus Object name=\"",this->name,"\" D-Bus Object path=\"",this->path,"\""); 97 debug("D-Bus Object name=\"",this->name,"\" D-Bus Object path=\"",this->path,"\"");
client/src/testprogram/testprogram.cc
@@ -177,7 +177,7 @@ @@ -177,7 +177,7 @@
177 177
178 int main(int argc, char **argv) { 178 int main(int argc, char **argv) {
179 179
180 - const char * session = ""; // ":a"; 180 + const char * session = ":a";
181 181
182 #ifndef _WIN32 182 #ifndef _WIN32
183 #pragma GCC diagnostic push 183 #pragma GCC diagnostic push
server/link.sh 0 → 100755
@@ -0,0 +1,14 @@ @@ -0,0 +1,14 @@
  1 +#!/bin/bash
  2 +
  3 +make clean
  4 +if [ "$?" != "0" ]; then
  5 + exit -1
  6 +fi
  7 +
  8 +make Debug
  9 +if [ "$?" != "0" ]; then
  10 + exit -1
  11 +fi
  12 +
  13 +sudo ln -sf $(readlink -f ../.bin/Debug/ipcserver.so) /usr/lib64/$(pkg-config --variable=product_name lib3270)-plugins/ipcserver.so
  14 +
server/src/core/getproperties.c
@@ -46,7 +46,7 @@ GVariant * ipc3270_get_property(GObject *object, const gchar *property_name, GEr @@ -46,7 +46,7 @@ GVariant * ipc3270_get_property(GObject *object, const gchar *property_name, GEr
46 46
47 errno = 0; // Just in case. 47 errno = 0; // Just in case.
48 48
49 - lib3270_trace_event(hSession,"GetProperty(%s) called on session %c\n",property_name,lib3270_get_session_id(hSession)); 49 + lib3270_write_event_trace(hSession,"GetProperty(%s) called on session %c\n",property_name,lib3270_get_session_id(hSession));
50 50
51 // Boolean properties 51 // Boolean properties
52 const LIB3270_INT_PROPERTY * boolprop = lib3270_get_boolean_properties_list(); 52 const LIB3270_INT_PROPERTY * boolprop = lib3270_get_boolean_properties_list();
server/src/core/linux/start.c
@@ -128,11 +128,12 @@ static gboolean register_object(ipc3270 *ipc, const char *name, char id) { @@ -128,11 +128,12 @@ static gboolean register_object(ipc3270 *ipc, const char *name, char id) {
128 gchar *ptr; 128 gchar *ptr;
129 129
130 g_autofree gchar *object_name = g_strdup_printf(PW3270_IPC_SESSION_BUS_NAME,name,id); 130 g_autofree gchar *object_name = g_strdup_printf(PW3270_IPC_SESSION_BUS_NAME,name,id);
  131 + g_autofree gchar *object_path = g_strdup_printf(PW3270_IPC_SESSION_BUS_PATH,name,id);
131 132
132 for(ptr=object_name;*ptr;ptr++) 133 for(ptr=object_name;*ptr;ptr++)
133 *ptr = g_ascii_tolower(*ptr); 134 *ptr = g_ascii_tolower(*ptr);
134 135
135 - debug("Requesting \"%s\"",object_name); 136 + debug("Requesting object \"%s\"",object_name);
136 137
137 // https://dbus.freedesktop.org/doc/dbus-specification.html 138 // https://dbus.freedesktop.org/doc/dbus-specification.html
138 GVariant * response = 139 GVariant * response =
@@ -187,10 +188,12 @@ static gboolean register_object(ipc3270 *ipc, const char *name, char id) { @@ -187,10 +188,12 @@ static gboolean register_object(ipc3270 *ipc, const char *name, char id) {
187 188
188 GDBusNodeInfo * introspection_data = g_dbus_node_info_new_for_xml(introspection_xml, NULL); 189 GDBusNodeInfo * introspection_data = g_dbus_node_info_new_for_xml(introspection_xml, NULL);
189 190
  191 + debug("interface=\"%s\" path=\"%s\"",PW3270_IPC_SESSION_INTERFACE_NAME,object_path);
  192 +
190 // Register object-id 193 // Register object-id
191 ipc->dbus.id = g_dbus_connection_register_object ( 194 ipc->dbus.id = g_dbus_connection_register_object (
192 ipc->dbus.connection, 195 ipc->dbus.connection,
193 - PW3270_IPC_SESSION_OBJECT_PATH, 196 + object_path,
194 introspection_data->interfaces[0], 197 introspection_data->interfaces[0],
195 &interface_vtable, 198 &interface_vtable,
196 ipc, 199 ipc,
@@ -203,7 +206,11 @@ static gboolean register_object(ipc3270 *ipc, const char *name, char id) { @@ -203,7 +206,11 @@ static gboolean register_object(ipc3270 *ipc, const char *name, char id) {
203 206
204 if(error) { 207 if(error) {
205 208
206 - g_message("Can't register object \"%s\": %s",object_name,error->message); 209 + g_message("Can't register object \"%s\" with interface \"%s\" and path \"%s\": %s",
  210 + object_name,
  211 + PW3270_IPC_SESSION_INTERFACE_NAME,
  212 + object_path,
  213 + error->message);
207 g_error_free(error); 214 g_error_free(error);
208 return FALSE; 215 return FALSE;
209 216
server/src/core/methods/methods.c
@@ -81,7 +81,7 @@ int ipc3270_method_call(GObject *object, const gchar *method_name, GVariant *req @@ -81,7 +81,7 @@ int ipc3270_method_call(GObject *object, const gchar *method_name, GVariant *req
81 81
82 debug("%s(%s,request=%p,response=%p)",__FUNCTION__,method_name,request,response); 82 debug("%s(%s,request=%p,response=%p)",__FUNCTION__,method_name,request,response);
83 83
84 - lib3270_trace_event(hSession,"Method %s called on session %c\n",method_name,lib3270_get_session_id(hSession)); 84 + lib3270_write_event_trace(hSession,"Method %s called on session %c\n",method_name,lib3270_get_session_id(hSession));
85 85
86 for(ix = 0; ix < G_N_ELEMENTS(methods); ix++) { 86 for(ix = 0; ix < G_N_ELEMENTS(methods); ix++) {
87 87
server/src/core/setproperties.c
@@ -50,7 +50,7 @@ gboolean ipc3270_set_property(GObject *object, const gchar *property_name, GVari @@ -50,7 +50,7 @@ gboolean ipc3270_set_property(GObject *object, const gchar *property_name, GVari
50 return FALSE; 50 return FALSE;
51 } 51 }
52 52
53 - lib3270_trace_event(hSession,"SetProperty(%s) called on session %c\n",property_name,lib3270_get_session_id(hSession)); 53 + lib3270_write_event_trace(hSession,"SetProperty(%s) called on session %c\n",property_name,lib3270_get_session_id(hSession));
54 54
55 // Boolean properties 55 // Boolean properties
56 const LIB3270_INT_PROPERTY * boolprop = lib3270_get_boolean_properties_list(); 56 const LIB3270_INT_PROPERTY * boolprop = lib3270_get_boolean_properties_list();
server/src/include/ipc-glib.h
@@ -46,8 +46,9 @@ @@ -46,8 +46,9 @@
46 #else 46 #else
47 47
48 #define PW3270_IPC_SESSION_BUS_NAME "br.com.bb.%s.%c" 48 #define PW3270_IPC_SESSION_BUS_NAME "br.com.bb.%s.%c"
  49 + #define PW3270_IPC_SESSION_BUS_PATH "/br/com/bb/%s/%c"
  50 +
49 #define PW3270_IPC_SESSION_INTERFACE_NAME "br.com.bb.tn3270.session" 51 #define PW3270_IPC_SESSION_INTERFACE_NAME "br.com.bb.tn3270.session"
50 - #define PW3270_IPC_SESSION_OBJECT_PATH "/br/com/bb/tn3270/session"  
51 52
52 #define PW3270_IPC_SERVICE_BUS_NAME "br.com.bb.tn3270.service" 53 #define PW3270_IPC_SERVICE_BUS_NAME "br.com.bb.tn3270.service"
53 #define PW3270_IPC_SERVICE_INTERFACE_NAME "br.com.bb.tn3270.service" 54 #define PW3270_IPC_SERVICE_INTERFACE_NAME "br.com.bb.tn3270.service"
server/src/plugin/plugin.c
@@ -98,7 +98,7 @@ @@ -98,7 +98,7 @@
98 98
99 char id = lib3270_get_session_id(v3270_get_session(terminal)); 99 char id = lib3270_get_session_id(v3270_get_session(terminal));
100 if(id) { 100 if(id) {
101 - g_autofree gchar * widget_name = g_strdup_printf("%s:%c",v3270_get_session_name(terminal),id); 101 + g_autofree gchar * widget_name = g_strdup_printf("%s:%c",session_name,id);
102 v3270_set_session_name(terminal, widget_name); 102 v3270_set_session_name(terminal, widget_name);
103 } 103 }
104 104