Commit 22842162e8b587ff4f4c1df3a9cb853a4409aea5
1 parent
765391db
Exists in
master
and in
1 other branch
Fixing performance issues.
Showing
4 changed files
with
68 additions
and
91 deletions
Show diff stats
src/core/actions.cc
@@ -36,12 +36,7 @@ | @@ -36,12 +36,7 @@ | ||
36 | 36 | ||
37 | try { | 37 | try { |
38 | 38 | ||
39 | - TN3270::Host &host = getSession(); | ||
40 | - | ||
41 | - if(!host.isConnected()) | ||
42 | - return HLLAPI_STATUS_DISCONNECTED; | ||
43 | - | ||
44 | - worker(host); | 39 | + worker(getSession()); |
45 | 40 | ||
46 | return HLLAPI_STATUS_SUCCESS; | 41 | return HLLAPI_STATUS_SUCCESS; |
47 | 42 |
src/core/calls.cc
@@ -37,6 +37,10 @@ | @@ -37,6 +37,10 @@ | ||
37 | 37 | ||
38 | return atoi(getSession().getRevision().c_str()); | 38 | return atoi(getSession().getRevision().c_str()); |
39 | 39 | ||
40 | + } catch(const std::system_error &e) { | ||
41 | + | ||
42 | + hllapi_translate_error(e); | ||
43 | + | ||
40 | } catch(const std::exception &e) { | 44 | } catch(const std::exception &e) { |
41 | 45 | ||
42 | hllapi_lasterror = e.what(); | 46 | hllapi_lasterror = e.what(); |
@@ -57,6 +61,10 @@ | @@ -57,6 +61,10 @@ | ||
57 | if(wait) | 61 | if(wait) |
58 | host.wait(TN3270::CONNECTED_TN3270E); | 62 | host.wait(TN3270::CONNECTED_TN3270E); |
59 | 63 | ||
64 | + } catch(const std::system_error &e) { | ||
65 | + | ||
66 | + return hllapi_translate_error(e); | ||
67 | + | ||
60 | } catch(const std::exception &e) { | 68 | } catch(const std::exception &e) { |
61 | 69 | ||
62 | hllapi_lasterror = e.what(); | 70 | hllapi_lasterror = e.what(); |
@@ -79,6 +87,10 @@ | @@ -79,6 +87,10 @@ | ||
79 | 87 | ||
80 | return getSession().isConnected(); | 88 | return getSession().isConnected(); |
81 | 89 | ||
90 | + } catch(const std::system_error &e) { | ||
91 | + | ||
92 | + return hllapi_translate_error(e); | ||
93 | + | ||
82 | } catch(std::exception &e) { | 94 | } catch(std::exception &e) { |
83 | 95 | ||
84 | hllapi_lasterror = e.what(); | 96 | hllapi_lasterror = e.what(); |
@@ -120,6 +132,10 @@ | @@ -120,6 +132,10 @@ | ||
120 | return HLLAPI_STATUS_WAITING; // time-out while still busy (in XCLOCK or XSYSTEM in X) for the 3270 terminal emulation. | 132 | return HLLAPI_STATUS_WAITING; // time-out while still busy (in XCLOCK or XSYSTEM in X) for the 3270 terminal emulation. |
121 | } | 133 | } |
122 | 134 | ||
135 | + } catch(const std::system_error &e) { | ||
136 | + | ||
137 | + return hllapi_translate_error(e); | ||
138 | + | ||
123 | } catch(std::exception &e) { | 139 | } catch(std::exception &e) { |
124 | 140 | ||
125 | hllapi_lasterror = e.what(); | 141 | hllapi_lasterror = e.what(); |
@@ -136,6 +152,10 @@ | @@ -136,6 +152,10 @@ | ||
136 | 152 | ||
137 | return (DWORD) getSession().getProgramMessage(); | 153 | return (DWORD) getSession().getProgramMessage(); |
138 | 154 | ||
155 | + } catch(const std::system_error &e) { | ||
156 | + | ||
157 | + hllapi_translate_error(e); | ||
158 | + | ||
139 | } catch(std::exception &e) { | 159 | } catch(std::exception &e) { |
140 | 160 | ||
141 | hllapi_lasterror = e.what(); | 161 | hllapi_lasterror = e.what(); |
@@ -153,6 +173,10 @@ | @@ -153,6 +173,10 @@ | ||
153 | 173 | ||
154 | getSession().disconnect(); | 174 | getSession().disconnect(); |
155 | 175 | ||
176 | + } catch(const std::system_error &e) { | ||
177 | + | ||
178 | + return hllapi_translate_error(e); | ||
179 | + | ||
156 | } catch(std::exception &e) { | 180 | } catch(std::exception &e) { |
157 | 181 | ||
158 | hllapi_lasterror = e.what(); | 182 | hllapi_lasterror = e.what(); |
@@ -168,12 +192,12 @@ | @@ -168,12 +192,12 @@ | ||
168 | 192 | ||
169 | try { | 193 | try { |
170 | 194 | ||
171 | - TN3270::Host &host = getSession(); | 195 | + getSession().waitForReady((unsigned int) seconds); |
196 | + return HLLAPI_STATUS_SUCCESS; | ||
172 | 197 | ||
173 | - if(host.isConnected()) | ||
174 | - host.waitForReady((unsigned int) seconds); | 198 | + } catch(const std::system_error &e) { |
175 | 199 | ||
176 | - return hllapi_get_state(); | 200 | + return hllapi_translate_error(e); |
177 | 201 | ||
178 | } catch(const std::exception &e) { | 202 | } catch(const std::exception &e) { |
179 | 203 | ||
@@ -193,7 +217,11 @@ | @@ -193,7 +217,11 @@ | ||
193 | 217 | ||
194 | host.wait((TN3270::ConnectionState) cstate, (unsigned int) seconds); | 218 | host.wait((TN3270::ConnectionState) cstate, (unsigned int) seconds); |
195 | 219 | ||
196 | - return 0; | 220 | + return HLLAPI_STATUS_SUCCESS; |
221 | + | ||
222 | + } catch(const std::system_error &e) { | ||
223 | + | ||
224 | + return hllapi_translate_error(e); | ||
197 | 225 | ||
198 | } catch(const std::exception &e) { | 226 | } catch(const std::exception &e) { |
199 | 227 | ||
@@ -209,12 +237,12 @@ | @@ -209,12 +237,12 @@ | ||
209 | 237 | ||
210 | try { | 238 | try { |
211 | 239 | ||
212 | - TN3270::Host &host = getSession(); | 240 | + getSession().waitForChange((unsigned int) seconds); |
241 | + return HLLAPI_STATUS_SUCCESS; | ||
213 | 242 | ||
214 | - if(host.isConnected()) | ||
215 | - host.waitForChange((unsigned int) seconds); | 243 | + } catch(const std::system_error &e) { |
216 | 244 | ||
217 | - return hllapi_get_state(); | 245 | + return hllapi_translate_error(e); |
218 | 246 | ||
219 | } catch(std::exception &e) { | 247 | } catch(std::exception &e) { |
220 | 248 | ||
@@ -233,6 +261,10 @@ | @@ -233,6 +261,10 @@ | ||
233 | getSession().setCharSet((const char *) charset); | 261 | getSession().setCharSet((const char *) charset); |
234 | return HLLAPI_STATUS_SUCCESS; | 262 | return HLLAPI_STATUS_SUCCESS; |
235 | 263 | ||
264 | + } catch(const std::system_error &e) { | ||
265 | + | ||
266 | + return hllapi_translate_error(e); | ||
267 | + | ||
236 | } catch(std::exception &e) { | 268 | } catch(std::exception &e) { |
237 | 269 | ||
238 | hllapi_lasterror = e.what(); | 270 | hllapi_lasterror = e.what(); |
@@ -248,8 +280,11 @@ | @@ -248,8 +280,11 @@ | ||
248 | try { | 280 | try { |
249 | 281 | ||
250 | getSession().wait(seconds); | 282 | getSession().wait(seconds); |
283 | + return HLLAPI_STATUS_SUCCESS; | ||
251 | 284 | ||
252 | - return hllapi_get_state(); | 285 | + } catch(const std::system_error &e) { |
286 | + | ||
287 | + return hllapi_translate_error(e); | ||
253 | 288 | ||
254 | } catch(std::exception &e) { | 289 | } catch(std::exception &e) { |
255 | 290 | ||
@@ -267,6 +302,10 @@ | @@ -267,6 +302,10 @@ | ||
267 | 302 | ||
268 | return getSession().compare((unsigned int) row, (unsigned int) col, text); | 303 | return getSession().compare((unsigned int) row, (unsigned int) col, text); |
269 | 304 | ||
305 | + } catch(const std::system_error &e) { | ||
306 | + | ||
307 | + return hllapi_translate_error(e); | ||
308 | + | ||
270 | } catch(std::exception &e) { | 309 | } catch(std::exception &e) { |
271 | 310 | ||
272 | hllapi_lasterror = e.what(); | 311 | hllapi_lasterror = e.what(); |
@@ -285,6 +324,10 @@ | @@ -285,6 +324,10 @@ | ||
285 | 324 | ||
286 | return HLLAPI_STATUS_SUCCESS; | 325 | return HLLAPI_STATUS_SUCCESS; |
287 | 326 | ||
327 | + } catch(const std::system_error &e) { | ||
328 | + | ||
329 | + return hllapi_translate_error(e); | ||
330 | + | ||
288 | } catch(std::exception &e) { | 331 | } catch(std::exception &e) { |
289 | 332 | ||
290 | hllapi_lasterror = e.what(); | 333 | hllapi_lasterror = e.what(); |
@@ -301,6 +344,10 @@ | @@ -301,6 +344,10 @@ | ||
301 | 344 | ||
302 | return getSession().compare((int) addr, text); | 345 | return getSession().compare((int) addr, text); |
303 | 346 | ||
347 | + } catch(const std::system_error &e) { | ||
348 | + | ||
349 | + return hllapi_translate_error(e); | ||
350 | + | ||
304 | } catch(std::exception &e) { | 351 | } catch(std::exception &e) { |
305 | 352 | ||
306 | hllapi_lasterror = e.what(); | 353 | hllapi_lasterror = e.what(); |
@@ -324,6 +371,10 @@ | @@ -324,6 +371,10 @@ | ||
324 | 371 | ||
325 | } | 372 | } |
326 | 373 | ||
374 | + } catch(const std::system_error &e) { | ||
375 | + | ||
376 | + return hllapi_translate_error(e); | ||
377 | + | ||
327 | } catch(std::exception &e) { | 378 | } catch(std::exception &e) { |
328 | 379 | ||
329 | hllapi_lasterror = e.what(); | 380 | hllapi_lasterror = e.what(); |
src/core/cursor.cc
@@ -35,16 +35,13 @@ | @@ -35,16 +35,13 @@ | ||
35 | 35 | ||
36 | try { | 36 | try { |
37 | 37 | ||
38 | - TN3270::Host &host = getSession(); | 38 | + worker(getSession()); |
39 | 39 | ||
40 | - if(!host.isConnected()) { | ||
41 | - hllapi_lasterror = _( "Disconnected from host" ); | ||
42 | - return HLLAPI_STATUS_DISCONNECTED; | ||
43 | - } | 40 | + return HLLAPI_STATUS_SUCCESS; |
44 | 41 | ||
45 | - worker(host); | 42 | + } catch(const std::system_error &e) { |
46 | 43 | ||
47 | - return HLLAPI_STATUS_SUCCESS; | 44 | + return hllapi_translate_error(e); |
48 | 45 | ||
49 | } catch(const std::exception &e) { | 46 | } catch(const std::exception &e) { |
50 | 47 |
src/core/set.cc
@@ -38,74 +38,9 @@ | @@ -38,74 +38,9 @@ | ||
38 | 38 | ||
39 | static DWORD set(std::function<void(TN3270::Host &)> worker) noexcept { | 39 | static DWORD set(std::function<void(TN3270::Host &)> worker) noexcept { |
40 | 40 | ||
41 | - LIB3270_KEYBOARD_LOCK_STATE kLock = LIB3270_KL_UNLOCKED; | ||
42 | - | ||
43 | try { | 41 | try { |
44 | 42 | ||
45 | - TN3270::Host &host = getSession(); | ||
46 | - | ||
47 | - switch(host.waitForKeyboardUnlock()) { | ||
48 | - case LIB3270_KL_UNLOCKED: | ||
49 | - worker(host); | ||
50 | - break; | ||
51 | - | ||
52 | - case LIB3270_KL_NOT_CONNECTED: | ||
53 | - hllapi_lasterror = _("Not connected to host"); | ||
54 | - return HLLAPI_STATUS_DISCONNECTED; | ||
55 | - | ||
56 | - case LIB3270_KL_OERR_MASK: | ||
57 | - hllapi_lasterror = _("LIB3270_KL_OERR_MASK"); | ||
58 | - return HLLAPI_STATUS_KEYBOARD_LOCKED; | ||
59 | - | ||
60 | - case LIB3270_KL_OERR_PROTECTED: | ||
61 | - hllapi_lasterror = _("LIB3270_KL_OERR_PROTECTED"); | ||
62 | - return HLLAPI_STATUS_KEYBOARD_LOCKED; | ||
63 | - | ||
64 | - case LIB3270_KL_OERR_NUMERIC: | ||
65 | - hllapi_lasterror = _("LIB3270_KL_OERR_NUMERIC"); | ||
66 | - return HLLAPI_STATUS_KEYBOARD_LOCKED; | ||
67 | - | ||
68 | - case LIB3270_KL_OERR_OVERFLOW: | ||
69 | - hllapi_lasterror = _("LIB3270_KL_OERR_OVERFLOW"); | ||
70 | - return HLLAPI_STATUS_KEYBOARD_LOCKED; | ||
71 | - | ||
72 | - case LIB3270_KL_OERR_DBCS: | ||
73 | - hllapi_lasterror = _("LIB3270_KL_OERR_DBCS"); | ||
74 | - return HLLAPI_STATUS_KEYBOARD_LOCKED; | ||
75 | - | ||
76 | - case LIB3270_KL_AWAITING_FIRST: | ||
77 | - hllapi_lasterror = _("LIB3270_KL_AWAITING_FIRST"); | ||
78 | - return HLLAPI_STATUS_KEYBOARD_LOCKED; | ||
79 | - | ||
80 | - case LIB3270_KL_OIA_TWAIT: | ||
81 | - hllapi_lasterror = _("LIB3270_KL_OIA_TWAIT"); | ||
82 | - return HLLAPI_STATUS_KEYBOARD_LOCKED; | ||
83 | - | ||
84 | - case LIB3270_KL_OIA_LOCKED: | ||
85 | - hllapi_lasterror = _("LIB3270_KL_OIA_LOCKED"); | ||
86 | - return HLLAPI_STATUS_KEYBOARD_LOCKED; | ||
87 | - | ||
88 | - case LIB3270_KL_DEFERRED_UNLOCK: | ||
89 | - hllapi_lasterror = _("LIB3270_KL_DEFERRED_UNLOCK"); | ||
90 | - return HLLAPI_STATUS_KEYBOARD_LOCKED; | ||
91 | - | ||
92 | - case LIB3270_KL_ENTER_INHIBIT: | ||
93 | - hllapi_lasterror = _("LIB3270_KL_ENTER_INHIBIT"); | ||
94 | - return HLLAPI_STATUS_KEYBOARD_LOCKED; | ||
95 | - | ||
96 | - case LIB3270_KL_SCROLLED: | ||
97 | - hllapi_lasterror = _("LIB3270_KL_SCROLLED"); | ||
98 | - return HLLAPI_STATUS_KEYBOARD_LOCKED; | ||
99 | - | ||
100 | - case LIB3270_KL_OIA_MINUS: | ||
101 | - hllapi_lasterror = _("LIB3270_KL_OIA_MINUS"); | ||
102 | - return HLLAPI_STATUS_KEYBOARD_LOCKED; | ||
103 | - | ||
104 | - default: | ||
105 | - hllapi_lasterror = _("Unexpected error waiting for keyboard unlock"); | ||
106 | - return HLLAPI_STATUS_SYSTEM_ERROR; | ||
107 | - } | ||
108 | - | 43 | + worker(getSession()); |
109 | return HLLAPI_STATUS_SUCCESS; | 44 | return HLLAPI_STATUS_SUCCESS; |
110 | 45 | ||
111 | } catch(const std::system_error &e) { | 46 | } catch(const std::system_error &e) { |
@@ -122,11 +57,10 @@ | @@ -122,11 +57,10 @@ | ||
122 | 57 | ||
123 | // Unexpected error getting session or lock state | 58 | // Unexpected error getting session or lock state |
124 | hllapi_lasterror = _( "Unexpected error" ); | 59 | hllapi_lasterror = _( "Unexpected error" ); |
125 | - return HLLAPI_STATUS_SYSTEM_ERROR; | ||
126 | 60 | ||
127 | } | 61 | } |
128 | 62 | ||
129 | - return hllapi_translate_error(kLock); | 63 | + return HLLAPI_STATUS_SYSTEM_ERROR; |
130 | 64 | ||
131 | } | 65 | } |
132 | 66 |