Commit 7af2aa4b6f0fe1b04f6724d485669ed695faa191
1 parent
67a39a85
Exists in
master
and in
1 other branch
Fixing enable/disable of polling on linux.
Showing
3 changed files
with
32 additions
and
10 deletions
Show diff stats
src/v3270/iocallback.c
| ... | ... | @@ -64,9 +64,10 @@ static void static_RemoveSource(G_GNUC_UNUSED H3270 *session, void *id) |
| 64 | 64 | g_source_destroy((GSource *) id); |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | -static void static_SetSourceState(G_GNUC_UNUSED H3270 *session, G_GNUC_UNUSED void *id, G_GNUC_UNUSED int enabled) | |
| 67 | +static void static_SetSourceState(G_GNUC_UNUSED H3270 *session, void *id, int enabled) | |
| 68 | 68 | { |
| 69 | - | |
| 69 | + if(id) | |
| 70 | + IO_source_set_state( (GSource *) id, (gboolean) (enabled != 0)); | |
| 70 | 71 | } |
| 71 | 72 | |
| 72 | 73 | static gboolean do_timer(TIMER *t) |
| ... | ... | @@ -143,13 +144,12 @@ gpointer BgCall(struct bgParameter *p) |
| 143 | 144 | |
| 144 | 145 | static int static_RunTask(H3270 *hSession, int(*callback)(H3270 *, void *), void *parm) |
| 145 | 146 | { |
| 147 | + struct bgParameter p = { TRUE, hSession, -1, callback, parm }; | |
| 148 | + | |
| 146 | 149 | trace("%s starts -------------------------------------", __FUNCTION__); |
| 147 | 150 | |
| 148 | - int rc = callback(hSession,parm); | |
| 151 | +// p.rc = callback(hSession,parm); | |
| 149 | 152 | |
| 150 | - trace("%s ends ---------------------------------------", __FUNCTION__); | |
| 151 | - /* | |
| 152 | - struct bgParameter p = { TRUE, hSession, -1, callback, parm }; | |
| 153 | 153 | |
| 154 | 154 | p.running = TRUE; |
| 155 | 155 | |
| ... | ... | @@ -168,10 +168,9 @@ static int static_RunTask(H3270 *hSession, int(*callback)(H3270 *, void *), void |
| 168 | 168 | |
| 169 | 169 | g_thread_join(thread); |
| 170 | 170 | |
| 171 | - return p.rc; | |
| 172 | - */ | |
| 171 | + trace("%s ends ---------------------------------------", __FUNCTION__); | |
| 173 | 172 | |
| 174 | - return rc; | |
| 173 | + return p.rc; | |
| 175 | 174 | } |
| 176 | 175 | |
| 177 | 176 | void v3270_register_io_handlers(G_GNUC_UNUSED v3270Class *cls) | ... | ... |
src/v3270/linux/iosource.c
| ... | ... | @@ -28,6 +28,8 @@ |
| 28 | 28 | */ |
| 29 | 29 | |
| 30 | 30 | #include <config.h> |
| 31 | + #include <lib3270.h> | |
| 32 | + #include <lib3270/log.h> | |
| 31 | 33 | #include <poll.h> |
| 32 | 34 | #include "../private.h" |
| 33 | 35 | |
| ... | ... | @@ -81,12 +83,32 @@ GSource * IO_source_new(H3270 *session, int fd, LIB3270_IO_FLAG flag, void(*call |
| 81 | 83 | if(flag & LIB3270_IO_FLAG_WRITE) |
| 82 | 84 | src->poll.events |= G_IO_OUT; |
| 83 | 85 | |
| 86 | + IO_source_set_state((GSource *) src, TRUE); | |
| 87 | + | |
| 84 | 88 | g_source_attach((GSource *) src,NULL); |
| 85 | - g_source_add_poll((GSource *) src,&src->poll); | |
| 89 | + g_source_add_poll((GSource *) src, &((IO_Source *)src)->poll); | |
| 86 | 90 | |
| 87 | 91 | return (GSource *) src; |
| 88 | 92 | } |
| 89 | 93 | |
| 94 | +G_GNUC_INTERNAL void IO_source_set_state(GSource *source, gboolean enable) | |
| 95 | +{ | |
| 96 | + ((IO_Source *)source)->enabled = enable; | |
| 97 | + | |
| 98 | + /* | |
| 99 | + if(enable) | |
| 100 | + { | |
| 101 | + trace("Polling %d was enabled",((IO_Source *)source)->poll.fd); | |
| 102 | + g_source_add_poll((GSource *) source,&((IO_Source *)source)->poll); | |
| 103 | + } | |
| 104 | + else | |
| 105 | + { | |
| 106 | + trace("Polling of %d was disabled",((IO_Source *)source)->poll.fd); | |
| 107 | + g_source_remove_poll((GSource *) source,&((IO_Source *)source)->poll); | |
| 108 | + } | |
| 109 | + */ | |
| 110 | +} | |
| 111 | + | |
| 90 | 112 | |
| 91 | 113 | gboolean IO_prepare(G_GNUC_UNUSED GSource *source, G_GNUC_UNUSED gint *timeout) |
| 92 | 114 | { | ... | ... |
src/v3270/private.h
| ... | ... | @@ -356,5 +356,6 @@ G_GNUC_INTERNAL const struct v3270_ssl_status_msg * v3270_get_ssl_status_msg(Gtk |
| 356 | 356 | |
| 357 | 357 | // I/O Callbacks |
| 358 | 358 | 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); |
| 359 | +G_GNUC_INTERNAL void IO_source_set_state(GSource *source, gboolean enable); | |
| 359 | 360 | |
| 360 | 361 | G_END_DECLS | ... | ... |