aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2010-04-01 17:44:32 +0200
committerThomas White <taw@physics.org>2010-04-01 17:44:32 +0200
commitc19cd3d161b88e5ea487b2660d81b53ace2645a2 (patch)
tree389dc07140c2f654695206e7f4731f053f89ebf1 /src
parent822712b0a5fe825bd9f40e1d2e7027935844553e (diff)
indexmajig: Protect stdout output with a mutex
Diffstat (limited to 'src')
-rw-r--r--src/indexamajig.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/indexamajig.c b/src/indexamajig.c
index b203a1a5..e2ca63d4 100644
--- a/src/indexamajig.c
+++ b/src/indexamajig.c
@@ -43,6 +43,7 @@
struct process_args
{
char *filename;
+ pthread_mutex_t *output_mutex;
UnitCell *cell;
int config_cmfilter;
int config_noisefilter;
@@ -305,7 +306,9 @@ static void *process_image(void *pargsv)
if ( config_nearbragg ) {
/* Use original data (temporarily) */
simage->data = data_for_measurement;
+ pthread_mutex_lock(pargs->output_mutex);
output_intensities(simage, image.indexed_cell);
+ pthread_mutex_unlock(pargs->output_mutex);
simage->data = NULL;
}
@@ -377,6 +380,7 @@ int main(int argc, char *argv[])
struct process_args *worker_args[MAX_THREADS];
int worker_active[MAX_THREADS];
int i;
+ pthread_mutex_t output_mutex = PTHREAD_MUTEX_INITIALIZER;
/* Long options */
const struct option longopts[] = {
@@ -531,6 +535,7 @@ int main(int argc, char *argv[])
pargs = malloc(sizeof(*pargs));
pargs->filename = prefixed;
+ pargs->output_mutex = &output_mutex;
pargs->config_cmfilter = config_cmfilter;
pargs->config_noisefilter = config_noisefilter;
pargs->config_writedrx = config_writedrx;