From bd2b2c9a17149a15d2a35a206e10eb3434331f4a Mon Sep 17 00:00:00 2001 From: Perry Werneck Date: Mon, 3 Aug 2020 11:37:52 -0300 Subject: [PATCH] Working on windows performance issues. --- client/src/host/properties.cc | 6 ++++++ client/src/include/lib3270/ipc.h | 5 ++--- client/src/session/local/attribute.cc | 5 +++++ client/src/session/local/private.h | 1 + client/src/session/remote/private.h | 1 + client/src/session/remote/properties.cc | 13 +++++++++++++ client/src/testprogram/testprogram.cc | 25 +++++++++++++------------ server/src/core/linux/gobject.c | 13 +++++++++++++ server/src/core/linux/gobject.h | 1 + server/src/core/methods/methods.c | 7 +++---- server/src/core/methods/private.h | 1 + server/src/core/setproperties.c | 16 ++++++++++++++++ server/src/core/windows/gobject.c | 7 +++++++ server/src/core/windows/gobject.h | 1 + server/src/include/ipc-glib.h | 3 +++ 15 files changed, 86 insertions(+), 19 deletions(-) diff --git a/client/src/host/properties.cc b/client/src/host/properties.cc index 5c1a8cb..2526566 100644 --- a/client/src/host/properties.cc +++ b/client/src/host/properties.cc @@ -58,4 +58,10 @@ std::vector TN3270::Host::getAttributes() const { } +void TN3270::Host::setTimeout(time_t timeout) noexcept { + this->timeout = timeout; + this->session->setWaitMode(timeout != 0); +} + + diff --git a/client/src/include/lib3270/ipc.h b/client/src/include/lib3270/ipc.h index 3290f0b..0c16a22 100644 --- a/client/src/include/lib3270/ipc.h +++ b/client/src/include/lib3270/ipc.h @@ -569,6 +569,7 @@ virtual void setHostURL(const char *url) = 0; virtual void setUnlockDelay(unsigned short delay = 350) = 0; + virtual void setWaitMode(bool mode) = 0; virtual void setLockOnOperatorError(bool lock = true) = 0; virtual unsigned short getScreenWidth() const = 0; @@ -835,9 +836,7 @@ } // Set properties - inline void setTimeout(time_t timeout = DEFAULT_TIMEOUT) noexcept { - this->timeout = timeout; - } + void setTimeout(time_t timeout = DEFAULT_TIMEOUT) noexcept; inline void setUnlockDelay(unsigned short delay = 350) { session->setUnlockDelay(delay); diff --git a/client/src/session/local/attribute.cc b/client/src/session/local/attribute.cc index c909c2a..e4bf5b6 100644 --- a/client/src/session/local/attribute.cc +++ b/client/src/session/local/attribute.cc @@ -484,6 +484,11 @@ chkResponse(lib3270_set_unlock_delay(hSession,delay)); } + void Local::Session::setWaitMode(bool mode) { + std::lock_guard lock(sync); + chkResponse(ENOTSUP); + } + void Local::Session::setLockOnOperatorError(bool lock) { std::lock_guard guard(sync); chkResponse(lib3270_set_lock_on_operator_error(hSession,lock ? 1 : 0)); diff --git a/client/src/session/local/private.h b/client/src/session/local/private.h index ae717be..41df8b3 100644 --- a/client/src/session/local/private.h +++ b/client/src/session/local/private.h @@ -152,6 +152,7 @@ unsigned short getScreenHeight() const override; unsigned short getScreenLength() const override; void setUnlockDelay(unsigned short delay) override; + void setWaitMode(bool mode) override; void setLockOnOperatorError(bool lock) override; void setCharSet(const char *charset = NULL) override; unsigned short setCursor(int addr) override; diff --git a/client/src/session/remote/private.h b/client/src/session/remote/private.h index e0a315f..97bc1d5 100644 --- a/client/src/session/remote/private.h +++ b/client/src/session/remote/private.h @@ -160,6 +160,7 @@ unsigned short getScreenHeight() const override; unsigned short getScreenLength() const override; void setUnlockDelay(unsigned short delay) override; + void setWaitMode(bool mode) override; void setLockOnOperatorError(bool lock) override; void setCharSet(const char *charset = NULL) override; unsigned short setCursor(int addr) override; diff --git a/client/src/session/remote/properties.cc b/client/src/session/remote/properties.cc index 9935a26..1762132 100644 --- a/client/src/session/remote/properties.cc +++ b/client/src/session/remote/properties.cc @@ -160,6 +160,19 @@ } + void IPC::Session::setWaitMode(bool mode) { + + int32_t rc; + + Request(*this,"setWaitMode") + .push(mode) + .call() + .pop(rc); + + chkResponse(rc); + + } + unsigned short IPC::Session::setCursor(unsigned short row, unsigned short col) { int32_t rc; diff --git a/client/src/testprogram/testprogram.cc b/client/src/testprogram/testprogram.cc index bf22390..5569ae1 100644 --- a/client/src/testprogram/testprogram.cc +++ b/client/src/testprogram/testprogram.cc @@ -38,13 +38,14 @@ #include -#ifndef _WIN32 #include - #pragma GCC diagnostic ignored "-Wunused-function" -#endif // _WIN32 #if defined(_MSC_VER) #pragma comment(lib,"ipc3270.lib") +#else + #pragma GCC diagnostic ignored "-Wunused-function" + #pragma GCC diagnostic ignored "-Wunused-parameter" + #pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant" #endif // _MSC_VER #include @@ -170,11 +171,12 @@ TN3270::Host host{session}; - // host.connect(); + host.setTimeout(10); + + host.connect(); + host.push(TN3270::ENTER); - cout << endl << "------------------------" << endl; host.toString(14,1,75,0); - cout << endl << "------------------------" << endl; // host.disconnect(); @@ -186,7 +188,6 @@ << std::endl; host.setUnlockDelay(0); - host.setTimeout(10); host.connect(nullptr); cout @@ -237,15 +238,12 @@ const char * session = ":A"; -#ifndef _WIN32 - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant" static struct option options[] = { { "session", required_argument, 0, 's' }, + { "perftest", no_argument, 0, 'P' }, { 0, 0, 0, 0} }; - #pragma GCC diagnostic pop int long_index =0; int opt; @@ -256,10 +254,13 @@ session = optarg; break; + case 'P': + testPerformance(session); + return 0; + } } -#endif // _WIN32 cout << "Session: " << session << endl; diff --git a/server/src/core/linux/gobject.c b/server/src/core/linux/gobject.c index 041d4da..510b497 100644 --- a/server/src/core/linux/gobject.c +++ b/server/src/core/linux/gobject.c @@ -120,6 +120,10 @@ void ipc3270_add_terminal_introspection(GString *introspection) { " " \ " " \ " " + " " + " " \ + " " \ + " " " " \ " " \ " " \ @@ -313,3 +317,12 @@ gchar * ipc3270_convert_to_3270(GObject *object, const gchar *string, GError **e gchar * ipc3270_convert_from_3270(GObject *object, const gchar *string, GError **error) { return g_convert_with_fallback(string,-1,IPC3270(object)->charset,lib3270_get_display_charset(IPC3270(object)->hSession),"?",NULL,NULL,error); } + +int ipc3270_set_wait(GObject *object, gboolean wait) { + IPC3270(object)->wait = wait; + return 0; +} + +gboolean ipc3270_get_wait(GObject *object) { + return IPC3270(object)->wait; +} diff --git a/server/src/core/linux/gobject.h b/server/src/core/linux/gobject.h index 01b0a80..c099c34 100644 --- a/server/src/core/linux/gobject.h +++ b/server/src/core/linux/gobject.h @@ -62,6 +62,7 @@ H3270 * hSession; gchar * charset; GtkWidget * terminal; + gboolean wait; ///< @brief If true enable automatic call of "wait for ready". GQuark error_domain; }; diff --git a/server/src/core/methods/methods.c b/server/src/core/methods/methods.c index 5427363..ba23f1f 100644 --- a/server/src/core/methods/methods.c +++ b/server/src/core/methods/methods.c @@ -74,6 +74,7 @@ int ipc3270_method_call(GObject *object, const gchar *method_name, GVariant *req { "action", ipc3270_method_action }, { "activatable", ipc3270_method_activatable }, + { "setwaitmode", ipc3270_method_set_wait_mode }, }; @@ -88,16 +89,14 @@ int ipc3270_method_call(GObject *object, const gchar *method_name, GVariant *req if(!g_ascii_strcasecmp(methods[ix].name,method_name)) { -#ifdef _DEBUG_ - lib3270_write_log(hSession,"IPC","Calling %s",methods[ix].name); -#endif // _DEBUG_ - + g_message("Running method %s",method_name); int rc = methods[ix].call(object,request,response,error); debug("rc=%d error=%p",rc,*error); if(rc) { + g_message("Method %s failed with rc=%d (%s)",method_name,rc,ipc3270_get_error_message(rc)); debug("%s exits with rc=%d (%s)",methods[ix].name,rc,ipc3270_get_error_message(rc)); lib3270_write_log(hSession,"IPC","%s exits with rc=%d (%s)",methods[ix].name,rc,ipc3270_get_error_message(rc)); ipc3270_set_error(object,rc,error); diff --git a/server/src/core/methods/private.h b/server/src/core/methods/private.h index bebe34d..f7c4fb9 100644 --- a/server/src/core/methods/private.h +++ b/server/src/core/methods/private.h @@ -60,6 +60,7 @@ G_GNUC_INTERNAL int ipc3270_method_action(GObject *session, GVariant *request, GObject *response, GError **error); G_GNUC_INTERNAL int ipc3270_method_activatable(GObject *session, GVariant *request, GObject *response, GError **error); + G_GNUC_INTERNAL int ipc3270_method_set_wait_mode(GObject *session, GVariant *request, GObject *response, GError **error); G_GNUC_INTERNAL int ipc3270_method_get_field_attribute(GObject *session, GVariant *request, GObject *response, GError **error); diff --git a/server/src/core/setproperties.c b/server/src/core/setproperties.c index 5685a71..27b7db8 100644 --- a/server/src/core/setproperties.c +++ b/server/src/core/setproperties.c @@ -185,3 +185,19 @@ gboolean ipc3270_set_property(GObject *object, const gchar *property_name, GVari return FALSE; } + +int ipc3270_method_set_wait_mode(GObject *session, GVariant *request, GObject *response, GError G_GNUC_UNUSED(**error)) { + + if(g_variant_n_children(request) != 1) { + g_message("set wait was called with %u arguments.",(unsigned int) g_variant_n_children(request)); + ipc3270_response_append_int32(response, EINVAL); + } + + GVariant *value = g_variant_get_child_value(request,0); + + ipc3270_response_append_int32(response, ipc3270_set_wait(session,g_variant_get_boolean(value))); + + g_variant_unref(value); + + return 0; +} diff --git a/server/src/core/windows/gobject.c b/server/src/core/windows/gobject.c index e2fc4ac..1239431 100644 --- a/server/src/core/windows/gobject.c +++ b/server/src/core/windows/gobject.c @@ -124,4 +124,11 @@ gchar * ipc3270_convert_from_3270(GObject *object, const gchar *string, GError * return g_convert_with_fallback(string,-1,IPC3270(object)->charset,lib3270_get_display_charset(IPC3270(object)->hSession),"?",NULL,NULL,error); } +int ipc3270_set_wait(GObject *object, gboolean wait) { + IPC3270(object)->wait = wait; + return 0; +} +gboolean ipc3270_get_wait(GObject *object) { + return IPC3270(object)->wait; +} diff --git a/server/src/core/windows/gobject.h b/server/src/core/windows/gobject.h index dfc559a..a681c57 100644 --- a/server/src/core/windows/gobject.h +++ b/server/src/core/windows/gobject.h @@ -82,6 +82,7 @@ H3270 * hSession; GtkWidget * terminal; gchar * charset; + gboolean wait; ///< @brief If true enable automatic call of "wait for ready". IPC3270_PIPE_SOURCE * source; GQuark error_domain; }; diff --git a/server/src/include/ipc-glib.h b/server/src/include/ipc-glib.h index 95ef7b7..9c52225 100644 --- a/server/src/include/ipc-glib.h +++ b/server/src/include/ipc-glib.h @@ -131,6 +131,9 @@ void ipc3270_set_terminal_widget(GObject *object, GtkWidget *widget); void ipc3270_export_object(GObject *object, const char *name, GError **error); + int ipc3270_set_wait(GObject *object, gboolean wait); + gboolean ipc3270_get_wait(GObject *object); + void ipc3270_add_terminal_introspection(GString *string); const gchar * ipc3270_get_display_charset(GObject *object); -- libgit2 0.21.2