bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

ipc works only in one direction


From: Frank Saar
Subject: ipc works only in one direction
Date: Mon, 16 Dec 2002 05:37:46 -0800

Hello,
I have again some problems with translators.
I have the following mig definition

subsystem test 500;
#include <hurd/hurd_types.defs>
routine get_random(
        server: mach_port_t;
        inout num: int );

Given the inout  I am able to see any given value from the client on the
server side. So the client is able to find the server and it is able to
transfer any messages. Well, fine one direction works. The problem is that
any modification on the server side doesnt have any effect on the second
parameter. I dont see any changes on the client side which were made on the
server side.
Well its quite obvious that the messge that I get should tell me that:bad
request message id -303. I attached gdb to the server and saw that the
serverĀ“s get_random is called and that the server returns
KERN_STATUS_SUCCESS. Having attached gdb also to the client I saw that the
lines in the Usercode that describe the error are the following:

excerpt of the user stub code:

        msg_result = mach_msg(&InP->Head,
MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 24, sizeof(Reply),
InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL);
        if (msg_result != MACH_MSG_SUCCESS) {
                mig_dealloc_reply_port(InP->Head.msgh_reply_port);
                return msg_result;
        }
        mig_put_reply_port(InP->Head.msgh_reply_port);

        if (OutP->Head.msgh_id != 600) {
                ....
        }

        if (OutP->RetCode != KERN_SUCCESS)  <------------------------ exits here
                return OutP->RetCode;

Right after the request has been send the client tries to send a reply to
the server. And as I see it,it is this reply (msgid=600) which never reaches
the server. But in the server stub code I dont find any code which could
handle this reply (well there must be some for this somewhere). I also
looked in the password servers user stub code (had to enable this, since
this code isnt generated by default). But this code looked pretty much like
my code. So I dont think the error doesnt lie neither in the stub code nor
in any special mig parameter.

I dont find the cause. I studied the mach3 server writers guide and in it I
found a similar sample:

mig definition:
routine getbalance{
    server:    mach_port_t;
    out balance:    int
)

server:
kern_return_t getbalance(mach_port_t server,int *blance)
    *balance=server_blance;
    return KERN_SUCCESS;
}

Well this looks pretty much as I have it. But well, my sample doesnt work. I
tried different things:
Since the direction to the server worked given the in directive I tried it
with a pointer as a second paramenter to get_random and tried to allocate
some storage on the server side (calloc,static,mmap). But it did not work
either. Since there are several samples in the hurd code I looked at them
too. For example the password server. But I saw nothing in any .defs files
that could give me a hint. I saw that server server stubs are compiled with
the -sheader directive. But I think this is because there is no user stub
code needed. I also looked in the Makeconf for any special parameters. But
except the -subrprefix I didnt see any special flag. In think this flag is
given to the c compiler and because I dont get any errors during compiling I
dont think that this flag will help me.

So again I dont know what went wrong.
The code has been compiled with:
mig definition: mig test.defs
SERVER: $(CC) $(CCFLAGS) -o testserver testServer.c stest.c $(LIBS)

CLIENT $(CC) $(CCFLAGS) -o test testUser.c utest.c
The server is copied to /hurd/testserver
a link to this server has been established with: settrans -ac /test
/hurd/testserver

So since I spent already some time on this issue without making any progress
I would be very glad to hear from you.
thanks in advance,
Frank


Server Code:
<---------------------------------------------------------------------------
---------------
extern boolean_t test_server (mach_msg_header_t *InHeadP, mach_msg_header_t
*OutHeadP);

int trivfs_fstype = FSTYPE_MISC;
int trivfs_fsid = 0;
int trivfs_support_read = 0;
int trivfs_support_write = 0;
int trivfs_support_exec = 0;
int trivfs_allow_open = 0x00;
int trivfs_protid_nportclasses = 0;
int trivfs_cntl_nportclasses = 0;

kern_return_t get_random ( mach_port_t server, int *num)
{
        error(0,0,"server:get_random\n");
        *num=3;
        return KERN_SUCCESS;
}

int demuxer (mach_msg_header_t *inp, mach_msg_header_t *outp)
{
  return (test_server(inp,outp)|trivfs_demuxer(inp,outp));
}


void trivfs_modify_stat (struct trivfs_protid *cred, io_statbuf_t  *st)
{
}
error_t trivfs_goaway (struct trivfs_control *fsys, int flags)
{
  exit (0);
}

int main()
{
  error_t err;
  struct trivfs_control *fsys;
  mach_port_t bootstrap;


        task_get_bootstrap_port (mach_task_self (), &bootstrap);
                if (bootstrap == MACH_PORT_NULL) {
                                return (0);
                        }
  /* Reply to our parent */
  err = trivfs_startup (bootstrap, 0, 0, 0, 0, 0,&fsys);
                mach_port_deallocate (mach_task_self (), bootstrap);
                if (err)        {
                                return (0);
                        }
  /* Try to connect to server   */
        ports_manage_port_operations_one_thread (fsys->pi.bucket, demuxer, 0);
}

client code:
<---------------------------------------------------------------------------
---------------
int main() {
        int r;
        error_t err;
        mach_port_t server;
        server=file_name_lookup("/test",0,0);
        if (server==MACH_PORT_NULL) {
                error(1,err,"Couldnt open server port\n");
        }
        err=get_random(server,&r);
        printf("user:r:%d\n",r);
        if (err<0) {
                error(1,err,"get_random failed %d\n",err);
        }
        printf("user:r:%d\n",r);
        mach_port_deallocate(mach_task_self(),server);
        return (0);
}






reply via email to

[Prev in Thread] Current Thread [Next in Thread]