Changeset 3105

Show
Ignore:
Timestamp:
03/05/10 12:59:21 (6 months ago)
Author:
scdbackup
Message:

Protected blanker and formatter thread from signals

Location:
libburn/trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • libburn/trunk/cdrskin/cdrskin_timestamp.h

    r3104 r3105  
    1 #define Cdrskin_timestamP "2010.03.05.111712" 
     1#define Cdrskin_timestamP "2010.03.05.190110" 
  • libburn/trunk/libburn/async.c

    r3102 r3105  
    319319static void *erase_worker_func(struct w_list *w) 
    320320{ 
     321 
     322#define Libburn_protect_erase_threaD 1 
     323 
     324#ifdef Libburn_protect_erase_threaD 
     325        sigset_t sigset, oldset; 
     326 
     327        /* Protect blank thread from being interrupted by external signals */ 
     328        sigfillset(&sigset); 
     329        sigdelset(&sigset, SIGSEGV); 
     330        sigdelset(&sigset, SIGILL); 
     331        pthread_sigmask(SIG_SETMASK, &sigset, &oldset); 
     332#endif /* Libburn_protect_erase_threaD */ 
     333 
    321334        burn_disc_erase_sync(w->u.erase.drive, w->u.erase.fast); 
    322335        remove_worker(pthread_self()); 
     336 
     337#ifdef Libburn_protect_erase_threaD 
     338        /* (just in case it would not end with all signals blocked) */ 
     339        pthread_sigmask(SIG_SETMASK, &oldset, NULL); 
     340#endif /* Libburn_protect_erase_threaD */ 
     341 
    323342        return NULL; 
    324343} 
     
    391410static void *format_worker_func(struct w_list *w) 
    392411{ 
     412 
     413#define Libburn_protect_format_threaD 1 
     414 
     415#ifdef Libburn_protect_format_threaD 
     416        sigset_t sigset, oldset; 
     417 
     418        /* Protect format thread from being interrupted by external signals */ 
     419        sigfillset(&sigset); 
     420        sigdelset(&sigset, SIGSEGV); 
     421        sigdelset(&sigset, SIGILL); 
     422        pthread_sigmask(SIG_SETMASK, &sigset, &oldset); 
     423#endif /* Libburn_protect_format_threaD */ 
     424 
    393425        burn_disc_format_sync(w->u.format.drive, w->u.format.size, 
    394426                                w->u.format.flag); 
    395427        remove_worker(pthread_self()); 
     428 
     429#ifdef Libburn_protect_format_threaD 
     430        /* (just in case it would not end with all signals blocked) */ 
     431        pthread_sigmask(SIG_SETMASK, &oldset, NULL); 
     432#endif /* Libburn_protect_format_threaD */ 
     433 
    396434        return NULL; 
    397435} 
     
    566604                        msg, 0, 0); 
    567605 
     606        remove_worker(pthread_self()); 
     607        d->busy = BURN_DRIVE_IDLE; 
     608 
    568609#ifdef Libburn_protect_write_threaD 
    569610        /* (just in case it would not end with all signals blocked) */ 
     
    571612#endif /* Libburn_protect_write_threaD */ 
    572613 
    573         remove_worker(pthread_self()); 
    574         d->busy = BURN_DRIVE_IDLE; 
    575614        return NULL; 
    576615} 
     
    665704        int old; 
    666705 
    667         pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &old); 
    668         pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &old); 
    669                 /* Note: Only burn_fifo_abort() shall cancel the fifo thread */ 
    670  
    671         burn_fifo_source_shoveller(w->u.fifo.source, w->u.fifo.flag); 
    672         remove_worker(pthread_self()); 
    673         return NULL; 
    674 } 
    675  
    676  
    677 int burn_fifo_start(struct burn_source *source, int flag) 
    678 { 
    679         struct fifo_opts o; 
    680         struct burn_source_fifo *fs = source->data; 
    681  
    682706#define Libburn_protect_fifo_threaD 1 
    683707 
     
    685709        sigset_t sigset, oldset; 
    686710 
    687         /* Protect write thread from being interrupted by external signals */ 
     711        /* Protect fifo thread from being interrupted by external signals */ 
    688712        sigfillset(&sigset); 
    689713        sigdelset(&sigset, SIGSEGV); 
     
    691715        pthread_sigmask(SIG_SETMASK, &sigset, &oldset); 
    692716#endif /* Libburn_protect_fifo_threaD */ 
     717 
     718        pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &old); 
     719        pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &old); 
     720                /* Note: Only burn_fifo_abort() shall cancel the fifo thread */ 
     721 
     722        burn_fifo_source_shoveller(w->u.fifo.source, w->u.fifo.flag); 
     723        remove_worker(pthread_self()); 
     724 
     725#ifdef Libburn_protect_fifo_threaD 
     726        /* (just in case it would not end with all signals blocked) */ 
     727        pthread_sigmask(SIG_SETMASK, &oldset, NULL); 
     728#endif /* Libburn_protect_fifo_threaD */ 
     729 
     730        return NULL; 
     731} 
     732 
     733 
     734int burn_fifo_start(struct burn_source *source, int flag) 
     735{ 
     736        struct fifo_opts o; 
     737        struct burn_source_fifo *fs = source->data; 
    693738 
    694739        fs->is_started = -1; 
     
    708753        fs->is_started = 1; 
    709754 
    710 #ifdef Libburn_protect_fifo_threaD 
    711         /* (just in case it would not end with all signals blocked) */ 
    712         pthread_sigmask(SIG_SETMASK, &oldset, NULL); 
    713 #endif /* Libburn_protect_fifo_threaD */ 
    714  
    715755        return 1; 
    716756}