Commit 64d1f0f80c78651a966ab301e29435b118b58bff

Authored by Perry Werneck
1 parent 71d02eec

Adding status "resolving", reorganizing auto-reconnect methods to avoid

"popup hangs".
@@ -127,6 +127,9 @@ @@ -127,6 +127,9 @@
127 <Unit filename="src/lib3270/charset.c"> 127 <Unit filename="src/lib3270/charset.c">
128 <Option compilerVar="CC" /> 128 <Option compilerVar="CC" />
129 </Unit> 129 </Unit>
  130 + <Unit filename="src/lib3270/connect.c">
  131 + <Option compilerVar="CC" />
  132 + </Unit>
130 <Unit filename="src/lib3270/ctlr.c"> 133 <Unit filename="src/lib3270/ctlr.c">
131 <Option compilerVar="CC" /> 134 <Option compilerVar="CC" />
132 </Unit> 135 </Unit>
src/include/lib3270.h
@@ -381,7 +381,8 @@ @@ -381,7 +381,8 @@
381 */ 381 */
382 typedef enum _lib3270_state 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 LIB3270_STATE_HALF_CONNECT, 386 LIB3270_STATE_HALF_CONNECT,
386 LIB3270_STATE_CONNECT, 387 LIB3270_STATE_CONNECT,
387 LIB3270_STATE_3270_MODE, 388 LIB3270_STATE_3270_MODE,
src/include/screen.h
@@ -18,5 +18,6 @@ @@ -18,5 +18,6 @@
18 LIB3270_INTERNAL int *char_width, *char_height; 18 LIB3270_INTERNAL int *char_width, *char_height;
19 19
20 LIB3270_INTERNAL void screen_update(H3270 *session, int bstart, int bend); 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 /* Spelled-out tty control character. */ 34 /* Spelled-out tty control character. */
27 struct ctl_char { 35 struct ctl_char {
28 const char *name; 36 const char *name;
@@ -32,7 +40,10 @@ struct ctl_char { @@ -32,7 +40,10 @@ struct ctl_char {
32 LIB3270_INTERNAL void net_abort(H3270 *hSession); 40 LIB3270_INTERNAL void net_abort(H3270 *hSession);
33 LIB3270_INTERNAL void net_add_eor(unsigned char *buf, int len); 41 LIB3270_INTERNAL void net_add_eor(unsigned char *buf, int len);
34 LIB3270_INTERNAL void net_break(H3270 *hSession); 42 LIB3270_INTERNAL void net_break(H3270 *hSession);
  43 +
35 LIB3270_INTERNAL int net_connect(H3270 *session, const char *, char *, Boolean, Boolean *, Boolean *); 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 LIB3270_INTERNAL void net_disconnect(H3270 *session); 47 LIB3270_INTERNAL void net_disconnect(H3270 *session);
37 LIB3270_INTERNAL void net_exception(H3270 *session, int fd, LIB3270_IO_FLAG flag, void *dunno); 48 LIB3270_INTERNAL void net_exception(H3270 *session, int fd, LIB3270_IO_FLAG flag, void *dunno);
38 LIB3270_INTERNAL void net_input(H3270 *session, int fd, LIB3270_IO_FLAG flag, void *dunno); 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,5 +62,4 @@ LIB3270_INTERNAL void space3270out(H3270 *hSession, int n);
51 #define trace_netdata(direction, buf, len) /* */ 62 #define trace_netdata(direction, buf, len) /* */
52 #endif // X3270_TRACE 63 #endif // X3270_TRACE
53 64
54 -  
55 LIB3270_INTERNAL int net_getsockname(const H3270 *h3270, void *buf, int *len); 65 LIB3270_INTERNAL int net_getsockname(const H3270 *h3270, void *buf, int *len);
src/lib3270/connect.c 0 → 100644
@@ -0,0 +1,95 @@ @@ -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,10 +193,10 @@ LIB3270_EXPORT void lib3270_register_schange(H3270 *h, LIB3270_STATE tx, void (*
193 void lib3270_st_changed(H3270 *h, LIB3270_STATE tx, int mode) 193 void lib3270_st_changed(H3270 *h, LIB3270_STATE tx, int mode)
194 { 194 {
195 #if defined(DEBUG) 195 #if defined(DEBUG)
196 -  
197 static const char * state_name[LIB3270_STATE_USER] = 196 static const char * state_name[LIB3270_STATE_USER] =
198 { 197 {
199 "LIB3270_STATE_RESOLVING", 198 "LIB3270_STATE_RESOLVING",
  199 + "LIB3270_STATE_CONNECTING",
200 "LIB3270_STATE_HALF_CONNECT", 200 "LIB3270_STATE_HALF_CONNECT",
201 "LIB3270_STATE_CONNECT", 201 "LIB3270_STATE_CONNECT",
202 "LIB3270_STATE_3270_MODE", 202 "LIB3270_STATE_3270_MODE",
@@ -204,10 +204,8 @@ void lib3270_st_changed(H3270 *h, LIB3270_STATE tx, int mode) @@ -204,10 +204,8 @@ void lib3270_st_changed(H3270 *h, LIB3270_STATE tx, int mode)
204 "LIB3270_STATE_REMODEL", 204 "LIB3270_STATE_REMODEL",
205 "LIB3270_STATE_PRINTER", 205 "LIB3270_STATE_PRINTER",
206 "LIB3270_STATE_EXITING", 206 "LIB3270_STATE_EXITING",
207 - "LIB3270_STATE_CHARSET",  
208 - 207 + "LIB3270_STATE_CHARSET"
209 }; 208 };
210 -  
211 #endif // DEBUG 209 #endif // DEBUG
212 210
213 struct lib3270_state_callback *st; 211 struct lib3270_state_callback *st;
@@ -218,7 +216,6 @@ void lib3270_st_changed(H3270 *h, LIB3270_STATE tx, int mode) @@ -218,7 +216,6 @@ void lib3270_st_changed(H3270 *h, LIB3270_STATE tx, int mode)
218 216
219 for (st = h->st_callbacks[tx];st;st = st->next) 217 for (st = h->st_callbacks[tx];st;st = st->next)
220 { 218 {
221 -// trace("st=%p func=%p",st,st->func);  
222 st->func(h,mode,st->data); 219 st->func(h,mode,st->data);
223 } 220 }
224 221
src/lib3270/linux/connect.c
@@ -48,10 +48,8 @@ @@ -48,10 +48,8 @@
48 48
49 #include <stdlib.h> 49 #include <stdlib.h>
50 50
51 -//#include "statusc.h"  
52 #include "hostc.h" 51 #include "hostc.h"
53 #include "trace_dsc.h" 52 #include "trace_dsc.h"
54 -//#include "utilc.h"  
55 #include "telnetc.h" 53 #include "telnetc.h"
56 #include "screen.h" 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,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 struct resolver 118 struct resolver
134 { 119 {
135 const char * message; 120 const char * message;
@@ -147,6 +132,8 @@ static void net_connected(H3270 *hSession, int fd unused, LIB3270_IO_FLAG flag u @@ -147,6 +132,8 @@ static void net_connected(H3270 *hSession, int fd unused, LIB3270_IO_FLAG flag u
147 hints.ai_flags = AI_PASSIVE; // For wildcard IP address 132 hints.ai_flags = AI_PASSIVE; // For wildcard IP address
148 hints.ai_protocol = 0; // Any protocol 133 hints.ai_protocol = 0; // Any protocol
149 134
  135 + status_resolving(hSession);
  136 +
150 int rc = getaddrinfo(hSession->host.current, hSession->host.srvc, &hints, &result); 137 int rc = getaddrinfo(hSession->host.current, hSession->host.srvc, &hints, &result);
151 if(rc != 0) 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,7 +141,7 @@ static void net_connected(H3270 *hSession, int fd unused, LIB3270_IO_FLAG flag u
154 return -1; 141 return -1;
155 } 142 }
156 143
157 - status_connecting(hSession,1); 144 + status_connecting(hSession);
158 145
159 for(rp = result; hSession->sock < 0 && rp != NULL; rp = rp->ai_next) 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,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 struct resolver host; 173 struct resolver host;
188 -  
189 - CHECK_SESSION_HANDLE(hSession);  
190 memset(&host,0,sizeof(host)); 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 if(lib3270_run_task(hSession, background_connect, &host) || hSession->sock < 0) 176 if(lib3270_run_task(hSession, background_connect, &host) || hSession->sock < 0)
229 { 177 {
230 char buffer[4096]; 178 char buffer[4096];
@@ -245,10 +193,8 @@ static void net_connected(H3270 *hSession, int fd unused, LIB3270_IO_FLAG flag u @@ -245,10 +193,8 @@ static void net_connected(H3270 *hSession, int fd unused, LIB3270_IO_FLAG flag u
245 (void) fcntl(hSession->sock, F_SETFD, 1); 193 (void) fcntl(hSession->sock, F_SETFD, 1);
246 194
247 hSession->ever_3270 = False; 195 hSession->ever_3270 = False;
248 - hSession->ssl.host = 0;  
249 196
250 #if defined(HAVE_LIBSSL) 197 #if defined(HAVE_LIBSSL)
251 - debug("** SSL init %s","begins");  
252 if(hSession->ssl.enabled) 198 if(hSession->ssl.enabled)
253 { 199 {
254 hSession->ssl.host = 1; 200 hSession->ssl.host = 1;
@@ -257,11 +203,10 @@ static void net_connected(H3270 *hSession, int fd unused, LIB3270_IO_FLAG flag u @@ -257,11 +203,10 @@ static void net_connected(H3270 *hSession, int fd unused, LIB3270_IO_FLAG flag u
257 return errno = ENOTCONN; 203 return errno = ENOTCONN;
258 204
259 } 205 }
260 - debug("** SSL init %s","ends");  
261 #endif // HAVE_LIBSSL 206 #endif // HAVE_LIBSSL
262 207
263 // set options for inline out-of-band data and keepalives 208 // set options for inline out-of-band data and keepalives
264 - optval = 1; 209 + int optval = 1;
265 if (setsockopt(hSession->sock, SOL_SOCKET, SO_OOBINLINE, (char *)&optval,sizeof(optval)) < 0) 210 if (setsockopt(hSession->sock, SOL_SOCKET, SO_OOBINLINE, (char *)&optval,sizeof(optval)) < 0)
266 { 211 {
267 int rc = errno; 212 int rc = errno;
src/lib3270/screen.c
@@ -556,10 +556,26 @@ void status_oerr(H3270 *session, int error_type) @@ -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 void status_reset(H3270 *session) 581 void status_reset(H3270 *session)
src/lib3270/session.c
@@ -86,6 +86,7 @@ void lib3270_session_free(H3270 *h) @@ -86,6 +86,7 @@ void lib3270_session_free(H3270 *h)
86 X509_CRL_free(h->ssl.crl.cert); 86 X509_CRL_free(h->ssl.crl.cert);
87 h->ssl.crl.cert = NULL; 87 h->ssl.crl.cert = NULL;
88 } 88 }
  89 +#endif // SSL_ENABLE_CRL_CHECK
89 90
90 // Release state change callbacks 91 // Release state change callbacks
91 for(f=0;f<LIB3270_STATE_USER;f++) 92 for(f=0;f<LIB3270_STATE_USER;f++)
@@ -97,7 +98,6 @@ void lib3270_session_free(H3270 *h) @@ -97,7 +98,6 @@ void lib3270_session_free(H3270 *h)
97 h->st_callbacks[f] = next; 98 h->st_callbacks[f] = next;
98 } 99 }
99 } 100 }
100 -#endif // SSL_ENABLE_CRL_CHECK  
101 101
102 // Release memory 102 // Release memory
103 #define release_pointer(x) lib3270_free(x); x = NULL; 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,7 +147,7 @@ int ssl_ctx_init(H3270 *hSession, SSL_ERROR_MESSAGE * message)
147 if(hSession->ssl.crl.cert) 147 if(hSession->ssl.crl.cert)
148 { 148 {
149 X509_STORE_add_crl(store, hSession->ssl.crl.cert); 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 X509_VERIFY_PARAM *param = X509_VERIFY_PARAM_new(); 153 X509_VERIFY_PARAM *param = X509_VERIFY_PARAM_new();
src/lib3270/windows/connect.c
@@ -39,8 +39,7 @@ @@ -39,8 +39,7 @@
39 39
40 #include "../private.h" 40 #include "../private.h"
41 #include <errno.h> 41 #include <errno.h>
42 -  
43 -#include <ws2tcpip.h> 42 +#include <lib3270/trace.h>
44 43
45 #ifdef HAVE_ICONV 44 #ifdef HAVE_ICONV
46 #include <iconv.h> 45 #include <iconv.h>
@@ -150,19 +149,6 @@ static void sockstart(H3270 *session) @@ -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 struct resolver 152 struct resolver
167 { 153 {
168 int convert; 154 int convert;
@@ -186,6 +172,8 @@ LIB3270_EXPORT int lib3270_connect_url(H3270 *hSession, const char *url, int wai @@ -186,6 +172,8 @@ LIB3270_EXPORT int lib3270_connect_url(H3270 *hSession, const char *url, int wai
186 172
187 debug("%s(%s,%s)",__FUNCTION__,hSession->host.current, hSession->host.srvc); 173 debug("%s(%s,%s)",__FUNCTION__,hSession->host.current, hSession->host.srvc);
188 174
  175 + status_resolving(hSession);
  176 +
189 int rc = getaddrinfo(hSession->host.current, hSession->host.srvc, &hints, &result); 177 int rc = getaddrinfo(hSession->host.current, hSession->host.srvc, &hints, &result);
190 if(rc != 0) 178 if(rc != 0)
191 { 179 {
@@ -194,7 +182,7 @@ LIB3270_EXPORT int lib3270_connect_url(H3270 *hSession, const char *url, int wai @@ -194,7 +182,7 @@ LIB3270_EXPORT int lib3270_connect_url(H3270 *hSession, const char *url, int wai
194 return -1; 182 return -1;
195 } 183 }
196 184
197 - status_connecting(hSession,1); 185 + status_connecting(hSession);
198 186
199 for(rp = result; hSession->sock < 0 && rp != NULL; rp = rp->ai_next) 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,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 memset(&host,0,sizeof(host)); 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 sockstart(hSession); 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 if(lib3270_run_task(hSession, background_connect, &host) || hSession->sock < 0) 220 if(lib3270_run_task(hSession, background_connect, &host) || hSession->sock < 0)
269 { 221 {
270 lib3270_autoptr(char) message = lib3270_strdup_printf(_( "Can't connect to %s"), lib3270_get_url(hSession)); 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,9 +285,8 @@ int lib3270_reconnect(H3270 *hSession, int seconds)
333 /* connect */ 285 /* connect */
334 286
335 WSASetLastError(0); 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 if (setsockopt(hSession->sock, SOL_SOCKET, SO_KEEPALIVE, (char *)&optval, sizeof(optval)) < 0) 290 if (setsockopt(hSession->sock, SOL_SOCKET, SO_KEEPALIVE, (char *)&optval, sizeof(optval)) < 0)
340 { 291 {
341 char buffer[4096]; 292 char buffer[4096];