Permalink
Browse files

Fixed return value from populate_data

  • Loading branch information...
1 parent 43620fe commit 84ba839750931d21d351d8f94232ea9041e78f4d @trondn trondn committed with ingenthr Jul 18, 2010
Showing with 14 additions and 9 deletions.
  1. +14 −9 main.c
View
23 main.c
@@ -566,8 +566,11 @@ static int populate_dataset(struct report *rep) {
* @return arg
*/
void *populate_thread_main(void* arg) {
- populate_dataset((struct report*) arg);
- return arg;
+ if (populate_dataset((struct report*) arg) == 0) {
+ return arg;
+ } else {
+ return NULL;
+ }
}
/**
@@ -576,6 +579,7 @@ void *populate_thread_main(void* arg) {
* @return 0 if success, -1 otherwise
*/
int populate_data(int no_threads) {
+ int ret = 0;
if (no_threads > 1) {
pthread_t *threads = calloc(sizeof (pthread_t), no_threads);
struct report *reports = calloc(sizeof (struct report), no_threads);
@@ -605,21 +609,22 @@ int populate_data(int no_threads) {
}
for (ii = 0; ii < no_threads; ++ii) {
- void *ret;
- pthread_join(threads[ii], &ret);
+ void *threadret;
+ pthread_join(threads[ii], &threadret);
+ if (threadret == NULL) {
+ ret = -1;
+ }
}
free(threads);
free(reports);
} else {
struct report report;
report.offset = 0;
report.total = no_items;
-
- if (populate_dataset(&report) == -1) {
- return 1;
- }
+ ret = populate_dataset(&report);
}
- return 0;
+
+ return ret;
}

0 comments on commit 84ba839

Please sign in to comment.