better seq behaviour in case of error

look for seq errors on cond wake as well
This commit is contained in:
John Cupitt 2016-08-06 20:38:03 +01:00
parent e439c5f78f
commit 23e318eb0a
2 changed files with 11 additions and 10 deletions

7
TODO
View File

@ -1,10 +1,3 @@
- try:
$ vips avg broken.jpg[fail]
about 50% of the time it'll trigger a range of out-of-order reads and lock
for 10s or so while seq times out
- add more webp tests to py suite
- try moving some more of the CLI tests to py

View File

@ -184,7 +184,7 @@ vips_sequential_generate( VipsRegion *or,
/* Exit the loop on timeout or condition passes. We have to
* be wary of spurious wakeups.
*/
while( r->top > sequential->y_pos )
while( r->top > sequential->y_pos ) {
#ifdef HAVE_COND_INIT
if( !g_cond_wait_until( sequential->ready,
sequential->lock, time ) )
@ -195,6 +195,14 @@ vips_sequential_generate( VipsRegion *or,
break;
#endif
/* We may have woken up because of an eval error.
*/
if( sequential->error ) {
g_mutex_unlock( sequential->lock );
return( -1 );
}
}
VIPS_GATE_STOP( "vips_sequential_generate: wait" );
VIPS_DEBUG_MSG_GREEN( "thread %p awake again ...\n",
@ -220,7 +228,7 @@ vips_sequential_generate( VipsRegion *or,
area.width = 1;
area.height = r->top - sequential->y_pos;
if( vips_region_prepare( ir, &area ) ) {
VIPS_DEBUG_MSG( "thread %p error, unlocking ...\n",
VIPS_DEBUG_MSG( "thread %p error, unlocking #1 ...\n",
g_thread_self() );
sequential->error = -1;
g_cond_broadcast( sequential->ready );
@ -237,7 +245,7 @@ vips_sequential_generate( VipsRegion *or,
VIPS_DEBUG_MSG_GREEN( "thread %p reading ...\n", g_thread_self() );
if( vips_region_prepare( ir, r ) ||
vips_region_region( or, ir, r, r->left, r->top ) ) {
VIPS_DEBUG_MSG( "thread %p error, unlocking ...\n",
VIPS_DEBUG_MSG( "thread %p error, unlocking #2 ...\n",
g_thread_self() );
sequential->error = -1;
g_cond_broadcast( sequential->ready );