From 6c708dcbf987d3e115cb31364e26d05ac5e0ad0c Mon Sep 17 00:00:00 2001 From: Ludovic Pouzenc Date: Sat, 14 May 2011 19:38:51 +0000 Subject: 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. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: file:///var/svn/2011-ddhardrescue/trunk@15 d3078510-dda0-49f1-841c-895ef4b7ec81 --- inc/slices_evt.h | 6 ++++-- 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 +#include + #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); +} +*/ -- cgit v1.2.3