summaryrefslogtreecommitdiff
path: root/src/HttpServer.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/HttpServer.cc')
-rw-r--r--src/HttpServer.cc12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/HttpServer.cc b/src/HttpServer.cc
index c9cb0ee..23af486 100644
--- a/src/HttpServer.cc
+++ b/src/HttpServer.cc
@@ -35,6 +35,8 @@ class HttpWorker : public Task {
HttpWorker(IO<Handle> io, void * server);
~HttpWorker();
static void buildErrorTemplate(IO<Handle> h) { m_errorTemplate.setTemplate(h); }
+ template<size_t S>
+ static void buildErrorTemplate(const char (&str)[S]) { m_errorTemplate.setTemplate(str, S - 1); }
static void buildErrorTemplate(const char * str, ssize_t s) { m_errorTemplate.setTemplate(str, s); }
static void buildErrorTemplate(const String & str) { m_errorTemplate.setTemplate(str); }
private:
@@ -594,14 +596,20 @@ typedef Balau::Listener<Balau::HttpWorker> HttpListener;
void Balau::HttpServer::start() {
AAssert(!m_started, "Don't start an HttpServer twice");
- m_listenerPtr = createTask(new HttpListener(m_port, m_local.to_charp(), this));
+ m_listenerPtr = TaskMan::registerTask(new HttpListener(m_port, m_local.to_charp(), this));
m_started = true;
}
void Balau::HttpServer::stop() {
AAssert(m_started, "Don't stop an HttpServer that hasn't been started");
- reinterpret_cast<HttpListener *>(m_listenerPtr)->stop();
+ HttpListener * listener = reinterpret_cast<HttpListener *>(m_listenerPtr);
+ Events::TaskEvent event(listener);
+ Task::prepare(&event);
+ listener->stop();
m_started = false;
+ Task::operationYield(&event);
+ IAssert(event.gotSignal(), "HttpServer::stop didn't actually get the listener to stop");
+ event.ack();
}
void Balau::HttpServer::registerAction(Action * action) {