X-Git-Url: http://git.wpitchoune.net/gitweb/?p=psensor-pkg-ubuntu.git;a=blobdiff_plain;f=src%2Fserver%2Fserver.c;h=297d0830e3cc870afaf9bd8dbb6bc20793b13322;hp=39e1f495d8dcf2c5fa2d26959cb1c143dbf5bfd9;hb=4c01ba89aac969b4c19190dd8f27329b5dd24a6e;hpb=2e68c12dc10ca8c06b03aad6b4e44144a9134cd5 diff --git a/src/server/server.c b/src/server/server.c index 39e1f49..297d083 100644 --- a/src/server/server.c +++ b/src/server/server.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010-2013 jeanfi@gmail.com + * Copyright (C) 2010-2014 jeanfi@gmail.com * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -42,8 +42,9 @@ #include "cpu.h" #endif -#include "log.h" +#include #include "psensor_json.h" +#include #include "url.h" #include "server.h" #include "slog.h" @@ -74,7 +75,7 @@ static struct option long_options[] = { static struct server_data server_data; -static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; +static pthread_mutex_t mutex; static int server_stop_requested; @@ -298,9 +299,9 @@ static int cbk_http_request(void *cls, nurl = url_normalize(url); - pthread_mutex_lock(&mutex); + pmutex_lock(&mutex); response = create_response(nurl, method, &resp_code); - pthread_mutex_unlock(&mutex); + pmutex_unlock(&mutex); ret = MHD_queue_response(connection, resp_code, response); MHD_destroy_response(response); @@ -388,6 +389,8 @@ int main(int argc, char *argv[]) if (!log_file) log_file = strdup(DEFAULT_LOG_FILE); + pmutex_init(&mutex); + log_open(log_file); psensor_init(); @@ -426,7 +429,7 @@ int main(int argc, char *argv[]) } while (!server_stop_requested) { - pthread_mutex_lock(&mutex); + pmutex_lock(&mutex); #ifdef HAVE_GTOP sysinfo_update(&server_data.psysinfo); @@ -436,7 +439,7 @@ int main(int argc, char *argv[]) psensor_log_measures(server_data.sensors); - pthread_mutex_unlock(&mutex); + pmutex_unlock(&mutex); sleep(5); }