Enlightenment CVS committal Author : kwo Project : e16 Module : e
Dir : e16/e/eesh Modified Files: E.h comms.c main.c Log Message: Fix bad event loop causing hangs in certain situations. Always wait for ack (also with -e), otherwise the message could get lost. =================================================================== RCS file: /cvs/e/e16/e/eesh/E.h,v retrieving revision 1.25 retrieving revision 1.26 diff -u -3 -r1.25 -r1.26 --- E.h 17 Jan 2007 01:10:40 -0000 1.25 +++ E.h 29 Sep 2007 16:39:33 -0000 1.26 @@ -44,7 +44,8 @@ char *msg; } Client; -Window CommsSetup(void); +void CommsInit(void); +Window CommsSetup(Window win); Window CommsFindCommsWindow(void); void CommsSend(Client * c, const char *s); char *CommsGet(Client * c, XEvent * ev); =================================================================== RCS file: /cvs/e/e16/e/eesh/comms.c,v retrieving revision 1.17 retrieving revision 1.18 diff -u -3 -r1.17 -r1.18 --- comms.c 17 Jan 2007 01:10:40 -0000 1.17 +++ comms.c 29 Sep 2007 16:39:33 -0000 1.18 @@ -27,14 +27,19 @@ static Window root_win; static Window my_win; -Window -CommsSetup(void) +void +CommsInit(void) { char *str; - XSetWindowAttributes attr; str = getenv("ENL_WM_ROOT"); root_win = (str) ? strtoul(str, NULL, 0) : DefaultRootWindow(disp); +} + +Window +CommsSetup(Window win __UNUSED__) +{ + XSetWindowAttributes attr; attr.override_redirect = False; my_win = XCreateWindow(disp, root_win, -100, -100, 5, 5, 0, 0, InputOnly, @@ -128,7 +133,7 @@ CommsGet(Client * c, XEvent * ev) { char s[13], s2[9], *msg; - int i; + unsigned int i; Window win; if ((!ev) || (!c)) @@ -147,24 +152,14 @@ sscanf(s2, "%lx", &win); - if (c->msg) - { - /* append text to end of msg */ - c->msg = EREALLOC(char, c->msg, strlen(c->msg) + strlen(s) + 1); + /* append text to end of msg */ + i = (c->msg) ? strlen(c->msg) : 0; + c->msg = EREALLOC(char, c->msg, i + strlen(s) + 1); - if (!c->msg) - return NULL; - strcat(c->msg, s); - } - else - { - /* new msg */ - c->msg = EMALLOC(char, strlen(s) + 1); + if (!c->msg) + return NULL; + strcpy(c->msg + i, s); - if (!c->msg) - return NULL; - strcpy(c->msg, s); - } if (strlen(s) < 12) { msg = c->msg; =================================================================== RCS file: /cvs/e/e16/e/eesh/main.c,v retrieving revision 1.25 retrieving revision 1.26 diff -u -3 -r1.25 -r1.26 --- main.c 8 Apr 2007 19:19:15 -0000 1.25 +++ main.c 29 Sep 2007 16:39:33 -0000 1.26 @@ -21,7 +21,6 @@ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - #include "E.h" /* Global vars */ @@ -149,14 +148,15 @@ exit(1); } - my_win = CommsSetup(); + CommsInit(); comms_win = CommsFindCommsWindow(); + my_win = CommsSetup(comms_win); e = ClientCreate(comms_win); me = ClientCreate(my_win); CommsSend(e, "set clientname eesh"); - CommsSend(e, "set version 0.1"); + CommsSend(e, "set version 0.2"); #if 0 /* Speed it up */ CommsSend(e, "set author The Rasterman"); CommsSend(e, "set email [EMAIL PROTECTED]"); @@ -187,8 +187,10 @@ /* Non-interactive */ CommsSend(e, command); XSync(disp, False); +#if 0 /* No - Wait for ack */ if (mode <= 0) goto done; +#endif } else { @@ -199,6 +201,28 @@ for (;;) { + XSync(disp, False); + while (XPending(disp)) + { + XNextEvent(disp, &ev); + switch (ev.type) + { + case ClientMessage: + s = CommsGet(me, &ev); + if (!s) + break; + if (*s) + printf("%s", s); + fflush(stdout); + Efree(s); + if (mode) + goto done; + break; + case DestroyNotify: + goto done; + } + } + FD_ZERO(&fd); if (!command) FD_SET(0, &fd); @@ -207,35 +231,9 @@ if (select(ConnectionNumber(disp) + 1, &fd, NULL, NULL, NULL) < 0) break; - XSync(disp, False); - if (FD_ISSET(0, &fd)) { stdin_read(); - } - else if (FD_ISSET(ConnectionNumber(disp), &fd)) - { - while (XPending(disp)) - { - XNextEvent(disp, &ev); - switch (ev.type) - { - case ClientMessage: - s = CommsGet(me, &ev); - if (!s) - break; - if (*s) - printf("%s", s); - fflush(stdout); - Efree(s); - if (mode) - goto done; - break; - case DestroyNotify: - goto done; - } - } - XSync(disp, False); } } ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs