%#
/*
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
* */
#include
#include
%>
show cache
<%$
//returns miliseconds
double dateDiff(timespec t1, timespec t2) {
return double(t2.tv_sec-t1.tv_sec)*1000+double(t2.tv_nsec-t1.tv_nsec)/1000000;
}
const char* ifnull(const char* s, const char* n) {
return s==nullptr?n:s;
}
void writeAddr(StreamWriter& sw, void* addr) {
Dl_info inf; char* sname;
dladdr(addr,&inf);
if(inf.dli_sname==nullptr) sname=nullptr;
else sname=abi::__cxa_demangle(inf.dli_sname, 0, 0, nullptr);
sw.writeF("%s: %s (%p)",ifnull(inf.dli_fname,"?"), ifnull(sname,"?"), addr);
if(sname) free(sname);
}
cppspManager* cm;
void init() {
doReadPost=true;
}
void load() override {
cm=server->manager();
if(cm==NULL) throw runtime_error("server is not managed by cppspManager");
}
%>
Worker #<%=server->threadID%>
<%
auto it=request->form.find("act");
if(it!=request->form.end()) {
if((*it).second=="clear+cppsp+page+cache") {
cm->cleanCache(0);
} else if((*it).second=="clear+route+cache") {
server->cleanCache(0);
} else if((*it).second=="clear+all+caches") {
server->cleanCache(0);
cm->cleanCache(0);
}
}
%>
Dynamic page cache:
| Path |
RC |
Load time |
Last access |
State |
<%
for(auto it=cm->cache.begin();it!=cm->cache.end();it++) {
auto tmp=(*it).second;
char buffer[256];
tm time1; localtime_r(&tmp->lastLoad.tv_sec,&time1);
strftime(buffer, sizeof(buffer), "%F %r", &time1);
const char* state=tmp->compiling?"compiling":tmp->loaded?"loaded":"unloaded";
%>
moduleCount>0?" class=\"persistent\" title=\"Module\"":""%>>
| <%htmlEscape((*it).first,output);%> |
<%=tmp->refCount%> |
<%htmlEscape(buffer,output);%> |
<%=int64_t(-dateDiff(cm->curTime,tmp->lastCheck)/1000)%> seconds ago |
<%=state%> |
<%
}
%>
Static page cache:
| Path |
RC |
Load time |
Last access |
<%
for(auto it=cm->staticCache.begin();it!=cm->staticCache.end();it++) {
auto tmp=(*it).second;
char buffer[256];
tm time1; localtime_r(&(*it).second->lastLoad.tv_sec,&time1);
strftime(buffer, sizeof(buffer), "%F %r", &time1);
%>
| <%htmlEscape((*it).first,output);%> |
<%=tmp->refCount%> |
<%htmlEscape(buffer,output);%> |
<%=int64_t(-dateDiff(cm->curTime,tmp->lastCheck)/1000)%> seconds ago |
<%
}
%>
Route cache:
| Path |
Handler |
Last update |
<%
for(auto it=server->routeCache.begin();it!=server->routeCache.end();it++) {
auto tmp=(*it).second;
%>
| <%htmlEscape((*it).first,output);%> |
<%
writeAddr(output,(void*)tmp->handler.func);
output.writeF(", %p",tmp->handler.data);
%> |
<%=int64_t(-dateDiff(cm->curTime,tmp->lastUpdate)/1000)%> seconds ago |
<%
}
%>