diff options
author | Ludovic Pouzenc <ludovic@pouzenc.fr> | 2011-05-14 19:38:51 +0000 |
---|---|---|
committer | Ludovic Pouzenc <ludovic@pouzenc.fr> | 2011-05-14 19:38:51 +0000 |
commit | 6c708dcbf987d3e115cb31364e26d05ac5e0ad0c (patch) | |
tree | 50b7b25ade5840432c290ac5d469251e6c4a862f | |
parent | b7fc5e62feba5edb3f67844c87fc8072930ea34b (diff) | |
download | 2011-ddhardrescue-6c708dcbf987d3e115cb31364e26d05ac5e0ad0c.tar.gz 2011-ddhardrescue-6c708dcbf987d3e115cb31364e26d05ac5e0ad0c.tar.bz2 2011-ddhardrescue-6c708dcbf987d3e115cb31364e26d05ac5e0ad0c.zip |
Ajout mutex pour tenter d'éliminer les problèmes d'accès courants aux buffers de ncurses sans implémenter une file de message complète.
git-svn-id: file:///var/svn/2011-ddhardrescue/trunk@15 d3078510-dda0-49f1-841c-895ef4b7ec81
-rw-r--r-- | inc/slices_evt.h | 6 | ||||
-rw-r--r-- | src/slices_evt.c | 16 |
2 files changed, 18 insertions, 4 deletions
diff --git a/inc/slices_evt.h b/inc/slices_evt.h index e7d44fe..d5772b3 100644 --- a/inc/slices_evt.h +++ b/inc/slices_evt.h @@ -7,11 +7,13 @@ typedef struct _slices_evt_t { slices_t *data; - pthread_mutex_t mutex; void (*eventListener)(/*sliceEvtKind_t evtKind,*/ struct _slices_evt_t *slicesEvt, slice_t *slice); + pthread_mutex_t eventListenerMutex; } slices_evt_t; -int sliceSplitEvt(slices_evt_t *slicesEvt, slice_t *initialSlice, address_t splitAt, sliceStatus_t statusBefore, sliceStatus_t statusAt, sliceStatus_t statusAfter); +int sliceEvtSplit(slices_evt_t *slicesEvt, slice_t *initialSlice, address_t splitAt, sliceStatus_t statusBefore, sliceStatus_t statusAt, sliceStatus_t statusAfter); + +//void sliceEvtPutEvent(slices_evt_t *slicesEvt, slice_t *modifiedSlice); #endif /*SLICES_EVT_H */ diff --git a/src/slices_evt.c b/src/slices_evt.c index 43cb568..9174903 100644 --- a/src/slices_evt.c +++ b/src/slices_evt.c @@ -1,10 +1,15 @@ +//XXX Suprress that when event queue is terminated +#include <stdio.h> +#include <pthread.h> + #include "slices_evt.h" -int sliceSplitEvt(slices_evt_t *slicesEvt, slice_t *initialSlice, address_t splitAt, sliceStatus_t statusBefore, sliceStatus_t statusAt, sliceStatus_t statusAfter) { +int sliceEvtSplit(slices_evt_t *slicesEvt, slice_t *initialSlice, address_t splitAt, sliceStatus_t statusBefore, sliceStatus_t statusAt, sliceStatus_t statusAfter) { int res; res=sliceSplit(slicesEvt->data, initialSlice, splitAt, statusBefore, statusAt, statusAfter); + + pthread_mutex_lock(&(slicesEvt->eventListenerMutex)); if ( slicesEvt->eventListener != NULL ) { - //FIXME : this could be dereference a NULL pointer. Implement a real listener system with a thread-safe FIFO switch(res) { case 3: slicesEvt->eventListener(slicesEvt, initialSlice->next->next); @@ -18,5 +23,12 @@ int sliceSplitEvt(slices_evt_t *slicesEvt, slice_t *initialSlice, address_t spli break; } } + pthread_mutex_unlock(&(slicesEvt->eventListenerMutex)); return res; } + +/* +void sliceEvtPutEvent(slices_evt_t *slicesEvt, slice_t *modifiedSlice) { + printf("sliceEvtPutEvent %p %p\n", slicesEvt, modifiedSlice); +} +*/ |