Skip to content

Commit

Permalink
Change option name server.daemon to server.thread
Browse files Browse the repository at this point in the history
  • Loading branch information
wolkykim committed Apr 18, 2014
1 parent 873f627 commit ae91d67
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion examples/echo_tcp_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ int main(int argc, char **argv) {
// Run server in a separate thread. If you want to run multiple
// server instances or if you want to run it in background, this
// is the option.
ad_server_set_option(server, "server.daemon", "0");
ad_server_set_option(server, "server.thread", "0");

// Call ad_server_free() internally when server is shutting down.
ad_server_set_option(server, "server.free_on_stop", "1");
Expand Down
2 changes: 1 addition & 1 deletion include/asyncd/ad_server.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ typedef struct ad_hook_s ad_hook_t;
{ "server.request_pipelining", "1" }, \
\
/* Run server in a separate thread */ \
{ "server.daemon", "0" }, \
{ "server.thread", "0" }, \
\
/* Collect resources after stop */ \
{ "server.free_on_stop", "1" }, \
Expand Down
2 changes: 1 addition & 1 deletion src/ad_http_handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -669,4 +669,4 @@ static ssize_t evbuffer_drainln(struct evbuffer *buffer, size_t *n_read_out, enu
return linelen;
}

#endif _DOXYGEN_SKIP
#endif // _DOXYGEN_SKIP
10 changes: 5 additions & 5 deletions src/ad_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ int ad_server_start(ad_server_t *server) {
INFO("Listening on %s:%d%s", addr, port, ((server->sslctx) ? " (SSL)" : ""));

int exitstatus = 0;
if (ad_server_get_option_int(server, "server.daemon")) {
if (ad_server_get_option_int(server, "server.thread")) {
DEBUG("Launching server as a thread.")
server->thread = NEW_OBJECT(pthread_t);
pthread_create(server->thread, NULL, &server_loop, (void *)server);
Expand Down Expand Up @@ -252,7 +252,7 @@ void ad_server_stop(ad_server_t *server) {
notify_loopexit(server);
sleep(1);

if (ad_server_get_option_int(server, "server.daemon")) {
if (ad_server_get_option_int(server, "server.thread")) {
close_server(server);
if (ad_server_get_option_int(server, "server.free_on_stop")) {
ad_server_free(server);
Expand All @@ -266,8 +266,8 @@ void ad_server_stop(ad_server_t *server) {
void ad_server_free(ad_server_t *server) {
if (server == NULL) return;

int daemon = ad_server_get_option_int(server, "server.daemon");
if (daemon && server->thread) {
int thread = ad_server_get_option_int(server, "server.thread");
if (thread && server->thread) {
notify_loopexit(server);
sleep(1);
close_server(server);
Expand Down Expand Up @@ -758,4 +758,4 @@ static void *get_userdata(ad_conn_t *conn, int index) {
return conn->userdata[index];
}

#endif _DOXYGEN_SKIP
#endif // _DOXYGEN_SKIP

0 comments on commit ae91d67

Please sign in to comment.