From 85a9cb317f700294b745ded07f6cfeef8636dfab Mon Sep 17 00:00:00 2001 From: perry.werneck@gmail.com Date: Thu, 27 Nov 2014 00:28:28 +0000 Subject: [PATCH] Melhorando controles --- connect.c | 8 +------- iocalls.c | 17 ++++++----------- telnet.c | 3 +-- 3 files changed, 8 insertions(+), 20 deletions(-) diff --git a/connect.c b/connect.c index 933d000..cb17e7d 100644 --- a/connect.c +++ b/connect.c @@ -82,7 +82,7 @@ static void net_connected(H3270 *hSession, int fd, LIB3270_IO_FLAG flag, void *d int err; socklen_t len = sizeof(err); - trace("%s",__FUNCTION__); + trace("%s write=%p",__FUNCTION__,hSession->ns_write_id); lib3270_remove_poll(hSession->ns_write_id); hSession->ns_write_id = NULL; @@ -121,15 +121,9 @@ static void net_connected(H3270 *hSession, int fd, LIB3270_IO_FLAG flag, void *d return; } -// hSession->ns_exception_id = AddExcept(hSession->sock, hSession, net_exception); -// hSession->ns_read_id = AddInput(hSession->sock, hSession, net_input); - hSession->ns_exception_id = lib3270_add_poll_fd(hSession,hSession->sock,LIB3270_IO_FLAG_EXCEPTION,net_exception,0); hSession->ns_read_id = lib3270_add_poll_fd(hSession,hSession->sock,LIB3270_IO_FLAG_READ,net_input,0); - hSession->excepting = 1; - hSession->reading = 1; - #if defined(HAVE_LIBSSL) if(hSession->ssl_con && hSession->secure == LIB3270_SSL_UNDEFINED) { diff --git a/iocalls.c b/iocalls.c index 06f0b62..acaf3cd 100644 --- a/iocalls.c +++ b/iocalls.c @@ -273,6 +273,7 @@ static void internal_remove_poll(void *id) } LIB3270_EXPORT void lib3270_remove_poll(void *id) { + debug("%s %p",__FUNCTION__,id); remove_poll(id); } @@ -312,7 +313,6 @@ LIB3270_EXPORT void lib3270_update_poll_fd(int fd, LIB3270_IO_FLAG flag) } - LIB3270_EXPORT void * lib3270_add_poll_fd(H3270 *session, int fd, LIB3270_IO_FLAG flag, void(*call)(H3270 *, int, LIB3270_IO_FLAG, void *), void *userdata ) { return add_poll(session,fd,flag,call,userdata); } @@ -626,21 +626,19 @@ void RemoveTimeOut(void * timer) void x_except_on(H3270 *h) { - if(h->excepting) + int reading = (h->ns_read_id != NULL); + + if(h->ns_exception_id) return; - if(h->reading) + if(reading) lib3270_remove_poll(h->ns_read_id); h->ns_exception_id = lib3270_add_poll_fd(h,h->sock,LIB3270_IO_FLAG_EXCEPTION,net_exception,0); -// h->ns_exception_id = AddExcept(h->sock, h, net_exception); - - h->excepting = 1; - if(h->reading) + if(reading) h->ns_read_id = lib3270_add_poll_fd(h,h->sock,LIB3270_IO_FLAG_READ,net_input,0); -// h->ns_read_id = AddInput(h->sock, h, net_input); } void remove_input_calls(H3270 *session) @@ -649,19 +647,16 @@ void remove_input_calls(H3270 *session) { lib3270_remove_poll(session->ns_read_id); session->ns_read_id = NULL; - session->reading = 0; } if(session->ns_exception_id) { lib3270_remove_poll(session->ns_exception_id); session->ns_exception_id = NULL; - session->excepting = 0; } if(session->ns_write_id) { lib3270_remove_poll(session->ns_write_id); session->ns_write_id = NULL; - session->writing = 0; } } diff --git a/telnet.c b/telnet.c index 785febb..b761960 100644 --- a/telnet.c +++ b/telnet.c @@ -1959,11 +1959,10 @@ void net_exception(H3270 *session, int fd, LIB3270_IO_FLAG flag, void *dunno) { session->syncing = 1; - if(session->excepting) + if(session->ns_exception_id) { lib3270_remove_poll(session->ns_exception_id); session->ns_exception_id = NULL; - session->excepting = 0; } } } -- libgit2 0.21.2