mirror of
https://github.com/adamdruppe/arsd.git
synced 2025-04-26 13:20:05 +03:00
catching up on lots of changes.
This commit is contained in:
parent
ca50fc2016
commit
5b816cb7e7
13 changed files with 1325 additions and 621 deletions
17
rtud.d
17
rtud.d
|
@ -129,6 +129,11 @@ void writeToFd(int fd, string s) {
|
|||
goto again;
|
||||
}
|
||||
|
||||
__gshared bool deathRequested = false;
|
||||
extern(C)
|
||||
void requestDeath(int sig) {
|
||||
deathRequested = true;
|
||||
}
|
||||
|
||||
import arsd.cgi;
|
||||
/// The throttledConnection param is useful for helping to get
|
||||
|
@ -144,6 +149,14 @@ import arsd.cgi;
|
|||
int handleListenerGateway(Cgi cgi, string channelPrefix, bool throttledConnection = false) {
|
||||
cgi.setCache(false);
|
||||
|
||||
import core.sys.posix.signal;
|
||||
sigaction_t act;
|
||||
// I want all zero everywhere else; the read() must not automatically restart for this to work.
|
||||
act.sa_handler = &requestDeath;
|
||||
|
||||
if(linux.sigaction(linux.SIGTERM, &act, null) != 0)
|
||||
throw new Exception("sig err");
|
||||
|
||||
auto f = openNetworkFd("localhost", 7070);
|
||||
scope(exit) linux.close(f);
|
||||
|
||||
|
@ -185,7 +198,7 @@ int handleListenerGateway(Cgi cgi, string channelPrefix, bool throttledConnectio
|
|||
|
||||
string[4096] buffer;
|
||||
|
||||
for(;;) {
|
||||
for(; !deathRequested ;) {
|
||||
auto num = linux.read(f, buffer.ptr, buffer.length);
|
||||
if(num < 0)
|
||||
throw new Exception("read error");
|
||||
|
@ -202,7 +215,7 @@ int handleListenerGateway(Cgi cgi, string channelPrefix, bool throttledConnectio
|
|||
}
|
||||
|
||||
// this is to support older browsers
|
||||
if(!isSse) {
|
||||
if(!isSse && !deathRequested) {
|
||||
// we have to parse it out and reformat for plain cgi...
|
||||
auto lol = parseMessages(wegot);
|
||||
//cgi.setResponseContentType("text/json");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue