Re: named ports - trivfs translator!

2001-06-04 Thread Marcus Brinkmann

On Mon, Jun 04, 2001 at 02:44:22AM +0200, Johan Rydberg wrote:
  The canonical way to do it on the Hurd is to attach the server to some node
  in the filesystem, that means, you write a translator which you attach with
  settrans, or you write a program that installs itself as a translator
  somewhere. libtrivfs helps a lot for that.  (For the latter, see how pfinet
  installs the tunnel device in pfinet/tunnel.c (setup_tunnel_device).
 
 I went with the latter and it seems to work.  Thanks.  Next question:

Note that if you do this, you hard code the file name in the program.  It is
preferable to use the default translator mechanism, where the program is
invoked as a translator with the bootstrap port set.  This is what we expect
from Hurd programs anyway.  Just something to remember if you go from the
testing stage to production quality ;)

 Take a look at the following scenario:
 
   1. allocate object
   2. client does something with object
   3. deallocate object
 
 I have created a port class with a custom clean routine.  I want the clean
 routine to be called if the object are NOT deallocated in step 3 (for example, 
 the client dies).  Is this possible - or do I have hold an internal state for
 every port?

AFAICS, the clean routine is always called if the port is deallocated, and
this happens automatically by the kernel if the task is destroyed.  If you
represent the resource as a port, it will be deallocated automatically. 
There is no way for the user to avoid that except staying alive forever.
If you want the user to keep a port and still deallocate the resource, then
you will have to implement this yourself, and check it in the clean routine. 
I believe this is what you mean with the internal state.

I am not that experienced in Mach IPC, maybe there is a way to do what you
want without having another variable.  This would involve the notify server
interface in Mach.  However, I would advise to stick with Hurds libports
(probably extending it if necessary).

Thanks,
Marcus


-- 
`Rhubarb is no Egyptian god.' Debian http://www.debian.org [EMAIL PROTECTED]
Marcus Brinkmann  GNUhttp://www.gnu.org[EMAIL PROTECTED]
[EMAIL PROTECTED]
http://www.marcus-brinkmann.de

___
Help-hurd mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/help-hurd



Re: named ports - trivfs translator!

2001-06-03 Thread Marcus Brinkmann

On Sat, Jun 02, 2001 at 06:43:37PM +0200, Johan Rydberg wrote:
 
 Hi!
 
 I'm thinking about implementing a small server.  What is
 the easiest way for a client to get the mach-port for the
 server?  

You can advertise your msg port to the proc server with the proc_setmsgport
RPC (send it to the port you get with getproc() from libc).  Then a client
can get the port with the proc_getmsgport RPC (requires the PID of the
server process).  This is a bit like the Mach nameserver, except you access
by PID rather than some name.

The canonical way to do it on the Hurd is to attach the server to some node
in the filesystem, that means, you write a translator which you attach with
settrans, or you write a program that installs itself as a translator
somewhere. libtrivfs helps a lot for that.  (For the latter, see how pfinet
installs the tunnel device in pfinet/tunnel.c (setup_tunnel_device).

Thanks,
Marcus

-- 
`Rhubarb is no Egyptian god.' Debian http://www.debian.org [EMAIL PROTECTED]
Marcus Brinkmann  GNUhttp://www.gnu.org[EMAIL PROTECTED]
[EMAIL PROTECTED]
http://www.marcus-brinkmann.de

___
Help-hurd mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/help-hurd



Re: named ports - trivfs translator!

2001-06-03 Thread Johan Rydberg

Marcus Brinkmann wrote:

 The canonical way to do it on the Hurd is to attach the server to some node
 in the filesystem, that means, you write a translator which you attach with
 settrans, or you write a program that installs itself as a translator
 somewhere. libtrivfs helps a lot for that.  (For the latter, see how pfinet
 installs the tunnel device in pfinet/tunnel.c (setup_tunnel_device).

I went with the latter and it seems to work.  Thanks.  Next question:

Take a look at the following scenario:

  1. allocate object
  2. client does something with object
  3. deallocate object

I have created a port class with a custom clean routine.  I want the clean
routine to be called if the object are NOT deallocated in step 3 (for example, 
the client dies).  Is this possible - or do I have hold an internal state for
every port?

regards,
johan


-- 
Johan Rydberg, Net Insight AB, Sweden, +46-8-685 04 00

$ ON F$ERROR(LANGUAGE,ENGLISH,IN_MESSAGE).GT.F$ERROR(NORMAL) -
 THEN EXCUSE/OBJECT=ME

___
Help-hurd mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/help-hurd