diff --git a/src/v3270/iocallback.c b/src/v3270/iocallback.c index 81ca8e0..2100bd9 100644 --- a/src/v3270/iocallback.c +++ b/src/v3270/iocallback.c @@ -64,9 +64,10 @@ static void static_RemoveSource(G_GNUC_UNUSED H3270 *session, void *id) g_source_destroy((GSource *) id); } -static void static_SetSourceState(G_GNUC_UNUSED H3270 *session, G_GNUC_UNUSED void *id, G_GNUC_UNUSED int enabled) +static void static_SetSourceState(G_GNUC_UNUSED H3270 *session, void *id, int enabled) { - + if(id) + IO_source_set_state( (GSource *) id, (gboolean) (enabled != 0)); } static gboolean do_timer(TIMER *t) @@ -143,13 +144,12 @@ gpointer BgCall(struct bgParameter *p) static int static_RunTask(H3270 *hSession, int(*callback)(H3270 *, void *), void *parm) { + struct bgParameter p = { TRUE, hSession, -1, callback, parm }; + trace("%s starts -------------------------------------", __FUNCTION__); - int rc = callback(hSession,parm); +// p.rc = callback(hSession,parm); - trace("%s ends ---------------------------------------", __FUNCTION__); - /* - struct bgParameter p = { TRUE, hSession, -1, callback, parm }; p.running = TRUE; @@ -168,10 +168,9 @@ static int static_RunTask(H3270 *hSession, int(*callback)(H3270 *, void *), void g_thread_join(thread); - return p.rc; - */ + trace("%s ends ---------------------------------------", __FUNCTION__); - return rc; + return p.rc; } void v3270_register_io_handlers(G_GNUC_UNUSED v3270Class *cls) diff --git a/src/v3270/linux/iosource.c b/src/v3270/linux/iosource.c index e08b7d8..6f6d4e2 100644 --- a/src/v3270/linux/iosource.c +++ b/src/v3270/linux/iosource.c @@ -28,6 +28,8 @@ */ #include + #include + #include #include #include "../private.h" @@ -81,12 +83,32 @@ GSource * IO_source_new(H3270 *session, int fd, LIB3270_IO_FLAG flag, void(*call if(flag & LIB3270_IO_FLAG_WRITE) src->poll.events |= G_IO_OUT; + IO_source_set_state((GSource *) src, TRUE); + g_source_attach((GSource *) src,NULL); - g_source_add_poll((GSource *) src,&src->poll); + g_source_add_poll((GSource *) src, &((IO_Source *)src)->poll); return (GSource *) src; } +G_GNUC_INTERNAL void IO_source_set_state(GSource *source, gboolean enable) +{ + ((IO_Source *)source)->enabled = enable; + + /* + if(enable) + { + trace("Polling %d was enabled",((IO_Source *)source)->poll.fd); + g_source_add_poll((GSource *) source,&((IO_Source *)source)->poll); + } + else + { + trace("Polling of %d was disabled",((IO_Source *)source)->poll.fd); + g_source_remove_poll((GSource *) source,&((IO_Source *)source)->poll); + } + */ +} + gboolean IO_prepare(G_GNUC_UNUSED GSource *source, G_GNUC_UNUSED gint *timeout) { diff --git a/src/v3270/private.h b/src/v3270/private.h index 8a43a12..ab41f54 100644 --- a/src/v3270/private.h +++ b/src/v3270/private.h @@ -356,5 +356,6 @@ G_GNUC_INTERNAL const struct v3270_ssl_status_msg * v3270_get_ssl_status_msg(Gtk // I/O Callbacks G_GNUC_INTERNAL GSource * IO_source_new(H3270 *session, int fd, LIB3270_IO_FLAG flag, void(*call)(H3270 *, int, LIB3270_IO_FLAG, void *), void *userdata); +G_GNUC_INTERNAL void IO_source_set_state(GSource *source, gboolean enable); G_END_DECLS -- libgit2 0.21.2