9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] why there is no srv->clunk in lib9p?
@ 2006-03-05 11:51 Gabriel Diaz
  2006-03-05 13:21 ` Russ Cox
  0 siblings, 1 reply; 2+ messages in thread
From: Gabriel Diaz @ 2006-03-05 11:51 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

[-- Attachment #1: Type: text/plain, Size: 261 bytes --]

Hello

why there is no srv->clunk in lib9p?

I see there is a sclunk in srv.c but it
doesn't call srv->clunk as the others
sfuncs there.

just putting

 if ( srv->clunk ) {
    srv->clunk(r);

   if( r->fid =removefid(srv-> ....

work, isn't it ?


thanks
gabi

[-- Attachment #2: Type: text/html, Size: 390 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [9fans] why there is no srv->clunk in lib9p?
  2006-03-05 11:51 [9fans] why there is no srv->clunk in lib9p? Gabriel Diaz
@ 2006-03-05 13:21 ` Russ Cox
  0 siblings, 0 replies; 2+ messages in thread
From: Russ Cox @ 2006-03-05 13:21 UTC (permalink / raw)
  To: 9fans

> why there is no srv->clunk in lib9p?

>From 9p(2):

          Destroyfid
               When a Fid's reference count drops to zero (i.e., it
               has been clunked and there are no outstanding requests
               referring to it), destroyfid is called to allow the
               program to dispose of the fid->aux pointer.

There is no srv->clunk because srv->destroyfid
takes its place.  Srv->destroyfid is called once the
fid's reference count drops to zero, which usually
happens as a result of a Tclunk message, but not always.

In regular a 9P conversation, Tclunk will drop the
last reference to a fid, but you can come up with
various cases where this is not true.  For example,
consider a fid where Tread takes a long time (perhaps
a pipe or /dev/cons or network connection).  What
if a client sent Tread and then without waiting for
the Rread, sent Tclunk.  If there were a clunk handler,
then presumably it would free whatever data structures
were associated with the fid.  But that memory is still
being used by the Tread.  Until all the requests that
reference the fid are done, it is not safe to free the
fid.

Russ



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-03-05 13:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-03-05 11:51 [9fans] why there is no srv->clunk in lib9p? Gabriel Diaz
2006-03-05 13:21 ` Russ Cox

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).