noinst_LIBRARIES = libpsensor.a
libpsensor_a_SOURCES = \
- amd.h \
- bool.h \
- color.h color.c \
- cpu.h \
+ amd.h\
+ bool.h\
+ color.h color.c\
+ cpu.h\
hdd.h hdd_hddtemp.c\
- lmsensor.h lmsensor.c \
- plog.h plog.c \
+ lmsensor.h lmsensor.c\
measure.h measure.c \
- ptime.h ptime.c \
- nvidia.h \
+ nvidia.h\
+ plog.h plog.c\
+ pmutex.h pmutex.c\
psensor.h psensor.c\
- pio.h pio.c \
- slog.c slog.h \
+ ptime.h ptime.c\
+ pio.h pio.c\
+ slog.c slog.h\
url.c url.h
AM_CPPFLAGS = -Wall -Werror
libpsensor_a_AR = $(AR) $(ARFLAGS)
libpsensor_a_LIBADD =
am__libpsensor_a_SOURCES_DIST = amd.h bool.h color.h color.c cpu.h \
- hdd.h hdd_hddtemp.c lmsensor.h lmsensor.c plog.h plog.c \
- measure.h measure.c ptime.h ptime.c nvidia.h psensor.h \
- psensor.c pio.h pio.c slog.c slog.h url.c url.h hdd_atasmart.c \
- nvidia.c amd.c cpu.c psensor_json.h psensor_json.c
+ hdd.h hdd_hddtemp.c lmsensor.h lmsensor.c measure.h measure.c \
+ nvidia.h plog.h plog.c pmutex.h pmutex.c psensor.h psensor.c \
+ ptime.h ptime.c pio.h pio.c slog.c slog.h url.c url.h \
+ hdd_atasmart.c nvidia.c amd.c cpu.c psensor_json.h \
+ psensor_json.c
@ATASMART_TRUE@am__objects_1 = hdd_atasmart.$(OBJEXT)
@NVIDIA_TRUE@am__objects_2 = nvidia.$(OBJEXT)
@LIBATIADL_TRUE@am__objects_3 = amd.$(OBJEXT)
@GTOP_TRUE@am__objects_4 = cpu.$(OBJEXT)
@JSON_TRUE@am__objects_5 = psensor_json.$(OBJEXT)
am_libpsensor_a_OBJECTS = color.$(OBJEXT) hdd_hddtemp.$(OBJEXT) \
- lmsensor.$(OBJEXT) plog.$(OBJEXT) measure.$(OBJEXT) \
- ptime.$(OBJEXT) psensor.$(OBJEXT) pio.$(OBJEXT) slog.$(OBJEXT) \
- url.$(OBJEXT) $(am__objects_1) $(am__objects_2) \
- $(am__objects_3) $(am__objects_4) $(am__objects_5)
+ lmsensor.$(OBJEXT) measure.$(OBJEXT) plog.$(OBJEXT) \
+ pmutex.$(OBJEXT) psensor.$(OBJEXT) ptime.$(OBJEXT) \
+ pio.$(OBJEXT) slog.$(OBJEXT) url.$(OBJEXT) $(am__objects_1) \
+ $(am__objects_2) $(am__objects_3) $(am__objects_4) \
+ $(am__objects_5)
libpsensor_a_OBJECTS = $(am_libpsensor_a_OBJECTS)
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
depcomp = $(SHELL) $(top_srcdir)/depcomp
top_srcdir = @top_srcdir@
noinst_LIBRARIES = libpsensor.a
libpsensor_a_SOURCES = amd.h bool.h color.h color.c cpu.h hdd.h \
- hdd_hddtemp.c lmsensor.h lmsensor.c plog.h plog.c measure.h \
- measure.c ptime.h ptime.c nvidia.h psensor.h psensor.c pio.h \
- pio.c slog.c slog.h url.c url.h $(am__append_1) \
- $(am__append_4) $(am__append_7) $(am__append_8) \
- $(am__append_11)
+ hdd_hddtemp.c lmsensor.h lmsensor.c measure.h measure.c \
+ nvidia.h plog.h plog.c pmutex.h pmutex.c psensor.h psensor.c \
+ ptime.h ptime.c pio.h pio.c slog.c slog.h url.c url.h \
+ $(am__append_1) $(am__append_4) $(am__append_7) \
+ $(am__append_8) $(am__append_11)
AM_CPPFLAGS = -Wall -Werror $(am__append_3) $(am__append_6) \
$(am__append_10) $(am__append_13)
EXTRA_DIST = $(libpsensor_a_SOURCES) \
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nvidia.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pio.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/plog.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pmutex.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/psensor.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/psensor_json.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ptime.Po@am__quote@
--- /dev/null
+/*
+ * 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
+ * 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+#include <stdio.h>
+
+#include <plog.h>
+#include <pmutex.h>
+
+int pmutex_lock(pthread_mutex_t *m)
+{
+ int ret;
+
+ ret = pthread_mutex_lock(m);
+
+ if (ret)
+ log_err("pmutex_lock: %p %d", m, ret);
+
+ return ret;
+}
+
+int pmutex_unlock(pthread_mutex_t *m)
+{
+ int ret;
+
+ ret = pthread_mutex_unlock(m);
+
+ if (ret)
+ log_err("pmutex_unlock: %p %d", m, ret);
+
+ return ret;
+}
+
+int pmutex_init(pthread_mutex_t *m)
+{
+ pthread_mutexattr_t attr;
+ int ret;
+
+ pthread_mutexattr_init(&attr);
+ pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK);
+
+ ret = pthread_mutex_init(m, &attr);
+
+ if (ret)
+ log_err("pmutex_init: %p %d", m, ret);
+
+ return ret;
+}
--- /dev/null
+/*
+ * 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
+ * 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+#ifndef _P_PMUTEX_H_
+#define _P_PMUTEX_H_
+
+#include <pthread.h>
+
+int pmutex_lock(pthread_mutex_t *);
+int pmutex_unlock(pthread_mutex_t *);
+int pmutex_init(pthread_mutex_t *);
+
+#endif
#include "ui_color.h"
#include "lmsensor.h"
#include "notify_cmd.h"
+#include <pmutex.h>
#include "slog.h"
#include "ui_pref.h"
#include "ui_graph.h"
cfg = ui->config;
while (1) {
- pthread_mutex_lock(&ui->sensors_mutex);
+ pmutex_lock(&ui->sensors_mutex);
sensors = ui->sensors;
if (!sensors)
period = cfg->sensor_update_interval;
- pthread_mutex_unlock(&ui->sensors_mutex);
+ pmutex_unlock(&ui->sensors_mutex);
sleep(period);
}
ret = TRUE;
cfg = ui->config;
- pthread_mutex_lock(&ui->sensors_mutex);
+ pmutex_lock(&ui->sensors_mutex);
graph_update(ui->sensors, ui->w_graph, ui->config, ui->main_window);
ret = FALSE;
}
- pthread_mutex_unlock(&ui->sensors_mutex);
+ pmutex_unlock(&ui->sensors_mutex);
if (ret == FALSE)
g_timeout_add(1000 * ui->graph_update_interval,
*/
static void cleanup(struct ui_psensor *ui)
{
- pthread_mutex_lock(&ui->sensors_mutex);
+ pmutex_lock(&ui->sensors_mutex);
log_debug("Cleanup...");
ui_status_cleanup();
- pthread_mutex_unlock(&ui->sensors_mutex);
+ pmutex_unlock(&ui->sensors_mutex);
config_cleanup();
gtk_init(NULL, NULL);
- pthread_mutex_init(&ui.sensors_mutex, NULL);
+ pmutex_init(&ui.sensors_mutex);
ui.config = config_load();
#include <plog.h>
#include "psensor_json.h"
+#include <pmutex.h>
#include "url.h"
#include "server.h"
#include "slog.h"
static struct server_data server_data;
-static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
+static pthread_mutex_t mutex;
static int server_stop_requested;
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);
if (!log_file)
log_file = strdup(DEFAULT_LOG_FILE);
+ pmutex_init(&mutex);
+
log_open(log_file);
psensor_init();
}
while (!server_stop_requested) {
- pthread_mutex_lock(&mutex);
+ pmutex_lock(&mutex);
#ifdef HAVE_GTOP
sysinfo_update(&server_data.psysinfo);
psensor_log_measures(server_data.sensors);
- pthread_mutex_unlock(&mutex);
+ pmutex_unlock(&mutex);
sleep(5);
}