Hunted down the bug which let newapi-cdrskin fail with drive 1

This commit is contained in:
Thomas Schmitt 2006-09-09 17:22:05 +00:00
parent 596661cb3f
commit 931f2934fd
2 changed files with 59 additions and 26 deletions

View File

@ -2162,6 +2162,11 @@ int Cdrskin_reinit_lib_with_adr(struct CdrskiN *skin, int flag)
{ {
int ret; int ret;
if(skin->verbosity>=Cdrskin_verbose_debuG)
ClN(fprintf(stderr,
"cdrskin_debug: Restarting libburn. flag= %d driveno= %d grabbed= %d \n",
flag,skin->driveno,skin->drive_is_grabbed));
if(skin->drive_is_grabbed) if(skin->drive_is_grabbed)
Cdrskin_release_drive(skin,0); Cdrskin_release_drive(skin,0);
if(flag&1) if(flag&1)
@ -2180,18 +2185,34 @@ int Cdrskin_reinit_lib_with_adr(struct CdrskiN *skin, int flag)
burn_drive_info_free(skin->drives); burn_drive_info_free(skin->drives);
*/ */
if(skin->verbosity>=Cdrskin_verbose_debuG)
ClN(fprintf(stderr,"cdrskin_debug: Finishing libburn.\n"));
burn_finish(); burn_finish();
if(skin->verbosity>=Cdrskin_verbose_debuG)
ClN(fprintf(stderr,"cdrskin_debug: Initializing libburn.\n"));
if(!burn_initialize()) { if(!burn_initialize()) {
fflush(stdout); fflush(stdout);
fprintf(stderr,"cdrskin : FATAL : Re-initialization of libburn failed\n"); fprintf(stderr,"cdrskin : FATAL : Re-initialization of libburn failed\n");
{ret= -1; goto ex;} {ret= -1; goto ex;}
} }
if(skin->verbosity>=Cdrskin_verbose_debuG)
ClN(fprintf(stderr,"cdrskin_debug: Grabbing drive.\n"));
ret= Cdrskin_grab_drive(skin,1|(flag&2));/* uses burn_drive_scan_and_grab() */ ret= Cdrskin_grab_drive(skin,1|(flag&2));/* uses burn_drive_scan_and_grab() */
if(ret<=0) if(ret<=0)
{ret=0; goto ex;} {ret=0; goto ex;}
ret= 1; ret= 1;
ex: ex:
if(skin->verbosity>=Cdrskin_verbose_debuG)
ClN(fprintf(stderr,"cdrskin_debug: Restarting of libburn done. ret= %d\n",
ret));
return(ret); return(ret);
} }
@ -2202,6 +2223,8 @@ ex:
gets shutdown and restarted with the wanted drive only. Thus, after gets shutdown and restarted with the wanted drive only. Thus, after
this call, libburn is supposed to have open only the grabbed drive. this call, libburn is supposed to have open only the grabbed drive.
All other drives should be free for other use. All other drives should be free for other use.
Warning: Do not store struct burn_drive pointer over this call.
Any such pointer might be invalid afterwards.
@param flag Bitfield for control purposes: @param flag Bitfield for control purposes:
bit0= bus is unscanned, device is known, bit0= bus is unscanned, device is known,
use burn_drive_scan_and_grab() use burn_drive_scan_and_grab()
@ -2219,8 +2242,14 @@ int Cdrskin_grab_drive(struct CdrskiN *skin, int flag)
if(skin->drive_is_grabbed) if(skin->drive_is_grabbed)
Cdrskin_release_drive(skin,0); Cdrskin_release_drive(skin,0);
drive= skin->drives[skin->driveno].drive; if(flag&1) {
skin->grabbed_drive= drive; skin->driveno= 0;
drive= NULL;
skin->grabbed_drive= drive;
} else {
drive= skin->drives[skin->driveno].drive;
skin->grabbed_drive= drive;
}
#ifdef Cdrskin_grab_abort_brokeN #ifdef Cdrskin_grab_abort_brokeN
@ -2245,32 +2274,29 @@ int Cdrskin_grab_drive(struct CdrskiN *skin, int flag)
if(flag&1) { if(flag&1) {
/* if(skin->verbosity>=Cdrskin_verbose_debuG)
fprintf(stderr, ClN(fprintf(stderr,
"cdrskin: experimental: Cdrskin_grab_drive() from shutdown libburn\n"); "cdrskin_debug: Cdrskin_grab_drive() from shutdown libburn\n"));
*/
ret= burn_drive_scan_and_grab(&(skin->drives),skin->preskin->device_adr, ret= burn_drive_scan_and_grab(&(skin->drives),skin->preskin->device_adr,
!(flag&2)); !(flag&2));
if(ret<=0) { if(ret<=0) {
/* if(skin->verbosity>=Cdrskin_verbose_debuG)
fprintf(stderr,"cdrskin: experimental: burn_drive_scan_and_grab ret=%d\n", ClN(fprintf(stderr,
ret); "cdrskin_debug: burn_drive_scan_and_grab ret=%d\n",ret));
*/
fprintf(stderr,"cdrskin: FATAL : unable to open drive '%s'\n", fprintf(stderr,"cdrskin: FATAL : unable to open drive '%s'\n",
skin->preskin->device_adr); skin->preskin->device_adr);
goto ex; goto ex;
} }
skin->driveno= 0; skin->driveno= 0;
drive= skin->drives[skin->driveno].drive;
skin->grabbed_drive= drive;
} else { } else {
/* if(skin->verbosity>=Cdrskin_verbose_debuG)
fprintf(stderr, ClN(fprintf(stderr,
"cdrskin: experimental: Cdrskin_grab_drive() on active libburn\n"); "cdrskin_debug: Cdrskin_grab_drive() on active libburn\n"));
*/
if(strlen(skin->preskin->device_adr)<=0) { if(strlen(skin->preskin->device_adr)<=0) {
/*
fprintf(stderr,
"cdrskin: experimental: Cdrskin_grab_drive() restarting libburn\n");
*/
ret= Cdrskin_reinit_lib_with_adr(skin,1|(flag&2)); ret= Cdrskin_reinit_lib_with_adr(skin,1|(flag&2));
goto ex; /* this calls Cdrskin_grab() with persistent address or fails */ goto ex; /* this calls Cdrskin_grab() with persistent address or fails */
} }
@ -2779,10 +2805,10 @@ int Cdrskin_atip(struct CdrskiN *skin, int flag)
ret= Cdrskin_checkdrive(skin,1); ret= Cdrskin_checkdrive(skin,1);
if(ret<=0) if(ret<=0)
return(ret); return(ret);
drive= skin->drives[skin->driveno].drive;
ret= Cdrskin_grab_drive(skin,0); ret= Cdrskin_grab_drive(skin,0);
if(ret<=0) if(ret<=0)
return(ret); return(ret);
drive= skin->drives[skin->driveno].drive;
while(burn_drive_get_status(drive,NULL)) while(burn_drive_get_status(drive,NULL))
sleep(2); sleep(2);
while ((s = burn_disc_get_status(drive)) == BURN_DISC_UNREADY) while ((s = burn_disc_get_status(drive)) == BURN_DISC_UNREADY)
@ -2807,10 +2833,9 @@ int Cdrskin_atip(struct CdrskiN *skin, int flag)
#ifdef Cdrskin_new_api_tesT #ifdef Cdrskin_new_api_tesT
/* if(skin->verbosity>=Cdrskin_verbose_debuG)
fprintf(stderr, ClN(fprintf(stderr,
"cdrskin: experimental: Cdrskin_atip() on Cdrskin_new_api_tesT\n"); "cdrskin_debug: Cdrskin_atip() on Cdrskin_new_api_tesT\n"));
*/
if(strlen(skin->preskin->device_adr)<=0) if(strlen(skin->preskin->device_adr)<=0)
burn_drive_get_adr(&(skin->drives[skin->driveno]), burn_drive_get_adr(&(skin->drives[skin->driveno]),
@ -2826,6 +2851,7 @@ int Cdrskin_atip(struct CdrskiN *skin, int flag)
ret= Cdrskin_grab_drive(skin,1); /* uses burn_drive_scan_and_grab() */ ret= Cdrskin_grab_drive(skin,1); /* uses burn_drive_scan_and_grab() */
if(ret<=0) if(ret<=0)
return(ret); return(ret);
drive= skin->drives[skin->driveno].drive;
#else /* Cdrskin_new_api_tesT */ #else /* Cdrskin_new_api_tesT */
@ -2839,10 +2865,10 @@ int Cdrskin_atip(struct CdrskiN *skin, int flag)
if(strlen(skin->preskin->device_adr)>0) if(strlen(skin->preskin->device_adr)>0)
burn_drive_add_whitelist(skin->preskin->device_adr); burn_drive_add_whitelist(skin->preskin->device_adr);
while (!burn_drive_scan(&(skin->drives), &(skin->n_drives))) ; while (!burn_drive_scan(&(skin->drives), &(skin->n_drives))) ;
drive= skin->drives[skin->driveno].drive;
ret= Cdrskin_grab_drive(skin,0); ret= Cdrskin_grab_drive(skin,0);
if(ret<=0) if(ret<=0)
return(ret); return(ret);
drive= skin->drives[skin->driveno].drive;
#endif /* ! Cdrskin_new_api_tesT */ #endif /* ! Cdrskin_new_api_tesT */
@ -2928,10 +2954,10 @@ int Cdrskin_blank(struct CdrskiN *skin, int flag)
double start_time; double start_time;
start_time= Sfile_microtime(0); /* will be refreshed later */ start_time= Sfile_microtime(0); /* will be refreshed later */
drive= skin->drives[skin->driveno].drive;
ret= Cdrskin_grab_drive(skin,0); ret= Cdrskin_grab_drive(skin,0);
if(ret<=0) if(ret<=0)
return(ret); return(ret);
drive= skin->drives[skin->driveno].drive;
while(burn_drive_get_status(drive,NULL)) while(burn_drive_get_status(drive,NULL))
sleep(2); sleep(2);
@ -3290,7 +3316,6 @@ int Cdrskin_burn(struct CdrskiN *skin, int flag)
printf("cdrskin: beginning to burn disk\n"); printf("cdrskin: beginning to burn disk\n");
drive= skin->drives[skin->driveno].drive;
disc= burn_disc_create(); disc= burn_disc_create();
session= burn_session_create(); session= burn_session_create();
burn_disc_add_session(disc,session,BURN_POS_END); burn_disc_add_session(disc,session,BURN_POS_END);
@ -3313,6 +3338,7 @@ int Cdrskin_burn(struct CdrskiN *skin, int flag)
ret= Cdrskin_grab_drive(skin,0); ret= Cdrskin_grab_drive(skin,0);
if(ret<=0) if(ret<=0)
return(ret); return(ret);
drive= skin->drives[skin->driveno].drive;
while (burn_drive_get_status(drive, NULL)) while (burn_drive_get_status(drive, NULL))
sleep(2); /* >>> ??? add a timeout ? */ sleep(2); /* >>> ??? add a timeout ? */

View File

@ -622,9 +622,16 @@ int burn_drive_scan_and_grab(struct burn_drive_info *drive_infos[], char* adr,
burn_drive_clear_whitelist(); burn_drive_clear_whitelist();
burn_drive_add_whitelist(adr); burn_drive_add_whitelist(adr);
/*
fprintf(stderr,"libburn: experimental: burn_drive_scan_and_grab(%s)\n",
adr);
*/
while (!burn_drive_scan(drive_infos, &n_drives)); while (!burn_drive_scan(drive_infos, &n_drives));
if (n_drives <= 0) if (n_drives <= 0)
return 0; return 0;
/*
fprintf(stderr, "libburn: experimental: n_drives == %d\n",n_drives);
*/
/* ts A60908 : seems we get rid of this :) */ /* ts A60908 : seems we get rid of this :) */
#ifdef Libburn_grab_release_and_grab_agaiN #ifdef Libburn_grab_release_and_grab_agaiN