Commit 64d1f0f80c78651a966ab301e29435b118b58bff
1 parent
71d02eec
Exists in
master
and in
3 other branches
Adding status "resolving", reorganizing auto-reconnect methods to avoid
"popup hangs".
Showing
11 changed files
with
168 additions
and
149 deletions
Show diff stats
lib3270.cbp
... | ... | @@ -127,6 +127,9 @@ |
127 | 127 | <Unit filename="src/lib3270/charset.c"> |
128 | 128 | <Option compilerVar="CC" /> |
129 | 129 | </Unit> |
130 | + <Unit filename="src/lib3270/connect.c"> | |
131 | + <Option compilerVar="CC" /> | |
132 | + </Unit> | |
130 | 133 | <Unit filename="src/lib3270/ctlr.c"> |
131 | 134 | <Option compilerVar="CC" /> |
132 | 135 | </Unit> | ... | ... |
src/include/lib3270.h
... | ... | @@ -381,7 +381,8 @@ |
381 | 381 | */ |
382 | 382 | typedef enum _lib3270_state |
383 | 383 | { |
384 | - LIB3270_STATE_RESOLVING, | |
384 | + LIB3270_STATE_RESOLVING, ///< @brief Resolving DNS. | |
385 | + LIB3270_STATE_CONNECTING, ///< @brief Connecting to host. | |
385 | 386 | LIB3270_STATE_HALF_CONNECT, |
386 | 387 | LIB3270_STATE_CONNECT, |
387 | 388 | LIB3270_STATE_3270_MODE, | ... | ... |
src/include/screen.h
... | ... | @@ -18,5 +18,6 @@ |
18 | 18 | LIB3270_INTERNAL int *char_width, *char_height; |
19 | 19 | |
20 | 20 | LIB3270_INTERNAL void screen_update(H3270 *session, int bstart, int bend); |
21 | -LIB3270_INTERNAL void status_connecting(H3270 *session, Boolean on); | |
21 | +LIB3270_INTERNAL void status_connecting(H3270 *session); | |
22 | +LIB3270_INTERNAL void status_resolving(H3270 *session); | |
22 | 23 | ... | ... |
src/include/telnetc.h
1 | 1 | /* |
2 | - * Copyright 1995, 1999, 2000, 2001, 2002, 2003, 2004, 2005, | |
3 | - * 2007 by Paul Mattes. | |
4 | - * RPQNAMES modifications Copyright 2004 by Don Russell. | |
5 | - * Permission to use, copy, modify, and distribute this software and its | |
6 | - * documentation for any purpose and without fee is hereby granted, | |
7 | - * provided that the above copyright notice appear in all copies and that | |
8 | - * both that copyright notice and this permission notice appear in | |
9 | - * supporting documentation. | |
10 | - * | |
11 | - * x3270, c3270, s3270 and tcl3270 are distributed in the hope that they will | |
12 | - * be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the file LICENSE | |
14 | - * for more details. | |
2 | + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 | |
3 | + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a | |
4 | + * aplicativos mainframe. Registro no INPI sob o nome G3270. | |
5 | + * | |
6 | + * Copyright (C) <2008> <Banco do Brasil S.A.> | |
7 | + * | |
8 | + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | |
9 | + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | |
10 | + * Free Software Foundation. | |
11 | + * | |
12 | + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | |
13 | + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | |
14 | + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | |
15 | + * obter mais detalhes. | |
16 | + * | |
17 | + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | |
18 | + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin | |
19 | + * St, Fifth Floor, Boston, MA 02110-1301 USA | |
20 | + * | |
21 | + * Este programa está nomeado como - e possui - linhas de código. | |
22 | + * | |
23 | + * Contatos: | |
24 | + * | |
25 | + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
26 | + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | |
27 | + * | |
15 | 28 | */ |
16 | 29 | |
17 | -/* | |
18 | - * telnetc.h | |
19 | - * Global declarations for telnet.c. | |
30 | +/** | |
31 | + * @brief Global declarations for telnet.c. | |
20 | 32 | */ |
21 | 33 | |
22 | -/* Output buffer. */ | |
23 | -// extern unsigned char *obuf; | |
24 | -// extern unsigned char *obptr; | |
25 | - | |
26 | 34 | /* Spelled-out tty control character. */ |
27 | 35 | struct ctl_char { |
28 | 36 | const char *name; |
... | ... | @@ -32,7 +40,10 @@ struct ctl_char { |
32 | 40 | LIB3270_INTERNAL void net_abort(H3270 *hSession); |
33 | 41 | LIB3270_INTERNAL void net_add_eor(unsigned char *buf, int len); |
34 | 42 | LIB3270_INTERNAL void net_break(H3270 *hSession); |
43 | + | |
35 | 44 | LIB3270_INTERNAL int net_connect(H3270 *session, const char *, char *, Boolean, Boolean *, Boolean *); |
45 | +LIB3270_INTERNAL int net_reconnect(H3270 *hSession, int seconds); | |
46 | + | |
36 | 47 | LIB3270_INTERNAL void net_disconnect(H3270 *session); |
37 | 48 | LIB3270_INTERNAL void net_exception(H3270 *session, int fd, LIB3270_IO_FLAG flag, void *dunno); |
38 | 49 | LIB3270_INTERNAL void net_input(H3270 *session, int fd, LIB3270_IO_FLAG flag, void *dunno); |
... | ... | @@ -51,5 +62,4 @@ LIB3270_INTERNAL void space3270out(H3270 *hSession, int n); |
51 | 62 | #define trace_netdata(direction, buf, len) /* */ |
52 | 63 | #endif // X3270_TRACE |
53 | 64 | |
54 | - | |
55 | 65 | LIB3270_INTERNAL int net_getsockname(const H3270 *h3270, void *buf, int *len); | ... | ... |
... | ... | @@ -0,0 +1,95 @@ |
1 | +/* | |
2 | + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 | |
3 | + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a | |
4 | + * aplicativos mainframe. Registro no INPI sob o nome G3270. | |
5 | + * | |
6 | + * Copyright (C) <2008> <Banco do Brasil S.A.> | |
7 | + * | |
8 | + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | |
9 | + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | |
10 | + * Free Software Foundation. | |
11 | + * | |
12 | + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | |
13 | + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | |
14 | + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | |
15 | + * obter mais detalhes. | |
16 | + * | |
17 | + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | |
18 | + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin | |
19 | + * St, Fifth Floor, Boston, MA 02110-1301 USA | |
20 | + * | |
21 | + * Este programa está nomeado como - e possui - linhas de código. | |
22 | + * | |
23 | + * Contatos: | |
24 | + * | |
25 | + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
26 | + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | |
27 | + * | |
28 | + */ | |
29 | + | |
30 | +#include <config.h> | |
31 | +#include "private.h" | |
32 | +#include "telnetc.h" | |
33 | +#include <errno.h> | |
34 | +#include <lib3270/trace.h> | |
35 | + | |
36 | +/*---[ Implement ]-------------------------------------------------------------------------------*/ | |
37 | + | |
38 | + LIB3270_EXPORT int lib3270_connect_url(H3270 *hSession, const char *url, int wait) | |
39 | + { | |
40 | + CHECK_SESSION_HANDLE(hSession); | |
41 | + | |
42 | + if(url && *url) | |
43 | + { | |
44 | + lib3270_set_url(hSession,url); | |
45 | + } | |
46 | + | |
47 | + return lib3270_reconnect(hSession, wait); | |
48 | + | |
49 | + } | |
50 | + | |
51 | + int lib3270_reconnect(H3270 *hSession, int seconds) | |
52 | + { | |
53 | + FAIL_IF_ONLINE(hSession); | |
54 | + | |
55 | + // | |
56 | + // Can't reconnect if already reconnecting *OR* there's an open popup | |
57 | + // (to avoid open more than one connect error popup. | |
58 | + // | |
59 | + if(hSession->auto_reconnect_inprogress || hSession->popups) | |
60 | + return errno = EAGAIN; | |
61 | + | |
62 | + if(hSession->sock > 0) | |
63 | + return errno = EBUSY; | |
64 | + | |
65 | + if(!(hSession->host.current && hSession->host.srvc)) | |
66 | + { | |
67 | + // No host info, try the default one. | |
68 | + if(lib3270_set_url(hSession,NULL)) | |
69 | + { | |
70 | + int err = errno; | |
71 | + lib3270_trace_event(hSession,"Can't set default URL (%s)\n",strerror(err)); | |
72 | + return errno = err; | |
73 | + } | |
74 | + | |
75 | + if(!(hSession->host.current && hSession->host.srvc)) | |
76 | + { | |
77 | + return errno = EINVAL; | |
78 | + } | |
79 | + } | |
80 | + | |
81 | +#if defined(HAVE_LIBSSL) | |
82 | + set_ssl_state(hSession,LIB3270_SSL_UNSECURE); | |
83 | +#endif // HAVE_LIBSSL | |
84 | + | |
85 | + snprintf(hSession->full_model_name,LIB3270_FULL_MODEL_NAME_LENGTH,"IBM-327%c-%d",hSession->m3279 ? '9' : '8', hSession->model_num); | |
86 | + | |
87 | + lib3270_trace_event(hSession,"Reconnecting to %s\n",lib3270_get_url(hSession)); | |
88 | + | |
89 | + hSession->ever_3270 = False; | |
90 | + hSession->ssl.host = 0; | |
91 | + | |
92 | + return net_reconnect(hSession,seconds); | |
93 | + | |
94 | + } | |
95 | + | ... | ... |
src/lib3270/host.c
... | ... | @@ -193,10 +193,10 @@ LIB3270_EXPORT void lib3270_register_schange(H3270 *h, LIB3270_STATE tx, void (* |
193 | 193 | void lib3270_st_changed(H3270 *h, LIB3270_STATE tx, int mode) |
194 | 194 | { |
195 | 195 | #if defined(DEBUG) |
196 | - | |
197 | 196 | static const char * state_name[LIB3270_STATE_USER] = |
198 | 197 | { |
199 | 198 | "LIB3270_STATE_RESOLVING", |
199 | + "LIB3270_STATE_CONNECTING", | |
200 | 200 | "LIB3270_STATE_HALF_CONNECT", |
201 | 201 | "LIB3270_STATE_CONNECT", |
202 | 202 | "LIB3270_STATE_3270_MODE", |
... | ... | @@ -204,10 +204,8 @@ void lib3270_st_changed(H3270 *h, LIB3270_STATE tx, int mode) |
204 | 204 | "LIB3270_STATE_REMODEL", |
205 | 205 | "LIB3270_STATE_PRINTER", |
206 | 206 | "LIB3270_STATE_EXITING", |
207 | - "LIB3270_STATE_CHARSET", | |
208 | - | |
207 | + "LIB3270_STATE_CHARSET" | |
209 | 208 | }; |
210 | - | |
211 | 209 | #endif // DEBUG |
212 | 210 | |
213 | 211 | struct lib3270_state_callback *st; |
... | ... | @@ -218,7 +216,6 @@ void lib3270_st_changed(H3270 *h, LIB3270_STATE tx, int mode) |
218 | 216 | |
219 | 217 | for (st = h->st_callbacks[tx];st;st = st->next) |
220 | 218 | { |
221 | -// trace("st=%p func=%p",st,st->func); | |
222 | 219 | st->func(h,mode,st->data); |
223 | 220 | } |
224 | 221 | ... | ... |
src/lib3270/linux/connect.c
... | ... | @@ -48,10 +48,8 @@ |
48 | 48 | |
49 | 49 | #include <stdlib.h> |
50 | 50 | |
51 | -//#include "statusc.h" | |
52 | 51 | #include "hostc.h" |
53 | 52 | #include "trace_dsc.h" |
54 | -//#include "utilc.h" | |
55 | 53 | #include "telnetc.h" |
56 | 54 | #include "screen.h" |
57 | 55 | |
... | ... | @@ -117,19 +115,6 @@ static void net_connected(H3270 *hSession, int fd unused, LIB3270_IO_FLAG flag u |
117 | 115 | |
118 | 116 | } |
119 | 117 | |
120 | - LIB3270_EXPORT int lib3270_connect_url(H3270 *hSession, const char *url, int wait) | |
121 | - { | |
122 | - CHECK_SESSION_HANDLE(hSession); | |
123 | - | |
124 | - if(url && *url) | |
125 | - { | |
126 | - lib3270_set_url(hSession,url); | |
127 | - } | |
128 | - | |
129 | - return lib3270_reconnect(hSession, wait); | |
130 | - | |
131 | - } | |
132 | - | |
133 | 118 | struct resolver |
134 | 119 | { |
135 | 120 | const char * message; |
... | ... | @@ -147,6 +132,8 @@ static void net_connected(H3270 *hSession, int fd unused, LIB3270_IO_FLAG flag u |
147 | 132 | hints.ai_flags = AI_PASSIVE; // For wildcard IP address |
148 | 133 | hints.ai_protocol = 0; // Any protocol |
149 | 134 | |
135 | + status_resolving(hSession); | |
136 | + | |
150 | 137 | int rc = getaddrinfo(hSession->host.current, hSession->host.srvc, &hints, &result); |
151 | 138 | if(rc != 0) |
152 | 139 | { |
... | ... | @@ -154,7 +141,7 @@ static void net_connected(H3270 *hSession, int fd unused, LIB3270_IO_FLAG flag u |
154 | 141 | return -1; |
155 | 142 | } |
156 | 143 | |
157 | - status_connecting(hSession,1); | |
144 | + status_connecting(hSession); | |
158 | 145 | |
159 | 146 | for(rp = result; hSession->sock < 0 && rp != NULL; rp = rp->ai_next) |
160 | 147 | { |
... | ... | @@ -181,50 +168,11 @@ static void net_connected(H3270 *hSession, int fd unused, LIB3270_IO_FLAG flag u |
181 | 168 | |
182 | 169 | } |
183 | 170 | |
184 | - int lib3270_reconnect(H3270 *hSession, int seconds) | |
171 | + int net_reconnect(H3270 *hSession, int seconds) | |
185 | 172 | { |
186 | - int optval; | |
187 | 173 | struct resolver host; |
188 | - | |
189 | - CHECK_SESSION_HANDLE(hSession); | |
190 | 174 | memset(&host,0,sizeof(host)); |
191 | 175 | |
192 | - if(hSession->auto_reconnect_inprogress) | |
193 | - return errno = EAGAIN; | |
194 | - | |
195 | - if(hSession->sock > 0) | |
196 | - return errno = EBUSY; | |
197 | - | |
198 | - if(!(hSession->host.current && hSession->host.srvc)) | |
199 | - { | |
200 | - // No host info, try the default one. | |
201 | - if(lib3270_set_url(hSession,NULL)) | |
202 | - { | |
203 | - int err = errno; | |
204 | - lib3270_trace_event(hSession,"Can't set default URL (%s)\n",strerror(err)); | |
205 | - return errno = err; | |
206 | - } | |
207 | - | |
208 | - if(!(hSession->host.current && hSession->host.srvc)) | |
209 | - { | |
210 | - return errno = ENOENT; | |
211 | - } | |
212 | - } | |
213 | - | |
214 | -#if defined(HAVE_LIBSSL) | |
215 | - set_ssl_state(hSession,LIB3270_SSL_UNSECURE); | |
216 | -#endif // HAVE_LIBSSL | |
217 | - | |
218 | - snprintf(hSession->full_model_name,LIB3270_FULL_MODEL_NAME_LENGTH,"IBM-327%c-%d",hSession->m3279 ? '9' : '8', hSession->model_num); | |
219 | - | |
220 | - lib3270_trace_event(hSession,"Reconnecting to %s\n",lib3270_get_url(hSession)); | |
221 | - | |
222 | - hSession->ever_3270 = False; | |
223 | - hSession->cstate = LIB3270_RESOLVING; | |
224 | - | |
225 | - lib3270_st_changed(hSession, LIB3270_STATE_RESOLVING, True); | |
226 | - | |
227 | - // s = getaddrinfo(hSession->host.current, hSession->host.srvc, &hints, &result); | |
228 | 176 | if(lib3270_run_task(hSession, background_connect, &host) || hSession->sock < 0) |
229 | 177 | { |
230 | 178 | char buffer[4096]; |
... | ... | @@ -245,10 +193,8 @@ static void net_connected(H3270 *hSession, int fd unused, LIB3270_IO_FLAG flag u |
245 | 193 | (void) fcntl(hSession->sock, F_SETFD, 1); |
246 | 194 | |
247 | 195 | hSession->ever_3270 = False; |
248 | - hSession->ssl.host = 0; | |
249 | 196 | |
250 | 197 | #if defined(HAVE_LIBSSL) |
251 | - debug("** SSL init %s","begins"); | |
252 | 198 | if(hSession->ssl.enabled) |
253 | 199 | { |
254 | 200 | hSession->ssl.host = 1; |
... | ... | @@ -257,11 +203,10 @@ static void net_connected(H3270 *hSession, int fd unused, LIB3270_IO_FLAG flag u |
257 | 203 | return errno = ENOTCONN; |
258 | 204 | |
259 | 205 | } |
260 | - debug("** SSL init %s","ends"); | |
261 | 206 | #endif // HAVE_LIBSSL |
262 | 207 | |
263 | 208 | // set options for inline out-of-band data and keepalives |
264 | - optval = 1; | |
209 | + int optval = 1; | |
265 | 210 | if (setsockopt(hSession->sock, SOL_SOCKET, SO_OOBINLINE, (char *)&optval,sizeof(optval)) < 0) |
266 | 211 | { |
267 | 212 | int rc = errno; | ... | ... |
src/lib3270/screen.c
... | ... | @@ -556,10 +556,26 @@ void status_oerr(H3270 *session, int error_type) |
556 | 556 | |
557 | 557 | } |
558 | 558 | |
559 | -void status_connecting(H3270 *session, Boolean on) | |
559 | +/** | |
560 | + * @brief Resolving DNS name. | |
561 | + * | |
562 | + */ | |
563 | +void status_resolving(H3270 *hSession) | |
564 | +{ | |
565 | + hSession->cstate = LIB3270_RESOLVING; | |
566 | + lib3270_st_changed(hSession, LIB3270_STATE_RESOLVING, True); | |
567 | + | |
568 | + mcursor_set(hSession,LIB3270_POINTER_LOCKED); | |
569 | + status_changed(hSession, LIB3270_MESSAGE_RESOLVING); | |
570 | +} | |
571 | + | |
572 | +void status_connecting(H3270 *hSession) | |
560 | 573 | { |
561 | - mcursor_set(session,on ? LIB3270_POINTER_LOCKED : LIB3270_POINTER_UNLOCKED); | |
562 | - status_changed(session, on ? LIB3270_MESSAGE_CONNECTING : LIB3270_MESSAGE_NONE); | |
574 | + hSession->cstate = LIB3270_RESOLVING; | |
575 | + lib3270_st_changed(hSession, LIB3270_STATE_CONNECTING, True); | |
576 | + | |
577 | + mcursor_set(hSession,LIB3270_POINTER_LOCKED); | |
578 | + status_changed(hSession, LIB3270_MESSAGE_CONNECTING); | |
563 | 579 | } |
564 | 580 | |
565 | 581 | void status_reset(H3270 *session) | ... | ... |
src/lib3270/session.c
... | ... | @@ -86,6 +86,7 @@ void lib3270_session_free(H3270 *h) |
86 | 86 | X509_CRL_free(h->ssl.crl.cert); |
87 | 87 | h->ssl.crl.cert = NULL; |
88 | 88 | } |
89 | +#endif // SSL_ENABLE_CRL_CHECK | |
89 | 90 | |
90 | 91 | // Release state change callbacks |
91 | 92 | for(f=0;f<LIB3270_STATE_USER;f++) |
... | ... | @@ -97,7 +98,6 @@ void lib3270_session_free(H3270 *h) |
97 | 98 | h->st_callbacks[f] = next; |
98 | 99 | } |
99 | 100 | } |
100 | -#endif // SSL_ENABLE_CRL_CHECK | |
101 | 101 | |
102 | 102 | // Release memory |
103 | 103 | #define release_pointer(x) lib3270_free(x); x = NULL; | ... | ... |
src/lib3270/ssl/ctx_init.c
... | ... | @@ -147,7 +147,7 @@ int ssl_ctx_init(H3270 *hSession, SSL_ERROR_MESSAGE * message) |
147 | 147 | if(hSession->ssl.crl.cert) |
148 | 148 | { |
149 | 149 | X509_STORE_add_crl(store, hSession->ssl.crl.cert); |
150 | - trace_ssl(hSession,"CRL was added to cert store"); | |
150 | + trace_ssl(hSession,"CRL was added to cert store\n"); | |
151 | 151 | } |
152 | 152 | |
153 | 153 | X509_VERIFY_PARAM *param = X509_VERIFY_PARAM_new(); | ... | ... |
src/lib3270/windows/connect.c
... | ... | @@ -39,8 +39,7 @@ |
39 | 39 | |
40 | 40 | #include "../private.h" |
41 | 41 | #include <errno.h> |
42 | - | |
43 | -#include <ws2tcpip.h> | |
42 | +#include <lib3270/trace.h> | |
44 | 43 | |
45 | 44 | #ifdef HAVE_ICONV |
46 | 45 | #include <iconv.h> |
... | ... | @@ -150,19 +149,6 @@ static void sockstart(H3270 *session) |
150 | 149 | } |
151 | 150 | } |
152 | 151 | |
153 | -LIB3270_EXPORT int lib3270_connect_url(H3270 *hSession, const char *url, int wait) | |
154 | -{ | |
155 | - CHECK_SESSION_HANDLE(hSession); | |
156 | - | |
157 | - if(url && *url) | |
158 | - { | |
159 | - lib3270_set_url(hSession,url); | |
160 | - } | |
161 | - | |
162 | - return lib3270_reconnect(hSession, wait); | |
163 | - | |
164 | -} | |
165 | - | |
166 | 152 | struct resolver |
167 | 153 | { |
168 | 154 | int convert; |
... | ... | @@ -186,6 +172,8 @@ LIB3270_EXPORT int lib3270_connect_url(H3270 *hSession, const char *url, int wai |
186 | 172 | |
187 | 173 | debug("%s(%s,%s)",__FUNCTION__,hSession->host.current, hSession->host.srvc); |
188 | 174 | |
175 | + status_resolving(hSession); | |
176 | + | |
189 | 177 | int rc = getaddrinfo(hSession->host.current, hSession->host.srvc, &hints, &result); |
190 | 178 | if(rc != 0) |
191 | 179 | { |
... | ... | @@ -194,7 +182,7 @@ LIB3270_EXPORT int lib3270_connect_url(H3270 *hSession, const char *url, int wai |
194 | 182 | return -1; |
195 | 183 | } |
196 | 184 | |
197 | - status_connecting(hSession,1); | |
185 | + status_connecting(hSession); | |
198 | 186 | |
199 | 187 | for(rp = result; hSession->sock < 0 && rp != NULL; rp = rp->ai_next) |
200 | 188 | { |
... | ... | @@ -221,50 +209,14 @@ LIB3270_EXPORT int lib3270_connect_url(H3270 *hSession, const char *url, int wai |
221 | 209 | |
222 | 210 | } |
223 | 211 | |
224 | -int lib3270_reconnect(H3270 *hSession, int seconds) | |
212 | +int net_reconnect(H3270 *hSession, int seconds) | |
225 | 213 | { |
226 | - int optval; | |
227 | - struct resolver host; | |
228 | - | |
229 | - CHECK_SESSION_HANDLE(hSession); | |
214 | + struct resolver host; | |
230 | 215 | |
231 | 216 | memset(&host,0,sizeof(host)); |
232 | 217 | |
233 | - if(hSession->auto_reconnect_inprogress) | |
234 | - return errno = EAGAIN; | |
235 | - | |
236 | - if(hSession->sock > 0) | |
237 | - return errno = EBUSY; | |
238 | - | |
239 | - if(!(hSession->host.current && hSession->host.srvc)) | |
240 | - { | |
241 | - // No host info, try the default one. | |
242 | - if(lib3270_set_url(hSession,NULL)) | |
243 | - { | |
244 | - int err = errno; | |
245 | - lib3270_trace_event(hSession,"Can't set default URL (%s)\n",strerror(err)); | |
246 | - return errno = err; | |
247 | - } | |
248 | - | |
249 | - if(!(hSession->host.current && hSession->host.srvc)) | |
250 | - { | |
251 | - return errno = ENOENT; | |
252 | - } | |
253 | - } | |
254 | - | |
255 | 218 | sockstart(hSession); |
256 | 219 | |
257 | -#if defined(HAVE_LIBSSL) | |
258 | - set_ssl_state(hSession,LIB3270_SSL_UNSECURE); | |
259 | -#endif // HAVE_LIBSSL | |
260 | - | |
261 | - snprintf(hSession->full_model_name,LIB3270_FULL_MODEL_NAME_LENGTH,"IBM-327%c-%d",hSession->m3279 ? '9' : '8', hSession->model_num); | |
262 | - | |
263 | - hSession->ever_3270 = False; | |
264 | - hSession->cstate = LIB3270_RESOLVING; | |
265 | - | |
266 | - lib3270_st_changed(hSession, LIB3270_STATE_RESOLVING, True); | |
267 | - | |
268 | 220 | if(lib3270_run_task(hSession, background_connect, &host) || hSession->sock < 0) |
269 | 221 | { |
270 | 222 | lib3270_autoptr(char) message = lib3270_strdup_printf(_( "Can't connect to %s"), lib3270_get_url(hSession)); |
... | ... | @@ -333,9 +285,8 @@ int lib3270_reconnect(H3270 *hSession, int seconds) |
333 | 285 | /* connect */ |
334 | 286 | |
335 | 287 | WSASetLastError(0); |
336 | - // u_long iMode=1; | |
337 | 288 | |
338 | - optval = lib3270_get_toggle(hSession,LIB3270_TOGGLE_KEEP_ALIVE) ? 1 : 0; | |
289 | + int optval = lib3270_get_toggle(hSession,LIB3270_TOGGLE_KEEP_ALIVE) ? 1 : 0; | |
339 | 290 | if (setsockopt(hSession->sock, SOL_SOCKET, SO_KEEPALIVE, (char *)&optval, sizeof(optval)) < 0) |
340 | 291 | { |
341 | 292 | char buffer[4096]; | ... | ... |