mirror of https://github.com/adamdruppe/arsd.git
musl compatibility by conditional versions
This commit is contained in:
parent
2a6bb100c2
commit
76b50ad081
51
cgi.d
51
cgi.d
|
@ -297,6 +297,21 @@ static import std.file;
|
||||||
// for a single thread, linear request thing, use:
|
// for a single thread, linear request thing, use:
|
||||||
// -version=embedded_httpd_threads -version=cgi_no_threads
|
// -version=embedded_httpd_threads -version=cgi_no_threads
|
||||||
|
|
||||||
|
version(Posix) {
|
||||||
|
version(CRuntime_Musl) {
|
||||||
|
|
||||||
|
} else version(minimal) {
|
||||||
|
|
||||||
|
} else {
|
||||||
|
version=with_sendfd;
|
||||||
|
version=with_addon_servers;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// the servers must know about the connections to talk to them; the interfaces are vital
|
||||||
|
version(with_addon_servers)
|
||||||
|
version=with_addon_servers_connections;
|
||||||
|
|
||||||
version(embedded_httpd) {
|
version(embedded_httpd) {
|
||||||
version(linux)
|
version(linux)
|
||||||
version=embedded_httpd_processes;
|
version=embedded_httpd_processes;
|
||||||
|
@ -3084,16 +3099,28 @@ void cgiMainImpl(alias fun, CustomCgi = Cgi, long maxContentLength = defaultMaxC
|
||||||
// run the special separate processes if needed
|
// run the special separate processes if needed
|
||||||
switch(args[1]) {
|
switch(args[1]) {
|
||||||
case "--websocket-server":
|
case "--websocket-server":
|
||||||
runWebsocketServer();
|
version(with_addon_servers)
|
||||||
|
runWebsocketServer();
|
||||||
|
else
|
||||||
|
writeln("Add-on servers not compiled in.");
|
||||||
return;
|
return;
|
||||||
case "--session-server":
|
case "--session-server":
|
||||||
runSessionServer();
|
version(with_addon_servers)
|
||||||
|
runSessionServer();
|
||||||
|
else
|
||||||
|
writeln("Add-on servers not compiled in.");
|
||||||
return;
|
return;
|
||||||
case "--event-server":
|
case "--event-server":
|
||||||
runEventServer();
|
version(with_addon_servers)
|
||||||
|
runEventServer();
|
||||||
|
else
|
||||||
|
writeln("Add-on servers not compiled in.");
|
||||||
return;
|
return;
|
||||||
case "--timer-server":
|
case "--timer-server":
|
||||||
runTimerServer();
|
version(with_addon_servers)
|
||||||
|
runTimerServer();
|
||||||
|
else
|
||||||
|
writeln("Add-on servers not compiled in.");
|
||||||
return;
|
return;
|
||||||
case "--timed-jobs":
|
case "--timed-jobs":
|
||||||
import core.demangle;
|
import core.demangle;
|
||||||
|
@ -4900,6 +4927,7 @@ version(Posix) {
|
||||||
alias SocketConnectionHandle = SOCKET;
|
alias SocketConnectionHandle = SOCKET;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
version(with_addon_servers_connections)
|
||||||
LocalServerConnectionHandle openLocalServerConnection(string name) {
|
LocalServerConnectionHandle openLocalServerConnection(string name) {
|
||||||
version(Posix) {
|
version(Posix) {
|
||||||
import core.sys.posix.unistd;
|
import core.sys.posix.unistd;
|
||||||
|
@ -4935,6 +4963,7 @@ LocalServerConnectionHandle openLocalServerConnection(string name) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
version(with_addon_servers_connections)
|
||||||
void closeLocalServerConnection(LocalServerConnectionHandle handle) {
|
void closeLocalServerConnection(LocalServerConnectionHandle handle) {
|
||||||
version(Posix) {
|
version(Posix) {
|
||||||
import core.sys.posix.unistd;
|
import core.sys.posix.unistd;
|
||||||
|
@ -5035,6 +5064,7 @@ void freeIoOp(ref IoOp* ptr) {
|
||||||
}
|
}
|
||||||
|
|
||||||
version(Posix)
|
version(Posix)
|
||||||
|
version(with_addon_servers_connections)
|
||||||
void nonBlockingWrite(EventIoServer eis, int connection, const void[] data) {
|
void nonBlockingWrite(EventIoServer eis, int connection, const void[] data) {
|
||||||
import core.sys.posix.unistd;
|
import core.sys.posix.unistd;
|
||||||
|
|
||||||
|
@ -5077,6 +5107,7 @@ https://docs.microsoft.com/en-us/windows/desktop/api/winsock2/nf-winsock2-wsaget
|
||||||
|
|
||||||
$(TIP If you make your subclass a `final class`, there is a slight performance improvement.)
|
$(TIP If you make your subclass a `final class`, there is a slight performance improvement.)
|
||||||
+/
|
+/
|
||||||
|
version(with_addon_servers_connections)
|
||||||
interface EventIoServer {
|
interface EventIoServer {
|
||||||
bool handleLocalConnectionData(IoOp* op, int receivedFd);
|
bool handleLocalConnectionData(IoOp* op, int receivedFd);
|
||||||
void handleLocalConnectionClose(IoOp* op);
|
void handleLocalConnectionClose(IoOp* op);
|
||||||
|
@ -5582,6 +5613,7 @@ class MockSession(Data) : Session!Data {
|
||||||
Direct interface to the basic data add-on server. You can
|
Direct interface to the basic data add-on server. You can
|
||||||
typically use [Cgi.getSessionObject] as a more convenient interface.
|
typically use [Cgi.getSessionObject] as a more convenient interface.
|
||||||
+/
|
+/
|
||||||
|
version(with_addon_servers_connections)
|
||||||
interface BasicDataServer {
|
interface BasicDataServer {
|
||||||
///
|
///
|
||||||
void createSession(string sessionId, int lifetime);
|
void createSession(string sessionId, int lifetime);
|
||||||
|
@ -5603,10 +5635,12 @@ interface BasicDataServer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
version(with_addon_servers_connections)
|
||||||
class BasicDataServerConnection : BasicDataServer {
|
class BasicDataServerConnection : BasicDataServer {
|
||||||
mixin ImplementRpcClientInterface!(BasicDataServer, "/tmp/arsd_session_server");
|
mixin ImplementRpcClientInterface!(BasicDataServer, "/tmp/arsd_session_server");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
version(with_addon_servers)
|
||||||
final class BasicDataServerImplementation : BasicDataServer, EventIoServer {
|
final class BasicDataServerImplementation : BasicDataServer, EventIoServer {
|
||||||
|
|
||||||
void createSession(string sessionId, int lifetime) {
|
void createSession(string sessionId, int lifetime) {
|
||||||
|
@ -5672,6 +5706,7 @@ final class BasicDataServerImplementation : BasicDataServer, EventIoServer {
|
||||||
schedule!fn(args).asap(); // run it in the background as soon as the event loop gets around to it
|
schedule!fn(args).asap(); // run it in the background as soon as the event loop gets around to it
|
||||||
---
|
---
|
||||||
+/
|
+/
|
||||||
|
version(with_addon_servers_connections)
|
||||||
struct ScheduledJobHelper {
|
struct ScheduledJobHelper {
|
||||||
private string func;
|
private string func;
|
||||||
private string[] args;
|
private string[] args;
|
||||||
|
@ -5776,10 +5811,12 @@ interface ScheduledJobServer {
|
||||||
void cancelJob(int jobId);
|
void cancelJob(int jobId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
version(with_addon_servers_connections)
|
||||||
class ScheduledJobServerConnection : ScheduledJobServer {
|
class ScheduledJobServerConnection : ScheduledJobServer {
|
||||||
mixin ImplementRpcClientInterface!(ScheduledJobServer, "/tmp/arsd_scheduled_job_server");
|
mixin ImplementRpcClientInterface!(ScheduledJobServer, "/tmp/arsd_scheduled_job_server");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
version(with_addon_servers)
|
||||||
final class ScheduledJobServerImplementation : ScheduledJobServer, EventIoServer {
|
final class ScheduledJobServerImplementation : ScheduledJobServer, EventIoServer {
|
||||||
// FIXME: we need to handle SIGCHLD in this somehow
|
// FIXME: we need to handle SIGCHLD in this somehow
|
||||||
// whenIs is 0 for relative, 1 for absolute
|
// whenIs is 0 for relative, 1 for absolute
|
||||||
|
@ -5877,6 +5914,7 @@ final class ScheduledJobServerImplementation : ScheduledJobServer, EventIoServer
|
||||||
}
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
|
version(with_addon_servers_connections)
|
||||||
interface EventSourceServer {
|
interface EventSourceServer {
|
||||||
/++
|
/++
|
||||||
sends this cgi request to the event server so it will be fed events. You should not do anything else with the cgi object after this.
|
sends this cgi request to the event server so it will be fed events. You should not do anything else with the cgi object after this.
|
||||||
|
@ -5981,6 +6019,7 @@ interface EventSourceServer {
|
||||||
}
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
|
version(with_addon_servers)
|
||||||
final class EventSourceServerImplementation : EventSourceServer, EventIoServer {
|
final class EventSourceServerImplementation : EventSourceServer, EventIoServer {
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -6459,7 +6498,7 @@ void runAddonServer(EIS)(string localListenerName, EIS eis) if(is(EIS : EventIoS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
version(Posix)
|
version(with_sendfd)
|
||||||
// copied from the web and ported from C
|
// copied from the web and ported from C
|
||||||
// see https://stackoverflow.com/questions/2358684/can-i-share-a-file-descriptor-to-another-process-on-linux-or-are-they-local-to-t
|
// see https://stackoverflow.com/questions/2358684/can-i-share-a-file-descriptor-to-another-process-on-linux-or-are-they-local-to-t
|
||||||
ssize_t write_fd(int fd, void *ptr, size_t nbytes, int sendfd) {
|
ssize_t write_fd(int fd, void *ptr, size_t nbytes, int sendfd) {
|
||||||
|
@ -6499,7 +6538,7 @@ ssize_t write_fd(int fd, void *ptr, size_t nbytes, int sendfd) {
|
||||||
return sendmsg(fd, &msg, 0);
|
return sendmsg(fd, &msg, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
version(Posix)
|
version(with_sendfd)
|
||||||
// copied from the web and ported from C
|
// copied from the web and ported from C
|
||||||
ssize_t read_fd(int fd, void *ptr, size_t nbytes, int *recvfd) {
|
ssize_t read_fd(int fd, void *ptr, size_t nbytes, int *recvfd) {
|
||||||
msghdr msg;
|
msghdr msg;
|
||||||
|
|
Loading…
Reference in New Issue