Re: Using dead notification with mach ports
This is where you went astray. The clients wouldn't look the new message queue up in some global namespace, but instead it would be returned to them (privately) as part of the reply to this "connection request" RPC. So now the server does the following fo each new client in the "connection request" RPC. mach_port_t task = mach_task_self(); mach_port_t old_port; mach_port_allocate(task,MACH_PORT_RIGHT_RECEIVE,&clientPort) mach_port_move_member(task,clientPort,serverPort) mach_port_request_notification(task, clientPort, MACH_NOTIFY_NO_SENDERS, 1, serverPort, MACH_MSG_TYPE_MAKE_SEND_ONCE,&old_port); where serverPort will be used by the server in the mach_msg_server. Then clientPort has to be sent back to the client, how is this done? Only by sending the clientPort back? Or the client needs to get a copy of send right to that clientPort Mach message queue alloccated by the server? Sorry, I sent that early by mistake.... Here's an example MIG definition that assumes the latter approach: routine StephaneConnectToServer ( serverPort : mach_port_t; connectFlags : integer_t; out semaphorePort: semaphore_t; out connectionPort: mach_port_make_send_t ); Hope that helps, --Jim _______________________________________________ darwin-development mailing list | darwin-development@lists.apple.com Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/darwin-development Do not post admin requests to the list. They will be ignored. On Sep 11, 2004, at 9:36 AM, Jim Magee wrote: On Sep 11, 2004, at 4:55 AM, Stiphane LETZ wrote: 4) client get this new private port from the server (same method as 2 ) mach_port_insert_right (task,clientPort,clientPort,MACH_MSG_TYPE_MAKE_SEND) I'm quite confused... Anyway, one of the 2 or 3 primary advantages of Mach IPC over other forms is the flexibility in passing other port rights in messages. Since it appears you are using MIG, you simply have to declare an "out" parameter (or two, if you count sending the semaphore as well) of type mach_port_t. That will arrange to have send rights transfered to the client (copied, to be explicit). But for the no-senders notification to fire, the server can't hold its own send right to that port (and you have given the server a send right with the mach_port_insert_right() call above). Instead, it must "move" the send right it created to the client. You can do this in one of two ways: You can declare the "out" parameter as type "mach_port_move_send_t" in the MIG definition or You could declare it of type "mach_port_make_send_t" and skip the call to mach_port_insert_right() altogether
participants (1)
-
Jim Magee