]> www.infradead.org Git - users/mchehab/rasdaemon.git/commitdiff
ras-events: open database on each thread
authorMauro Carvalho Chehab <mchehab@redhat.com>
Thu, 9 May 2013 16:11:26 +0000 (13:11 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Thu, 9 May 2013 16:33:31 +0000 (13:33 -0300)
sqlite3 is only able to prevent race issues between different
threads if each thread opens its own connection to the database.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
ras-events.c
ras-events.h
ras-record.c

index 5a6cdfee5f5531c195a2989b701564850d84602e..301d38d4bdb68c79b82dc13a917164afd229a40b 100644 (file)
@@ -342,7 +342,9 @@ static void *handle_ras_events_cpu(void *priv)
                return NULL;
        }
 
-//     printf("Listening to events on cpu %d\n", pdata->cpu);
+       printf("Listening to events on cpu %d\n", pdata->cpu);
+        if (pdata->ras->record_events)
+                ras_mc_event_opendb(pdata->ras);
 
        read_ras_event(fd, pdata, kbuf, page);
 
@@ -468,9 +470,7 @@ int handle_ras_events(int record_events)
 
        ras->pevent = pevent;
        ras->page_size = page_size;
-
-       if (record_events)
-               ras_mc_event_opendb(ras);
+        ras->record_events = record_events;
 
        pevent_register_event_handler(pevent, -1, "ras", "mc_event",
                                      ras_mc_event_handler, ras);
index 5506d1d27abf877700a29d1ebcd90c699e399e0f..6b081ed6716e465586b656db0a66edd44e0fc969 100644 (file)
@@ -33,9 +33,11 @@ struct ras_events {
        struct pevent   *pevent;
        int             page_size;
 
-       /* For timestamp */
+       /* Booleans */
        unsigned        use_uptime: 1;
+        unsigned        record_events: 1;
 
+        /* For timestamp */
        time_t          uptime_diff;
 
        /* For ras-record */
index 752de468c1a746a687cbe5c16b346309bff80484..eebfc8d5db14331cff02199114e255f48b65fa9c 100644 (file)
@@ -103,6 +103,8 @@ int ras_mc_event_opendb(struct ras_events *ras)
        char sql[1024];
        struct sqlite3_priv *priv;
 
+        printf("Calling %s()\n", __FUNCTION__);
+
        ras->db_priv = NULL;
 
        priv = calloc(1, sizeof(*priv));