summaryrefslogtreecommitdiff
path: root/sys/include
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2021-05-01 16:37:00 +0200
committercinap_lenrek <cinap_lenrek@felloff.net>2021-05-01 16:37:00 +0200
commitf6509078ed9d03b71c945b19cdda5c882cb1e78d (patch)
treef060fbb137179f248898f62e3b81c882a6f493e8 /sys/include
parent013b4983140cc2fbb7df9e3647e2e7c5d575a9dd (diff)
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.
Diffstat (limited to 'sys/include')
-rw-r--r--sys/include/9p.h20
1 files changed, 12 insertions, 8 deletions
diff --git a/sys/include/9p.h b/sys/include/9p.h
index 949476232..1a51ffeab 100644
--- a/sys/include/9p.h
+++ b/sys/include/9p.h
@@ -235,23 +235,29 @@ struct Srv {
int spid; /* pid of srv() caller */
+ void (*forker)(void (*)(void*), void*, int);
void (*free)(Srv*);
};
+void srvforker(void (*)(void*), void*, int);
+void threadsrvforker(void (*)(void*), void*, int);
+
void srv(Srv*);
+void postsrv(Srv*, char*);
void postmountsrv(Srv*, char*, char*, int);
-void _postmountsrv(Srv*, char*, char*, int);
void postsharesrv(Srv*, char*, char*, char*);
-void _postsharesrv(Srv*, char*, char*, char*);
void listensrv(Srv*, char*);
-void _listensrv(Srv*, char*);
-int chatty9p;
-void respond(Req*, char*);
-void responderror(Req*);
+
+void threadsrv(Srv*);
+void threadpostsrv(Srv*, char*);
void threadpostmountsrv(Srv*, char*, char*, int);
void threadpostsharesrv(Srv*, char*, char*, char*);
void threadlistensrv(Srv *s, char *addr);
+int chatty9p;
+void respond(Req*, char*);
+void responderror(Req*);
+
/*
* Helper. Assumes user is same as group.
*/
@@ -276,8 +282,6 @@ void authwrite(Req*);
void authdestroy(Fid*);
int authattach(Req*);
-extern void (*_forker)(void (*)(void*), void*, int);
-
void srvacquire(Srv *);
void srvrelease(Srv *);