wmii

git clone git://oldgit.suckless.org/wmii/
Log | Files | Refs | README | LICENSE

commit bdbc256a1bf3517c01d87ddaabe8dcf795f59273
parent 3728e6420f91c308b552dba25d393d7f9378453b
Author: Anselm R. Garbe <garbeam@wmii.de>
Date:   Fri,  3 Feb 2006 17:42:59 +0200

fixed missing respond in xclunk of wmiibar, now proceeding with wm


Diffstat:
cmd/wmiibar.c | 20++++----------------
libixp/ixp.h | 2++
libixp/server.c | 26+++++++++++++++++++++++++-
3 files changed, 31 insertions(+), 17 deletions(-)

diff --git a/cmd/wmiibar.c b/cmd/wmiibar.c @@ -767,7 +767,8 @@ xclunk(IXPConn *c, Fcall *fcall) cext_array_detach((void **)c->map, m, &c->mapsz); free(m); fcall->id = RCLUNK; - return 0; + ixp_server_respond_fcall(c, fcall); + return nil; } static void @@ -795,16 +796,6 @@ do_fcall(IXPConn *c) } } -static Fcall * -pending(IXPConn *c, unsigned char id) -{ - size_t i; - for(i = 0; (i < c->pendsz) && c->pend[i]; i++) - if(c->pend[i]->id == id) - return c->pend[i]; - return nil; -} - static void do_pend_fcall(char *event) { @@ -813,7 +804,7 @@ do_pend_fcall(char *event) for(i = 0; (i < srv.connsz) && srv.conn[i]; i++) { IXPConn *c = srv.conn[i]; /* all pending TREADs are on /event, so no qid checking necessary */ - while((fcall = pending(c, TREAD))) { + while((fcall = ixp_server_dequeue_fcall(c, TREAD))) { IXPMap *m = ixp_server_fid2map(c, fcall->fid); unsigned char *p = fcall->data; @@ -828,7 +819,6 @@ do_pend_fcall(char *event) if(ixp_server_respond_fcall(c, fcall)) break; } - cext_array_detach((void **)c->pend, fcall, &c->pendsz); free(fcall); } } @@ -940,9 +930,7 @@ main(int argc, char *argv[]) fprintf(stderr, "wmiibar: fatal: %s\n", errstr); /* cleanup */ - for(i = 0; (i < srv.connsz) && srv.conn[i]; i++) - if(srv.conn[i]->close) - srv.conn[i]->close(srv.conn[i]); + ixp_server_close(&srv); XCloseDisplay(dpy); return errstr ? 1 : 0; diff --git a/libixp/ixp.h b/libixp/ixp.h @@ -288,6 +288,8 @@ void ixp_server_enqueue_fcall(IXPConn *c, Fcall *fcall); unsigned int ixp_server_receive_fcall(IXPConn *c, Fcall *fcall); int ixp_server_respond_fcall(IXPConn *c, Fcall *fcall); int ixp_server_respond_error(IXPConn *c, Fcall *fcall, char *errstr); +Fcall *ixp_server_dequeue_fcall(IXPConn *c, unsigned short id); +void ixp_server_close(IXPServer *s); /* socket.c */ int ixp_connect_sock(char *address); diff --git a/libixp/server.c b/libixp/server.c @@ -108,11 +108,26 @@ ixp_server_fid2map(IXPConn *c, unsigned int fid) return nil; } -void ixp_server_enqueue_fcall(IXPConn *c, Fcall *fcall) +void +ixp_server_enqueue_fcall(IXPConn *c, Fcall *fcall) { c->pend = (Fcall **)cext_array_attach((void **)c->pend, fcall, sizeof(Fcall *), &c->pendsz); } +Fcall * +ixp_server_dequeue_fcall(IXPConn *c, unsigned short id) +{ + Fcall *fcall = nil; + size_t i; + for(i = 0; (i < c->pendsz) && c->pend[i]; i++) + if(c->pend[i]->id == id) { + fcall = c->pend[i]; + cext_array_detach((void **)c->pend, fcall, &c->pendsz); + break; + } + return fcall; +} + unsigned int ixp_server_receive_fcall(IXPConn *c, Fcall *fcall) { @@ -153,3 +168,12 @@ ixp_server_respond_error(IXPConn *c, Fcall *fcall, char *errstr) } return 0; } + +void +ixp_server_close(IXPServer *s) +{ + size_t i; + for(i = 0; (i < s->connsz) && s->conn[i]; i++) + if(s->conn[i]->close) + s->conn[i]->close(s->conn[i]); +}