--- a/render_threads.c Tue Jun 17 18:05:08 2008 +0300
+++ b/render_threads.c Tue Jun 17 18:15:43 2008 +0300
@@ -389,8 +389,8 @@
pthread_mutex_lock(&ctx->process_row_mut);
}
- // are all the slices done now?
- if (ctx->slices_running == 0) {
+ // are all the rows and slices done now?
+ if (ctx->slices_running == 0 && ctx->waiting_rows == 0) {
// unlock the mutex so the worker threads don't get stuck on it
pthread_mutex_unlock(&ctx->process_row_mut);
@@ -429,13 +429,13 @@
for (i = 0; i < ctx->slice_count; i++) {
if (pthread_cancel(ctx->threads[i].thread))
PWARNING("pthread_cancel(worker:%d)", i);
- else {
- if (pthread_join(ctx->threads[i].thread, &retval)) {
- PWARNING("pthread_join(worker:%d)", i);
- } else {
- if (retval != PTHREAD_CANCELED)
- PWARNING("worker:%d retval = %p", i, retval);
- }
+
+ // join it in any case
+ if (pthread_join(ctx->threads[i].thread, &retval)) {
+ PWARNING("pthread_join(worker:%d)", i);
+ } else {
+ if (retval != PTHREAD_CANCELED)
+ PWARNING("worker:%d retval = %p", i, retval);
}
}
@@ -509,6 +509,9 @@
if (!(ctx = calloc(1, sizeof(*ctx))))
ERROR("calloc");
+ // flag it for free()ing
+ ctx->owned_by_me = 1;
+
// init with silent fall-through
if (render_threads_init(ctx, render_info))
goto error;