Commit 0668e0fac6edd49e03e6371756acc3c7a2e02274
1 parent
17909801
Exists in
master
and in
1 other branch
Fixing issues on non GUI (local) sessions.
Showing
15 changed files
with
136 additions
and
88 deletions
Show diff stats
client/src/core/constants.cc
client/src/host/init.cc
... | ... | @@ -42,15 +42,23 @@ |
42 | 42 | |
43 | 43 | TN3270::Host::Host(const char *id, const char *charset) { |
44 | 44 | |
45 | - debug("Creating host id=\"", id); | |
45 | + if(!id) | |
46 | + id = ""; | |
47 | + | |
48 | + debug("Creating host id=\"", id, "\""); | |
46 | 49 | |
47 | 50 | this->timeout = 5; |
48 | 51 | this->session = Session::getInstance(id, charset); |
49 | 52 | |
53 | + debug("Create host with session ",this->session); | |
54 | + | |
50 | 55 | } |
51 | 56 | |
52 | 57 | |
53 | 58 | TN3270::Host::~Host() { |
54 | - delete this->session; | |
55 | - this->session = nullptr; | |
59 | + debug("Deleting host session ",this->session); | |
60 | + if(this->session) { | |
61 | + delete this->session; | |
62 | + this->session = nullptr; | |
63 | + } | |
56 | 64 | } | ... | ... |
client/src/host/properties.cc
... | ... | @@ -60,7 +60,7 @@ std::vector<TN3270::Attribute> TN3270::Host::getAttributes() const { |
60 | 60 | |
61 | 61 | void TN3270::Host::setTimeout(time_t timeout) noexcept { |
62 | 62 | this->timeout = timeout; |
63 | - this->session->setWaitMode(timeout != 0); | |
63 | + this->session->setTimeout(timeout); | |
64 | 64 | } |
65 | 65 | |
66 | 66 | ... | ... |
client/src/include/lib3270/ipc.h
... | ... | @@ -569,7 +569,7 @@ |
569 | 569 | virtual void setHostURL(const char *url) = 0; |
570 | 570 | |
571 | 571 | virtual void setUnlockDelay(unsigned short delay = 350) = 0; |
572 | - virtual void setWaitMode(bool mode) = 0; | |
572 | + virtual void setTimeout(time_t timeout = 0) = 0; | |
573 | 573 | virtual void setLockOnOperatorError(bool lock = true) = 0; |
574 | 574 | |
575 | 575 | virtual unsigned short getScreenWidth() const = 0; |
... | ... | @@ -668,6 +668,9 @@ |
668 | 668 | int overflow(int c) override; |
669 | 669 | |
670 | 670 | public: |
671 | + Host(const Host &src) = delete; | |
672 | + Host(const Host *src) = delete; | |
673 | + | |
671 | 674 | Host(const char *id, const char *charset = nullptr); |
672 | 675 | |
673 | 676 | ~Host(); | ... | ... |
client/src/session/local/actions.cc
... | ... | @@ -50,56 +50,63 @@ |
50 | 50 | } |
51 | 51 | |
52 | 52 | bool Local::Action::activatable() const noexcept { |
53 | - std::lock_guard<std::mutex> lock(this->session->sync); | |
53 | + std::lock_guard<std::recursive_mutex> lock(this->session->sync); | |
54 | 54 | debug(__FUNCTION__,"(",(void *) descriptor,")"); |
55 | 55 | return lib3270_action_is_activatable(this->descriptor,this->session->hSession); |
56 | 56 | } |
57 | 57 | |
58 | 58 | void Local::Action::activate() { |
59 | - std::lock_guard<std::mutex> lock(this->session->sync); | |
59 | + std::lock_guard<std::recursive_mutex> lock(this->session->sync); | |
60 | 60 | |
61 | 61 | chkResponse(lib3270_action_activate(this->descriptor,this->session->hSession)); |
62 | 62 | |
63 | 63 | } |
64 | 64 | |
65 | 65 | void Local::Action::wait(time_t seconds) { |
66 | - std::lock_guard<std::mutex> lock(this->session->sync); | |
66 | + std::lock_guard<std::recursive_mutex> lock(this->session->sync); | |
67 | 67 | chkResponse(lib3270_wait_for_ready(this->session->hSession,seconds)); |
68 | 68 | } |
69 | 69 | |
70 | 70 | TN3270::Action * Local::Session::getAction(const LIB3270_ACTION *descriptor) { |
71 | - std::lock_guard<std::mutex> lock(sync); | |
71 | + std::lock_guard<std::recursive_mutex> lock(sync); | |
72 | 72 | return new Local::Action(this, descriptor); |
73 | 73 | } |
74 | 74 | |
75 | 75 | void Local::Session::action(const char *action_name) { |
76 | - std::lock_guard<std::mutex> lock(sync); | |
76 | + std::lock_guard<std::recursive_mutex> lock(sync); | |
77 | 77 | chkResponse(lib3270_action_activate_by_name(action_name,hSession)); |
78 | + if(this->timeout) | |
79 | + chkResponse(lib3270_wait_for_ready(hSession,this->timeout)); | |
78 | 80 | } |
79 | 81 | |
80 | 82 | void Local::Session::connect(const char *url, time_t seconds) { |
81 | 83 | |
82 | - std::lock_guard<std::mutex> lock(sync); | |
83 | - chkResponse(lib3270_connect_url(hSession,url,seconds)); | |
84 | + std::lock_guard<std::recursive_mutex> lock(sync); | |
85 | + chkResponse(lib3270_connect_url(hSession,url,seconds ? seconds : this->timeout)); | |
86 | + | |
84 | 87 | } |
85 | 88 | |
86 | 89 | void Local::Session::disconnect() { |
87 | 90 | |
88 | - std::lock_guard<std::mutex> lock(sync); | |
91 | + std::lock_guard<std::recursive_mutex> lock(sync); | |
89 | 92 | chkResponse(lib3270_disconnect(hSession)); |
90 | 93 | } |
91 | 94 | |
92 | 95 | void Local::Session::pfkey(unsigned short value) { |
93 | 96 | |
94 | - std::lock_guard<std::mutex> lock(sync); | |
97 | + std::lock_guard<std::recursive_mutex> lock(sync); | |
95 | 98 | chkResponse(lib3270_pfkey(hSession,value)); |
99 | + if(this->timeout) | |
100 | + chkResponse(lib3270_wait_for_ready(hSession,this->timeout)); | |
96 | 101 | |
97 | 102 | } |
98 | 103 | |
99 | 104 | void Local::Session::pakey(unsigned short value) { |
100 | 105 | |
101 | - std::lock_guard<std::mutex> lock(sync); | |
106 | + std::lock_guard<std::recursive_mutex> lock(sync); | |
102 | 107 | chkResponse(lib3270_pakey(hSession,value)); |
108 | + if(this->timeout) | |
109 | + chkResponse(lib3270_wait_for_ready(hSession,this->timeout)); | |
103 | 110 | |
104 | 111 | } |
105 | 112 | |
... | ... | @@ -142,14 +149,16 @@ |
142 | 149 | throw std::system_error(EINVAL, std::system_category()); |
143 | 150 | } |
144 | 151 | |
145 | - std::lock_guard<std::mutex> lock(sync); | |
152 | + std::lock_guard<std::recursive_mutex> lock(sync); | |
146 | 153 | chkResponse(actions[(size_t) action](hSession)); |
154 | + if(this->timeout) | |
155 | + chkResponse(lib3270_wait_for_ready(hSession,this->timeout)); | |
147 | 156 | |
148 | 157 | } |
149 | 158 | |
150 | 159 | void Local::Session::print(LIB3270_CONTENT_OPTION option) { |
151 | 160 | |
152 | - std::lock_guard<std::mutex> lock(sync); | |
161 | + std::lock_guard<std::recursive_mutex> lock(sync); | |
153 | 162 | |
154 | 163 | switch(option) { |
155 | 164 | case LIB3270_CONTENT_ALL: | ... | ... |
client/src/session/local/attribute.cc
... | ... | @@ -345,7 +345,7 @@ |
345 | 345 | |
346 | 346 | Attribute Local::Session::getAttribute(const char *name) const { |
347 | 347 | |
348 | - std::lock_guard<std::mutex> lock(const_cast<Local::Session *>(this)->sync); | |
348 | + std::lock_guard<std::recursive_mutex> lock(const_cast<Local::Session *>(this)->sync); | |
349 | 349 | |
350 | 350 | // Check for integer properties. |
351 | 351 | { |
... | ... | @@ -415,7 +415,7 @@ |
415 | 415 | |
416 | 416 | void Local::Session::getAttributes(std::vector<Attribute> & attributes) const { |
417 | 417 | |
418 | - std::lock_guard<std::mutex> lock(const_cast<Local::Session *>(this)->sync); | |
418 | + std::lock_guard<std::recursive_mutex> lock(const_cast<Local::Session *>(this)->sync); | |
419 | 419 | |
420 | 420 | // Add integer properties. |
421 | 421 | { |
... | ... | @@ -465,37 +465,37 @@ |
465 | 465 | } |
466 | 466 | |
467 | 467 | unsigned short Local::Session::getScreenWidth() const { |
468 | - std::lock_guard<std::mutex> lock(const_cast<Local::Session *>(this)->sync); | |
468 | + std::lock_guard<std::recursive_mutex> lock(const_cast<Local::Session *>(this)->sync); | |
469 | 469 | return (unsigned short) lib3270_get_width(hSession); |
470 | 470 | } |
471 | 471 | |
472 | 472 | unsigned short Local::Session::getScreenHeight() const { |
473 | - std::lock_guard<std::mutex> lock(const_cast<Local::Session *>(this)->sync); | |
473 | + std::lock_guard<std::recursive_mutex> lock(const_cast<Local::Session *>(this)->sync); | |
474 | 474 | return (unsigned short) lib3270_get_height(hSession); |
475 | 475 | } |
476 | 476 | |
477 | 477 | unsigned short Local::Session::getScreenLength() const { |
478 | - std::lock_guard<std::mutex> lock(const_cast<Local::Session *>(this)->sync); | |
478 | + std::lock_guard<std::recursive_mutex> lock(const_cast<Local::Session *>(this)->sync); | |
479 | 479 | return (unsigned short) lib3270_get_length(hSession); |
480 | 480 | } |
481 | 481 | |
482 | 482 | void Local::Session::setUnlockDelay(unsigned short delay) { |
483 | - std::lock_guard<std::mutex> lock(sync); | |
483 | + std::lock_guard<std::recursive_mutex> lock(sync); | |
484 | 484 | chkResponse(lib3270_set_unlock_delay(hSession,delay)); |
485 | 485 | } |
486 | 486 | |
487 | - void Local::Session::setWaitMode(bool mode) { | |
488 | - std::lock_guard<std::mutex> lock(sync); | |
489 | - chkResponse(ENOTSUP); | |
487 | + void Local::Session::setTimeout(time_t timeout) { | |
488 | + std::lock_guard<std::recursive_mutex> lock(sync); | |
489 | + this->timeout = timeout; | |
490 | 490 | } |
491 | 491 | |
492 | 492 | void Local::Session::setLockOnOperatorError(bool lock) { |
493 | - std::lock_guard<std::mutex> guard(sync); | |
493 | + std::lock_guard<std::recursive_mutex> guard(sync); | |
494 | 494 | chkResponse(lib3270_set_lock_on_operator_error(hSession,lock ? 1 : 0)); |
495 | 495 | } |
496 | 496 | |
497 | 497 | unsigned short Local::Session::setCursor(int addr) { |
498 | - std::lock_guard<std::mutex> lock(sync); | |
498 | + std::lock_guard<std::recursive_mutex> lock(sync); | |
499 | 499 | |
500 | 500 | int rc = lib3270_set_cursor_address(hSession,addr); |
501 | 501 | if(rc < 0) |
... | ... | @@ -506,7 +506,7 @@ |
506 | 506 | } |
507 | 507 | |
508 | 508 | unsigned short Local::Session::setCursor(unsigned short row, unsigned short col) { |
509 | - std::lock_guard<std::mutex> lock(sync); | |
509 | + std::lock_guard<std::recursive_mutex> lock(sync); | |
510 | 510 | |
511 | 511 | int rc = lib3270_set_cursor_position(hSession,row,col); |
512 | 512 | if(rc < 0) |
... | ... | @@ -517,7 +517,7 @@ |
517 | 517 | } |
518 | 518 | |
519 | 519 | unsigned short Local::Session::getCursorAddress() { |
520 | - std::lock_guard<std::mutex> lock(sync); | |
520 | + std::lock_guard<std::recursive_mutex> lock(sync); | |
521 | 521 | |
522 | 522 | int rc = lib3270_get_cursor_address(hSession); |
523 | 523 | |
... | ... | @@ -529,35 +529,36 @@ |
529 | 529 | |
530 | 530 | std::string Local::Session::getVersion() const { |
531 | 531 | |
532 | - std::lock_guard<std::mutex> lock(const_cast<Local::Session *>(this)->sync); | |
532 | + std::lock_guard<std::recursive_mutex> lock(const_cast<Local::Session *>(this)->sync); | |
533 | 533 | return lib3270_get_version(); |
534 | 534 | |
535 | 535 | } |
536 | 536 | |
537 | 537 | std::string Local::Session::getRevision() const { |
538 | 538 | |
539 | - std::lock_guard<std::mutex> lock(const_cast<Local::Session *>(this)->sync); | |
539 | + std::lock_guard<std::recursive_mutex> lock(const_cast<Local::Session *>(this)->sync); | |
540 | 540 | return lib3270_get_revision(); |
541 | 541 | |
542 | 542 | } |
543 | 543 | |
544 | 544 | std::string Local::Session::getAssociatedLUName() const { |
545 | 545 | |
546 | - std::lock_guard<std::mutex> lock(const_cast<Local::Session *>(this)->sync); | |
547 | - return lib3270_get_associated_luname(hSession); | |
546 | + std::lock_guard<std::recursive_mutex> lock(const_cast<Local::Session *>(this)->sync); | |
547 | + const char * luname = lib3270_get_associated_luname(hSession); | |
548 | + return string(luname ? luname : ""); | |
548 | 549 | |
549 | 550 | } |
550 | 551 | |
551 | 552 | std::string Local::Session::getHostURL() const { |
552 | 553 | |
553 | - std::lock_guard<std::mutex> lock(const_cast<Local::Session *>(this)->sync); | |
554 | + std::lock_guard<std::recursive_mutex> lock(const_cast<Local::Session *>(this)->sync); | |
554 | 555 | return lib3270_get_url(hSession); |
555 | 556 | |
556 | 557 | } |
557 | 558 | |
558 | 559 | void Local::Session::setHostURL(const char *url) { |
559 | 560 | |
560 | - std::lock_guard<std::mutex> lock(sync); | |
561 | + std::lock_guard<std::recursive_mutex> lock(sync); | |
561 | 562 | chkResponse(lib3270_set_url(hSession, url)); |
562 | 563 | |
563 | 564 | } | ... | ... |
client/src/session/local/get.cc
... | ... | @@ -44,7 +44,7 @@ |
44 | 44 | |
45 | 45 | std::string Local::Session::get() const { |
46 | 46 | |
47 | - std::lock_guard<std::mutex> lock(const_cast<Local::Session *>(this)->sync); | |
47 | + std::lock_guard<std::recursive_mutex> lock(const_cast<Local::Session *>(this)->sync); | |
48 | 48 | |
49 | 49 | lib3270_auto_cleanup<char> text = lib3270_get_string_at_address(hSession, 0, -1, '\n'); |
50 | 50 | |
... | ... | @@ -57,7 +57,7 @@ |
57 | 57 | |
58 | 58 | std::string Local::Session::get(int baddr, int len, char lf) const { |
59 | 59 | |
60 | - std::lock_guard<std::mutex> lock(const_cast<Local::Session *>(this)->sync); | |
60 | + std::lock_guard<std::recursive_mutex> lock(const_cast<Local::Session *>(this)->sync); | |
61 | 61 | |
62 | 62 | lib3270_auto_cleanup<char> text = lib3270_get_string_at_address(hSession, baddr, len, lf); |
63 | 63 | |
... | ... | @@ -70,7 +70,7 @@ |
70 | 70 | |
71 | 71 | std::string Local::Session::get(unsigned int row, unsigned int col, int len, char lf) const { |
72 | 72 | |
73 | - std::lock_guard<std::mutex> lock(const_cast<Local::Session *>(this)->sync); | |
73 | + std::lock_guard<std::recursive_mutex> lock(const_cast<Local::Session *>(this)->sync); | |
74 | 74 | |
75 | 75 | lib3270_auto_cleanup<char> text = lib3270_get_string_at(hSession, row, col, len, lf); |
76 | 76 | |
... | ... | @@ -84,27 +84,28 @@ |
84 | 84 | |
85 | 85 | ProgramMessage Local::Session::getProgramMessage() const { |
86 | 86 | |
87 | - std::lock_guard<std::mutex> lock(const_cast<Local::Session *>(this)->sync); | |
87 | + std::lock_guard<std::recursive_mutex> lock(const_cast<Local::Session *>(this)->sync); | |
88 | 88 | return (ProgramMessage) lib3270_get_program_message(this->hSession); |
89 | 89 | |
90 | 90 | } |
91 | 91 | |
92 | 92 | ConnectionState Local::Session::getConnectionState() const { |
93 | 93 | |
94 | - std::lock_guard<std::mutex> lock(const_cast<Local::Session *>(this)->sync); | |
94 | + std::lock_guard<std::recursive_mutex> lock(const_cast<Local::Session *>(this)->sync); | |
95 | 95 | return (ConnectionState) lib3270_get_connection_state(this->hSession); |
96 | 96 | |
97 | 97 | } |
98 | 98 | |
99 | 99 | SSLState Local::Session::getSSLState() const { |
100 | 100 | |
101 | - std::lock_guard<std::mutex> lock(const_cast<Local::Session *>(this)->sync); | |
101 | + std::lock_guard<std::recursive_mutex> lock(const_cast<Local::Session *>(this)->sync); | |
102 | 102 | return (TN3270::SSLState) lib3270_get_ssl_state(hSession); |
103 | 103 | |
104 | 104 | } |
105 | 105 | |
106 | 106 | LIB3270_KEYBOARD_LOCK_STATE Local::Session::getKeyboardLockState() const { |
107 | - std::lock_guard<std::mutex> lock(const_cast<Local::Session *>(this)->sync); | |
107 | + | |
108 | + std::lock_guard<std::recursive_mutex> lock(const_cast<Local::Session *>(this)->sync); | |
108 | 109 | return lib3270_get_keyboard_lock_state(hSession); |
109 | 110 | } |
110 | 111 | ... | ... |
client/src/session/local/init.cc
... | ... | @@ -61,9 +61,10 @@ |
61 | 61 | |
62 | 62 | Local::Session::Session(const char *charset) : Abstract::Session() { |
63 | 63 | |
64 | - std::lock_guard<std::mutex> lock(sync); | |
64 | + std::lock_guard<std::recursive_mutex> lock(sync); | |
65 | 65 | |
66 | 66 | this->hSession = lib3270_session_new(""); |
67 | + this->timeout = 5; | |
67 | 68 | |
68 | 69 | lib3270_set_user_data(this->hSession,(void *) this); |
69 | 70 | |
... | ... | @@ -99,7 +100,7 @@ |
99 | 100 | |
100 | 101 | Local::Session::~Session() { |
101 | 102 | |
102 | - std::lock_guard<std::mutex> lock(sync); | |
103 | + std::lock_guard<std::recursive_mutex> lock(sync); | |
103 | 104 | |
104 | 105 | lib3270_session_free(this->hSession); |
105 | 106 | this->hSession = nullptr; | ... | ... |
client/src/session/local/private.h
... | ... | @@ -77,11 +77,14 @@ |
77 | 77 | |
78 | 78 | friend class Action; |
79 | 79 | |
80 | + /// @brief Timeout for automatic waits. | |
81 | + time_t timeout; | |
82 | + | |
80 | 83 | /// @brief Handle of the related instance of lib3270 |
81 | 84 | H3270 * hSession; |
82 | 85 | |
83 | - /// @brief Mutex to serialize access to lib3270 | |
84 | - std::mutex sync; | |
86 | + /// @brief Recursive mutex to serialize access to lib3270 | |
87 | + std::recursive_mutex sync; | |
85 | 88 | |
86 | 89 | /// @brief Popup Handler. |
87 | 90 | static int popupHandler(H3270 *session, const LIB3270_POPUP *popup, unsigned char wait); |
... | ... | @@ -152,7 +155,7 @@ |
152 | 155 | unsigned short getScreenHeight() const override; |
153 | 156 | unsigned short getScreenLength() const override; |
154 | 157 | void setUnlockDelay(unsigned short delay) override; |
155 | - void setWaitMode(bool mode) override; | |
158 | + void setTimeout(time_t timeout) override; | |
156 | 159 | void setLockOnOperatorError(bool lock) override; |
157 | 160 | void setCharSet(const char *charset = NULL) override; |
158 | 161 | unsigned short setCursor(int addr) override; | ... | ... |
client/src/session/local/set.cc
... | ... | @@ -44,7 +44,7 @@ |
44 | 44 | |
45 | 45 | void Local::Session::set(const std::string &str) { |
46 | 46 | |
47 | - std::lock_guard<std::mutex> lock(this->sync); | |
47 | + std::lock_guard<std::recursive_mutex> lock(this->sync); | |
48 | 48 | |
49 | 49 | int rc = lib3270_set_field(hSession,str.c_str(),str.length()); |
50 | 50 | if(rc < 0) |
... | ... | @@ -54,7 +54,7 @@ |
54 | 54 | |
55 | 55 | void Local::Session::set(int baddr, const std::string &str) { |
56 | 56 | |
57 | - std::lock_guard<std::mutex> lock(this->sync); | |
57 | + std::lock_guard<std::recursive_mutex> lock(this->sync); | |
58 | 58 | |
59 | 59 | int rc = lib3270_set_string_at_address(hSession,baddr,(unsigned char *) str.c_str(),str.length()); |
60 | 60 | if(rc < 0) |
... | ... | @@ -64,7 +64,7 @@ |
64 | 64 | |
65 | 65 | void Local::Session::set(int row, int col, const std::string &str) { |
66 | 66 | |
67 | - std::lock_guard<std::mutex> lock(this->sync); | |
67 | + std::lock_guard<std::recursive_mutex> lock(this->sync); | |
68 | 68 | |
69 | 69 | int rc = lib3270_set_string_at(hSession,row,col,(unsigned char *) str.c_str(),str.length()); |
70 | 70 | if(rc < 0) | ... | ... |
client/src/session/local/wait.cc
... | ... | @@ -45,53 +45,53 @@ |
45 | 45 | |
46 | 46 | void Local::Session::wait(time_t seconds) const { |
47 | 47 | |
48 | - std::lock_guard<std::mutex> lock(const_cast<Local::Session *>(this)->sync); | |
48 | + std::lock_guard<std::recursive_mutex> lock(const_cast<Local::Session *>(this)->sync); | |
49 | 49 | chkResponse(lib3270_wait(this->hSession, seconds)); |
50 | 50 | |
51 | 51 | } |
52 | 52 | |
53 | 53 | void Local::Session::waitForReady(time_t timeout) const { |
54 | 54 | |
55 | - std::lock_guard<std::mutex> lock(const_cast<Local::Session *>(this)->sync); | |
55 | + std::lock_guard<std::recursive_mutex> lock(const_cast<Local::Session *>(this)->sync); | |
56 | 56 | chkResponse(lib3270_wait_for_ready(this->hSession, timeout)); |
57 | 57 | } |
58 | 58 | |
59 | 59 | void Local::Session::waitForConnectionState(ConnectionState state, time_t timeout) const { |
60 | 60 | |
61 | - std::lock_guard<std::mutex> lock(const_cast<Local::Session *>(this)->sync); | |
61 | + std::lock_guard<std::recursive_mutex> lock(const_cast<Local::Session *>(this)->sync); | |
62 | 62 | chkResponse(lib3270_wait_for_cstate(this->hSession, (LIB3270_CSTATE) state, timeout)); |
63 | 63 | } |
64 | 64 | |
65 | 65 | LIB3270_KEYBOARD_LOCK_STATE Local::Session::waitForKeyboardUnlock(time_t timeout) const { |
66 | 66 | |
67 | - std::lock_guard<std::mutex> lock(const_cast<Local::Session *>(this)->sync); | |
67 | + std::lock_guard<std::recursive_mutex> lock(const_cast<Local::Session *>(this)->sync); | |
68 | 68 | return lib3270_wait_for_keyboard_unlock(this->hSession, timeout); |
69 | 69 | } |
70 | 70 | |
71 | 71 | void Local::Session::waitForChange(time_t seconds) const { |
72 | 72 | |
73 | - std::lock_guard<std::mutex> lock(const_cast<Local::Session *>(this)->sync); | |
73 | + std::lock_guard<std::recursive_mutex> lock(const_cast<Local::Session *>(this)->sync); | |
74 | 74 | chkResponse(lib3270_wait_for_update(this->hSession, seconds)); |
75 | 75 | |
76 | 76 | } |
77 | 77 | |
78 | 78 | void Local::Session::wait(const char *text, int seconds) { |
79 | 79 | |
80 | - std::lock_guard<std::mutex> lock(sync); | |
80 | + std::lock_guard<std::recursive_mutex> lock(sync); | |
81 | 81 | chkResponse(lib3270_wait_for_string(hSession,convertToHost(text,-1).c_str(),seconds)); |
82 | 82 | |
83 | 83 | } |
84 | 84 | |
85 | 85 | void Local::Session::wait(unsigned short row, unsigned short col, const char *text, int seconds) { |
86 | 86 | |
87 | - std::lock_guard<std::mutex> lock(sync); | |
87 | + std::lock_guard<std::recursive_mutex> lock(sync); | |
88 | 88 | chkResponse(lib3270_wait_for_string_at(hSession,row,col,convertToHost(text,-1).c_str(),seconds)); |
89 | 89 | |
90 | 90 | } |
91 | 91 | |
92 | 92 | void Local::Session::wait(int addr, const char *text, int seconds) { |
93 | 93 | |
94 | - std::lock_guard<std::mutex> lock(sync); | |
94 | + std::lock_guard<std::recursive_mutex> lock(sync); | |
95 | 95 | chkResponse(lib3270_wait_for_string_at_address(hSession,addr,convertToHost(text,-1).c_str(),seconds)); |
96 | 96 | |
97 | 97 | } | ... | ... |
client/src/session/remote/private.h
... | ... | @@ -160,7 +160,7 @@ |
160 | 160 | unsigned short getScreenHeight() const override; |
161 | 161 | unsigned short getScreenLength() const override; |
162 | 162 | void setUnlockDelay(unsigned short delay) override; |
163 | - void setWaitMode(bool mode) override; | |
163 | + void setTimeout(time_t timeout) override; | |
164 | 164 | void setLockOnOperatorError(bool lock) override; |
165 | 165 | void setCharSet(const char *charset = NULL) override; |
166 | 166 | unsigned short setCursor(int addr) override; | ... | ... |
client/src/session/remote/properties.cc
... | ... | @@ -160,12 +160,12 @@ |
160 | 160 | |
161 | 161 | } |
162 | 162 | |
163 | - void IPC::Session::setWaitMode(bool mode) { | |
163 | + void IPC::Session::setTimeout(time_t timeout) { | |
164 | 164 | |
165 | 165 | int32_t rc; |
166 | 166 | |
167 | 167 | Request(*this,"setWaitMode") |
168 | - .push(mode) | |
168 | + .push(timeout != 0) | |
169 | 169 | .call() |
170 | 170 | .pop(rc); |
171 | 171 | ... | ... |
client/src/session/tools.cc
client/src/testprogram/testprogram.cc
... | ... | @@ -98,7 +98,7 @@ |
98 | 98 | */ |
99 | 99 | |
100 | 100 | // Test Attributes |
101 | - static void testAttributes(const char *session) { | |
101 | + static void testAttributes(const char *session, const char *url) { | |
102 | 102 | |
103 | 103 | TN3270::Host host{session}; |
104 | 104 | |
... | ... | @@ -122,7 +122,7 @@ |
122 | 122 | } |
123 | 123 | |
124 | 124 | // Performance test. |
125 | - static void testPerformance(const char *session) { | |
125 | + static void testPerformance(const char *session, const char *url) { | |
126 | 126 | |
127 | 127 | try { |
128 | 128 | |
... | ... | @@ -165,30 +165,22 @@ |
165 | 165 | } |
166 | 166 | |
167 | 167 | // test host object |
168 | - static void testHost(const char *session) { | |
168 | + static void testHost(const char *session, const char *url) { | |
169 | 169 | |
170 | 170 | try { |
171 | 171 | |
172 | 172 | TN3270::Host host{session}; |
173 | 173 | |
174 | - host.setTimeout(10); | |
175 | - | |
176 | - host.connect(); | |
177 | - host.push(TN3270::ENTER); | |
178 | - | |
179 | - host.toString(14,1,75,0); | |
180 | - | |
181 | - // host.disconnect(); | |
182 | - | |
183 | - /* | |
184 | 174 | cout |
185 | 175 | << "Version: " << host["version"] |
186 | 176 | << "\tRevision: " << host["Revision"] |
187 | 177 | << "\tConnected: " << host["Connected"] |
188 | 178 | << std::endl; |
189 | 179 | |
190 | - host.setUnlockDelay(0); | |
191 | - host.connect(nullptr); | |
180 | + host.setUnlockDelay(0); // Disable the 350ms delay on screen changes. | |
181 | + host.setTimeout(10); // Set the default timeout. | |
182 | + host["crlget"] = false; // Disable CRL get to speed up the connection. | |
183 | + host.connect(url); | |
192 | 184 | |
193 | 185 | cout |
194 | 186 | << "Wait for unlock returns " << host.getKeyboardLockState() << std::endl |
... | ... | @@ -203,28 +195,30 @@ |
203 | 195 | } |
204 | 196 | |
205 | 197 | host.setCursor(10,10); |
206 | - | |
207 | - host.wait(10); | |
208 | - | |
198 | +// host.wait(10); | |
209 | 199 | // host.input("test@0another line"); |
210 | 200 | |
201 | + cout << "Sending ENTER" << endl; | |
211 | 202 | host.push(TN3270::ENTER); |
212 | - host.wait(10); | |
203 | + cout << "ENTER returns" << endl; | |
204 | + | |
205 | + host.wait(2); | |
213 | 206 | |
214 | 207 | cout << host << endl; |
215 | 208 | |
216 | 209 | cout << endl << "[" << host.toString((unsigned int) 1, (unsigned int) 3,7) << "]" << endl; |
217 | 210 | cout << endl << "[" << host.toString((int) 15, (int) 10) << "]" << endl; |
218 | 211 | |
212 | + cout << "Sending PF3" << endl; | |
219 | 213 | host.pfkey(3); |
220 | - host.wait(10); | |
214 | + cout << "PF3 returns" << endl; | |
221 | 215 | |
222 | 216 | cout << host << endl; |
223 | - host.wait(10); | |
224 | 217 | |
218 | + cout << "Disconnecting" << endl; | |
225 | 219 | host.disconnect(); |
226 | 220 | |
227 | - */ | |
221 | + cout << "Test complete" << endl; | |
228 | 222 | |
229 | 223 | } catch(const std::exception &e) { |
230 | 224 | |
... | ... | @@ -237,10 +231,13 @@ |
237 | 231 | int main(int argc, char **argv) { |
238 | 232 | |
239 | 233 | const char * session = ":A"; |
234 | + const char * url = nullptr; | |
240 | 235 | |
241 | 236 | static struct option options[] = { |
242 | 237 | { "session", required_argument, 0, 's' }, |
238 | + { "url", required_argument, 0, 'U' }, | |
243 | 239 | { "perftest", no_argument, 0, 'P' }, |
240 | + { "info", no_argument, 0, 'I' }, | |
244 | 241 | { 0, 0, 0, 0} |
245 | 242 | |
246 | 243 | }; |
... | ... | @@ -252,19 +249,42 @@ |
252 | 249 | switch(opt) { |
253 | 250 | case 's': |
254 | 251 | session = optarg; |
252 | + cout << "Session: " << session << endl; | |
253 | + break; | |
254 | + | |
255 | + case 'U': | |
256 | + url = optarg; | |
257 | + cout << "URL: " << session << endl; | |
255 | 258 | break; |
256 | 259 | |
257 | 260 | case 'P': |
258 | - testPerformance(session); | |
261 | + testPerformance(session,url); | |
262 | + return 0; | |
263 | + | |
264 | + case 'I': | |
265 | + testHost(session,url); | |
259 | 266 | return 0; |
260 | 267 | |
261 | 268 | } |
262 | 269 | |
263 | 270 | } |
264 | 271 | |
265 | - cout << "Session: " << session << endl; | |
272 | + /* | |
273 | + | |
274 | + host.setTimeout(10); | |
275 | + | |
276 | + host.connect(); | |
277 | + host.push(TN3270::ENTER); | |
278 | + | |
279 | + host.toString(14,1,75,0); | |
280 | + | |
281 | + // host.disconnect(); | |
282 | + */ | |
283 | + | |
284 | + | |
285 | + // cout << "Session: " << session << endl; | |
266 | 286 | |
267 | - testHost(session); | |
287 | + //testHost(session); | |
268 | 288 | // testPerformance(session); |
269 | 289 | |
270 | 290 | ... | ... |