commit 66a3d98ab98b546a4f1a6d4a41f5a4aefca578e0
parent a4c81cb8f199af385920f71ea1d0ce7df8ae1c2c
Author: Anselm R. Garbe <garbeam@wmii.de>
Date: Tue, 7 Feb 2006 12:27:38 +0100
proceeded
Diffstat:
6 files changed, 61 insertions(+), 12 deletions(-)
diff --git a/cmd/wm/fs.c b/cmd/wm/fs.c
@@ -994,7 +994,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 = ixp_server_dequeue_fcall(c, TREAD))) {
+ while((fcall = ixp_server_dequeue_fcall_id(c, TREAD))) {
IXPMap *m = ixp_server_fid2map(c, fcall->fid);
unsigned char *p = fcall->data;
diff --git a/cmd/wmiibar.c b/cmd/wmiibar.c
@@ -765,7 +765,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 = ixp_server_dequeue_fcall(c, TREAD))) {
+ while((fcall = ixp_server_dequeue_fcall_id(c, TREAD))) {
IXPMap *m = ixp_server_fid2map(c, fcall->fid);
unsigned char *p = fcall->data;
diff --git a/cmd/wmiifs.c b/cmd/wmiifs.c
@@ -39,6 +39,7 @@ static IXPServer srv;
static Mount **mount = nil;
static size_t mountsz = 0;
static size_t nmount = 0;
+static unsigned short tag = 0;
static unsigned char *msg[IXP_MAX_MSG];
static void rx_fcall(IXPConn *c);
@@ -218,7 +219,6 @@ mkqid(Qid *dir, char *wname, Qid *new, Bool iswalk)
static char *
xwalk(IXPConn *c, Fcall *fcall)
{
- static unsigned short tag = 0;
unsigned short nwqid = 0;
Qid dir = root_qid;
IXPMap *m;
@@ -248,6 +248,7 @@ xwalk(IXPConn *c, Fcall *fcall)
xclose_mount(mnt->respond);
return Enofile;
}
+ /* message will be received by mnt->respond */
ixp_server_enqueue_fcall(mnt->respond, fcall);
return nil;
}
@@ -277,19 +278,51 @@ xwalk(IXPConn *c, Fcall *fcall)
return nil;
}
+static Mount *
+map2mount(IXPMap *m)
+{
+ unsigned short id;
+ int i;
+ if((id = qpath_id(m->qid.path))) { /* remote */
+ i = index_of_id(id);
+ if((i >= 0) && (i < nmount))
+ return mount[i];
+ }
+ return nil;
+}
+
static char *
xopen(IXPConn *c, Fcall *fcall)
{
IXPMap *m = ixp_server_fid2map(c, fcall->fid);
+ Mount *mnt;
if(!m)
return Enofid;
- if(!(fcall->mode | IXP_OREAD) && !(fcall->mode | IXP_OWRITE))
- return Enomode;
- fcall->id = ROPEN;
- fcall->qid = m->qid;
- fcall->iounit = 2048;
- ixp_server_respond_fcall(c, fcall);
+ if((mnt = map2mount(m))) { /* remote */
+ unsigned int msize;
+ ixp_fcall_to_msg(fcall, msg, IXP_MAX_MSG);
+ ixp_msg_to_fcall(msg, IXP_MAX_MSG, &mnt->client.fcall);
+ fcall->tag = mnt->client.fcall.tag = tag++;
+
+ msize = ixp_fcall_to_msg(&mnt->client.fcall, msg, IXP_MAX_MSG);
+ mnt->client.errstr = 0;
+ if(ixp_send_message(mnt->client.fd, msg, msize, &mnt->client.errstr) != msize) {
+ xclose_mount(mnt->respond);
+ return Enofile;
+ }
+ /* message will be received by mnt->respond */
+ ixp_server_enqueue_fcall(mnt->respond, fcall);
+ return nil;
+ }
+ else { /* local */
+ if(!(fcall->mode | IXP_OREAD) && !(fcall->mode | IXP_OWRITE))
+ return Enomode;
+ fcall->id = ROPEN;
+ fcall->qid = m->qid;
+ fcall->iounit = 2048;
+ ixp_server_respond_fcall(c, fcall);
+ }
return nil;
}
diff --git a/libixp/ixp.h b/libixp/ixp.h
@@ -289,7 +289,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);
+Fcall *ixp_server_dequeue_fcall_tag(IXPConn *c, unsigned short tag);
+Fcall *ixp_server_dequeue_fcall_id(IXPConn *c, unsigned char id);
void ixp_server_close(IXPServer *s);
/* socket.c */
diff --git a/libixp/server.c b/libixp/server.c
@@ -119,7 +119,22 @@ ixp_server_enqueue_fcall(IXPConn *c, Fcall *fcall)
}
Fcall *
-ixp_server_dequeue_fcall(IXPConn *c, unsigned short id)
+ixp_server_dequeue_fcall_tag(IXPConn *c, unsigned short tag)
+{
+ Fcall *fcall = nil;
+ size_t i;
+ for(i = 0; (i < c->pendsz) && c->pend[i]; i++)
+ if(c->pend[i]->tag == tag) {
+ fcall = c->pend[i];
+ cext_array_detach((void **)c->pend, fcall, &c->pendsz);
+ break;
+ }
+ /* free it */
+ return fcall;
+}
+
+Fcall *
+ixp_server_dequeue_fcall_id(IXPConn *c, unsigned char id)
{
Fcall *fcall = nil;
size_t i;
diff --git a/rc/wmiirc b/rc/wmiirc
@@ -143,5 +143,5 @@ normstyle /menu/nstyle >[2]/dev/null
selstyle /menu/sstyle >[2]/dev/null
# MISC
-xsetroot -mod 2 2 -bg \#666699 -fg \#888888
+xsetroot -mod 2 2 -bg \#555588 -fg \#666666
status&