* [9fans] Fwd: lib9p: Add clunk callback to Srv struct [not found] <CAEDK68Ze=Di=8qQt1GOfkhq9nxb29=q=Z+AUuxzJouOT6_WeTg@mail.gmail.com> @ 2016-02-01 21:54 ` Tiago Natel 2016-02-01 22:03 ` cinap_lenrek 2016-02-01 22:42 ` Skip Tavakkolian 0 siblings, 2 replies; 7+ messages in thread From: Tiago Natel @ 2016-02-01 21:54 UTC (permalink / raw) To: Fans of the OS Plan 9 from Bell Labs [-- Attachment #1: Type: text/plain, Size: 967 bytes --] Someone here can help me? ---------- Forwarded message ---------- From: Tiago Natel <tiago.natel@neoway.com.br> Date: 2016-02-01 19:17 GMT-02:00 Subject: lib9p: Add clunk callback to Srv struct To: 9front@9front.org Hello folks, Is there a reason why lib9p doesn't have a clunk function pointer in Srv struct? I have a file server project using Srv and I want to know when no one client have a specific file opened. One way that I was able to get this working was forking 9front and adding a clunk callback to Srv structure. See the commit below: https://bitbucket.org/tiago4orion/plan9front/commits/5e1141f0a4aa98310cb0e2382c5c78c60fe73b4f My project usage of the clunk routine is here: https://bitbucket.org/tiago4orion/dchan/src/60dc3e45eb28c8a8289c177680120ef7f44e0925/fs.c?fileviewer=file-view-default#fs.c-680 This makes sense? Or is there better ways to achieve this? And if that makes sense, it can go upstream? Thanks. [-- Attachment #2: Type: text/html, Size: 1698 bytes --] ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [9fans] Fwd: lib9p: Add clunk callback to Srv struct 2016-02-01 21:54 ` [9fans] Fwd: lib9p: Add clunk callback to Srv struct Tiago Natel @ 2016-02-01 22:03 ` cinap_lenrek 2016-02-02 18:17 ` Tiago Natel 2016-02-01 22:42 ` Skip Tavakkolian 1 sibling, 1 reply; 7+ messages in thread From: cinap_lenrek @ 2016-02-01 22:03 UTC (permalink / raw) To: 9fans > Is there a reason why lib9p doesn't have a clunk function pointer in Srv struct? what about Srv.destroyfid()? 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. -- cinap ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [9fans] Fwd: lib9p: Add clunk callback to Srv struct 2016-02-01 22:03 ` cinap_lenrek @ 2016-02-02 18:17 ` Tiago Natel 2016-02-02 19:15 ` Skip Tavakkolian 2016-02-03 1:25 ` cinap_lenrek 0 siblings, 2 replies; 7+ messages in thread From: Tiago Natel @ 2016-02-02 18:17 UTC (permalink / raw) To: Fans of the OS Plan 9 from Bell Labs [-- Attachment #1: Type: text/plain, Size: 1665 bytes --] 2016-02-01 20:03 GMT-02:00 <cinap_lenrek@felloff.net>: > > Is there a reason why lib9p doesn't have a clunk function pointer in Srv > struct? > > what about Srv.destroyfid()? > > 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. > > Thanks for your help! I'd tried using destroyfid to achieve what I need but failed. I tried today again implement with destroyfid but realized that it will not fully support what I need. I'm using a file server for exchange data between 9P clients. When a new file is created, I create a plan9 channel and two threads (one for handle reads and other for writes), a write(2) to the file is translated into a sendp and a read(2) is translated into a recvp on the channel. The channel could be buffered or not, and then I want to maintain data allocated (aux related data) anyway, because the file server is a queueing system when channel have a buffer bigger than zero. Apart from that, I want to know how many clients have each file opened to update my stats file. It's possible in any way without a clunk callback? I'm trying to replace a rabbitmq server with this system, but I have a requirement for some way of monitoring of queues size, performance of channels, number of clients connected to each channel (file on dchan), etc, I need this kind of information for make a comparison with the current queue system... Thanks! -- > cinap > > [-- Attachment #2: Type: text/html, Size: 2311 bytes --] ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [9fans] Fwd: lib9p: Add clunk callback to Srv struct 2016-02-02 18:17 ` Tiago Natel @ 2016-02-02 19:15 ` Skip Tavakkolian 2016-02-03 1:25 ` cinap_lenrek 1 sibling, 0 replies; 7+ messages in thread From: Skip Tavakkolian @ 2016-02-02 19:15 UTC (permalink / raw) To: Fans of the OS Plan 9 from Bell Labs [-- Attachment #1: Type: text/plain, Size: 1859 bytes --] i'd recommend studying 9pserve.c in plan9port. On Tue, Feb 2, 2016 at 10:17 AM Tiago Natel <tiago.natel@neoway.com.br> wrote: > 2016-02-01 20:03 GMT-02:00 <cinap_lenrek@felloff.net>: > >> > Is there a reason why lib9p doesn't have a clunk function pointer in >> Srv struct? >> >> what about Srv.destroyfid()? >> >> 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. >> >> > Thanks for your help! I'd tried using destroyfid to achieve what I need > but failed. I tried today again implement with destroyfid but realized that > it will not fully support what I need. > > I'm using a file server for exchange data between 9P clients. When a new > file is created, I create a plan9 channel and two threads (one for handle > reads and other for writes), a write(2) to the file is translated into a > sendp and a read(2) is translated into a recvp on the channel. The channel > could be buffered or not, and then I want to maintain data allocated (aux > related data) anyway, because the file server is a queueing system when > channel have a buffer bigger than zero. > > Apart from that, I want to know how many clients have each file opened to > update my stats file. It's possible in any way without a clunk callback? > > I'm trying to replace a rabbitmq server with this system, but I have a > requirement for some way of monitoring of queues size, performance of > channels, number of clients connected to each channel (file on dchan), etc, > I need this kind of information for make a comparison with the current > queue system... > > Thanks! > > -- >> cinap >> >> [-- Attachment #2: Type: text/html, Size: 2833 bytes --] ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [9fans] Fwd: lib9p: Add clunk callback to Srv struct 2016-02-02 18:17 ` Tiago Natel 2016-02-02 19:15 ` Skip Tavakkolian @ 2016-02-03 1:25 ` cinap_lenrek 2016-02-03 11:53 ` Tiago Natel 1 sibling, 1 reply; 7+ messages in thread From: cinap_lenrek @ 2016-02-03 1:25 UTC (permalink / raw) To: 9fans > I'm using a file server for exchange data between 9P clients. When a new > file is created, I create a plan9 channel and two threads (one for handle > reads and other for writes), a write(2) to the file is translated into a > sendp and a read(2) is translated into a recvp on the channel. The channel > could be buffered or not, and then I want to maintain data allocated (aux > related data) anyway, because the file server is a queueing system when > channel have a buffer bigger than zero. It is hard to say without seeing the code, but this construction sounds wrong as recvp() in Srv.read would block the 9p read loop causing you to not process any other 9p requests when one client is blocked in a read. You also want to handle flushes otherwise you cannot interrupt/cancel the blocked read. You can handle this by chaining the Req's that you cannot satisfy immidiately in a linked list and respond to them from some other proc or thread once you have data the client could read. What do you mean by client? You could have multiple Srv's with each client having its own network connection to it. Or it could mean multiple attaches (mounts) and a single Srv. Or you it could mean you mean *someone* reading the file and the state about a "Client" is in the Fid. Anyway, it sounds like the problem you'r having with destroyfid() is that it doenst give you access to information whoever is the client of the file closed no? -- cinap ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [9fans] Fwd: lib9p: Add clunk callback to Srv struct 2016-02-03 1:25 ` cinap_lenrek @ 2016-02-03 11:53 ` Tiago Natel 0 siblings, 0 replies; 7+ messages in thread From: Tiago Natel @ 2016-02-03 11:53 UTC (permalink / raw) To: Fans of the OS Plan 9 from Bell Labs [-- Attachment #1: Type: text/plain, Size: 3080 bytes --] 2016-02-02 23:25 GMT-02:00 <cinap_lenrek@felloff.net>: > > > It is hard to say without seeing the code, but this construction sounds > wrong > as recvp() in Srv.read would block the 9p read loop causing you to > not process any other 9p requests when one client is blocked in a read. > You also want to handle flushes otherwise you cannot interrupt/cancel > the blocked read. You can handle this by chaining the Req's that you > cannot satisfy immidiately in a linked list and respond to them from some > other proc or thread once you have data the client could read. > Source code: hg clone https://bitbucket.org/tiago4orion/dchan Well, I'm doing a lot of tests with simultaneous access and everything 'appears' to works as expected. I'm using threadlistensrv/threadpostmountsrv to handle each new 9P connection in a separate thread. When a new client creates a file, the file server creates a Channel and two additional threads (one for block the reads, and one for block the writes) that will enqueue (reqqueuepush) the related requests. See here: Create a new file (or dchan channel): fs.c:497,507 When someone attempts to write to this file: fs.c:/^fswrite The request will be enqueued in the f->aux->wq (Reqqueue*) executing the function syncwrite on the writer thread of this file. The fs.c:/^syncwrite will send the r->ifcall.data in the channel associated with the file (f->aux->chan) and it will block the writer thread (of this specific file) until someother 9P client attempts to read the file. The read is similar, but happens in the syncread function. That way I'm able to create multiple clients: plan9: cpu% mount -c /srv/dchan /n/dchan Linux: # mount -t 9p -o port=6666 ip.of.dchan /n/dchan # cd /n/dchan # touch pipeline The command above will create two associated with this specific file. # cat pipeline The command above will block in the recvp call in the reader thread of this file, until someone writes something in it. cpu% cd /n/dchan cpu% ls ctl stats pipeline cpu% echo AAAAAAAAAAAAA >> pipeline The command above will issue a sendp in the same channel on the writer thread. The linux box will receive (recvp) the data and block in the next read(2). That's the workflow. > > What do you mean by client? By client I mean a 9P connection: mount -c /srv/dchan /n/dchan > You could have multiple Srv's with each > client having its own network connection to it. I'm using thread*srv function to achieve this. It's correct, isn't? > Or it could mean multiple > attaches (mounts) and a single Srv. Or you it could mean you mean *someone* > reading the file and the state about a "Client" is in the Fid. Anyway, > it sounds like the problem you'r having with destroyfid() is that it doenst > give you access to information whoever is the client of the file closed no? > Yes, I don't know if I understodd what you mean, but yeah, I need the information when someone closed the file (stopped reading the Channel). Thanks > > -- > cinap > > [-- Attachment #2: Type: text/html, Size: 4798 bytes --] ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [9fans] Fwd: lib9p: Add clunk callback to Srv struct 2016-02-01 21:54 ` [9fans] Fwd: lib9p: Add clunk callback to Srv struct Tiago Natel 2016-02-01 22:03 ` cinap_lenrek @ 2016-02-01 22:42 ` Skip Tavakkolian 1 sibling, 0 replies; 7+ messages in thread From: Skip Tavakkolian @ 2016-02-01 22:42 UTC (permalink / raw) To: 9fans > I have a file server project using Srv and I want to know when no one > client have a specific file opened. i believe since you're using alloctree and passing in the destroy function, you don't need it. ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2016-02-03 11:53 UTC | newest] Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- [not found] <CAEDK68Ze=Di=8qQt1GOfkhq9nxb29=q=Z+AUuxzJouOT6_WeTg@mail.gmail.com> 2016-02-01 21:54 ` [9fans] Fwd: lib9p: Add clunk callback to Srv struct Tiago Natel 2016-02-01 22:03 ` cinap_lenrek 2016-02-02 18:17 ` Tiago Natel 2016-02-02 19:15 ` Skip Tavakkolian 2016-02-03 1:25 ` cinap_lenrek 2016-02-03 11:53 ` Tiago Natel 2016-02-01 22:42 ` Skip Tavakkolian
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).