Commit Graph

10 Commits (master)

Author SHA1 Message Date
cinap_lenrek ee289c2415 lib9p: remove Srv.srvfd, make postsrv() and threadpostsrv() return the mountable file descriptor, update documentation
Now that we have these new functions,
we can also make them return an error
instead of calling sysfatal() like
postmountsrv().

Remove the confusing Srv.srvfd, as it
is only temporarily used and return
it from postsrv() instead.
2021-05-01 19:58:58 +02:00
cinap_lenrek 57c21ae441 lib9p: remove unneccesary headers 2021-05-01 17:03:03 +02:00
cinap_lenrek f6509078ed lib9p: expose Srv.forker handler and srvforker(), threadsrvforker() and threadsrv() functions
To use srvrease()/srvaquire() we need to have a way to spawn
new processes to handle the service loop. This functionality
was provided by the internal _forker() function which was
eigther rfork or libthread based implementation depending on
if postmountsrv() or threadpostmountsrv() where called.

For servers who want to use srv() directly, _forker would not
be initialized so srvrelease() could not be used.

To untangle this, we get rid of the global _forker handler
and put the handler in the Srv structure. Which will get
initialized (when nil) to eigther srvforker() or threadsrvforker()
depending on if the thread or non-thread entry points where used.

For symmetry, we provde new threadsrv() and threadpostsrv()
functions which handle the default initialization of Srv.forker.

This also allows a user to provide his own forker function,
maybe to conserve stack space.

To avoid dead code, we put each of these function in their
own object file. Note, this also allows a user to define its
own srvforker() symbol.
2021-05-01 16:37:00 +02:00
cinap_lenrek 5e59c57bb1 lib9p: open internal file-descriptor with OCEXEC flag in getremotesys() 2020-12-07 14:54:27 +01:00
cinap_lenrek 8f64e44854 lib9p: zero out per connection state in Srv template for listensrv()
in case listensrv() is called with a previously active Srv,
we have to make sure that per connection state is zeroed
out (locks and reference conuts).

also, dont assume anything about the Ref structure. there
might be implementations that have a spinlock in them.
2020-03-07 15:01:29 +01:00
cinap_lenrek dea2905783 lib9p: fix listensrv() filedescriptor leaks 2019-10-04 18:52:53 +02:00
cinap_lenrek a034e629f7 lib9p: do not override Srv.end in listensrv(), simplify srvclose() and recounting
listensrv() used to override Srv.end() with its own handler
to free the malloc'd Srv structure and close the fd. this
makes it impossible to register your own cleanup handler.
instead, we introduce the private Srv.free() handler that
is used by listensrv to register its cleanup code. Srv.free()
is called once all the srv procs have been exited and all
requests on that srv have been responded to while Srv.end()
is called once all the procs exited the srv loop regardless
of the requests still being in flight.
2015-10-15 13:21:30 +02:00
cinap_lenrek 6b4c5380d8 lib9p: defer freeing srv for listensrv()
use the Srv.end callback for freeing the srv and closing the
file descriptor of a connection. this makes sure we wont free
the srv while there are still outstanding requests that would
access the srv when doing the respond() call.
2013-01-30 10:34:57 +01:00
Taru Karttunen a9060cc06b Import sources from 2011-03-30 iso image - lib 2011-03-30 19:35:09 +03:00
Taru Karttunen e5888a1ffd Import sources from 2011-03-30 iso image 2011-03-30 15:46:40 +03:00