Got rid by soft means of assert() in async.c

This commit is contained in:
Thomas Schmitt 2006-10-07 06:23:31 +00:00
parent 16d3089ba8
commit 91f2a231f3
3 changed files with 92 additions and 17 deletions

View File

@ -5,6 +5,7 @@ Format:
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
Number) grep'ed line Number) grep'ed line
(++ before number means: is fully done, + means is done so far )
function(): function():
Description of abort condition. Description of abort condition.
@ -13,9 +14,11 @@ Possible callers and their relation to the abort condition.
: Error Evaluation : Error Evaluation
=> Consequences => Consequences
Eventual implementation timestamp
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
1) libburn/async.c: assert(a != NULL); /* wasn't found.. this should not be possible */ ++ 1) libburn/async.c: assert(a != NULL); /* wasn't found.. this should not be possible */
static remove_worker(): static remove_worker():
A thread describing structure (struct w_list) could not be found in A thread describing structure (struct w_list) could not be found in
order to be released. order to be released.
@ -26,12 +29,13 @@ Called by static write_disc_worker_func(), thread under API burn_disc_write()
All three want to clean up after they are done. All three want to clean up after they are done.
: Severe Libburn Error : Severe Libburn Error
=> Plain burn_finish() is admissible. => issue LIBDAX_MSGS_SEV_WARNING
=> But a mere LIBDAX_MSGS_SEV_WARNING could be justified, too.
ts A61006
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
2) libburn/async.c: assert(!(workers && workers->drive)); ++ 2) libburn/async.c: assert(!(workers && workers->drive));
API burn_drive_scan(): API burn_drive_scan():
Before spawning a thread, the function refuses work because another Before spawning a thread, the function refuses work because another
drive activity is going on. drive activity is going on.
@ -39,9 +43,11 @@ drive activity is going on.
: Severe Application Error : Severe Application Error
=> return -1; redefine @return in API , issue LIBDAX_MSGS_SEV_SORRY => return -1; redefine @return in API , issue LIBDAX_MSGS_SEV_SORRY
ts A61006
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
3) libburn/async.c: assert(workers == NULL); + 3) libburn/async.c: assert(workers == NULL);
API burn_drive_scan(): API burn_drive_scan():
After thread is done and remover_worker() succeeded, there is still a After thread is done and remover_worker() succeeded, there is still a
worker registered. Shall probably detect roguely appeared burn or worker registered. Shall probably detect roguely appeared burn or
@ -50,9 +56,11 @@ erase runs. (I consider to install a mutex shielded function for that.)
: Severe Libburn Error : Severe Libburn Error
=> Same as 1) => Same as 1)
ts A61006
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
4) libburn/async.c: assert(drive); ++ 4) libburn/async.c: assert(drive);
libburn/async.c: assert(!SCAN_GOING()); libburn/async.c: assert(!SCAN_GOING());
libburn/async.c: assert(!find_worker(drive)); libburn/async.c: assert(!find_worker(drive));
API burn_disc_erase(): API burn_disc_erase():
@ -63,9 +71,11 @@ a parallel activity on another drive.
: Severe Application Error : Severe Application Error
=> (no return value), issue LIBDAX_MSGS_SEV_SORRY => (no return value), issue LIBDAX_MSGS_SEV_SORRY
ts A61006
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
5) libburn/async.c: assert(!SCAN_GOING()); ++ 5) libburn/async.c: assert(!SCAN_GOING());
libburn/async.c: assert(!find_worker(opts->drive)); libburn/async.c: assert(!find_worker(opts->drive));
API burn_disc_write(): API burn_disc_write():
Same as 4) Same as 4)
@ -73,6 +83,8 @@ Same as 4)
: Severe Application Error : Severe Application Error
=> Same as 4) => Same as 4)
ts A61006
--------------------------------------------------------------------- ---------------------------------------------------------------------
6) libburn/drive.c: assert(d->busy == BURN_DRIVE_IDLE); 6) libburn/drive.c: assert(d->busy == BURN_DRIVE_IDLE);

View File

@ -8,9 +8,14 @@
#include "async.h" #include "async.h"
#include <pthread.h> #include <pthread.h>
#include <assert.h>
#include <stdlib.h> #include <stdlib.h>
/*
#include <a ssert.h>
*/
#include "libdax_msgs.h"
extern struct libdax_msgs *libdax_messenger;
#define SCAN_GOING() (workers && !workers->drive) #define SCAN_GOING() (workers && !workers->drive)
typedef void *(*WorkerFunc) (void *); typedef void *(*WorkerFunc) (void *);
@ -100,7 +105,13 @@ static void remove_worker(pthread_t th)
free(a); free(a);
break; break;
} }
assert(a != NULL); /* wasn't found.. this should not be possible */
/* ts A61006 */
/* a ssert(a != NULL);/ * wasn't found.. this should not be possible */
if (a == NULL)
libdax_msgs_submit(libdax_messenger, -1, 0x00020101,
LIBDAX_MSGS_SEV_WARNING, LIBDAX_MSGS_PRIO_HIGH,
"remove_worker() cannot find given worker item", 0, 0);
} }
static void *scan_worker_func(struct w_list *w) static void *scan_worker_func(struct w_list *w)
@ -116,7 +127,17 @@ int burn_drive_scan(struct burn_drive_info *drives[], unsigned int *n_drives)
int ret = 0; int ret = 0;
/* cant be anything working! */ /* cant be anything working! */
assert(!(workers && workers->drive));
/* ts A61006 */
/* a ssert(!(workers && workers->drive)); */
if (workers != NULL && workers->drive != NULL) {
libdax_msgs_submit(libdax_messenger,
workers->drive->global_index, 0x00020102,
LIBDAX_MSGS_SEV_SORRY, LIBDAX_MSGS_PRIO_HIGH,
"A drive operation is still going on (want to scan)",
0, 0);
return -1;
}
if (!workers) { if (!workers) {
/* start it */ /* start it */
@ -128,7 +149,16 @@ int burn_drive_scan(struct burn_drive_info *drives[], unsigned int *n_drives)
/* its done */ /* its done */
ret = workers->u.scan.done; ret = workers->u.scan.done;
remove_worker(workers->thread); remove_worker(workers->thread);
assert(workers == NULL);
/* ts A61006 */
/* a ssert(workers == NULL); */
if (workers != NULL)
libdax_msgs_submit(libdax_messenger, -1, 0x00020101,
LIBDAX_MSGS_SEV_WARNING, LIBDAX_MSGS_PRIO_HIGH,
"After scan a drive operation is still going on",
0, 0);
return -1;
} else { } else {
/* still going */ /* still going */
} }
@ -146,9 +176,25 @@ void burn_disc_erase(struct burn_drive *drive, int fast)
{ {
struct erase_opts o; struct erase_opts o;
assert(drive); /* ts A61006 */
assert(!SCAN_GOING()); /* a ssert(drive); */
assert(!find_worker(drive)); /* a ssert(!SCAN_GOING()); */
/* a ssert(!find_worker(drive)); */
if((drive == NULL)) {
libdax_msgs_submit(libdax_messenger, drive->global_index,
0x00020104,
LIBDAX_MSGS_SEV_SORRY, LIBDAX_MSGS_PRIO_HIGH,
"NULL pointer caught in burn_disc_erase", 0, 0);
return;
}
if ((SCAN_GOING()) || find_worker(drive)) {
libdax_msgs_submit(libdax_messenger, drive->global_index,
0x00020102,
LIBDAX_MSGS_SEV_SORRY, LIBDAX_MSGS_PRIO_HIGH,
"A drive operation is still going on (want to erase)",
0, 0);
return;
}
o.drive = drive; o.drive = drive;
o.fast = fast; o.fast = fast;
@ -171,8 +217,17 @@ void burn_disc_write(struct burn_write_opts *opts, struct burn_disc *disc)
{ {
struct write_opts o; struct write_opts o;
assert(!SCAN_GOING()); /* ts A61006 */
assert(!find_worker(opts->drive)); /* a ssert(!SCAN_GOING()); */
/* a ssert(!find_worker(opts->drive)); */
if ((SCAN_GOING()) || find_worker(opts->drive)) {
libdax_msgs_submit(libdax_messenger, opts->drive->global_index,
0x00020102,
LIBDAX_MSGS_SEV_SORRY, LIBDAX_MSGS_PRIO_HIGH,
"A drive operation is still going on (want to write)",
0, 0);
return;
}
o.drive = opts->drive; o.drive = opts->drive;
o.opts = opts; o.opts = opts;
o.disc = disc; o.disc = disc;

View File

@ -293,6 +293,8 @@ Range "elmom" : 0x00010000 to 0x0001ffff
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
Range "scdbackup" : 0x00020000 to 0x0002ffff Range "scdbackup" : 0x00020000 to 0x0002ffff
Acessing and defending drives:
0x00020001 (SORRY,LOW) = Cannot open busy device 0x00020001 (SORRY,LOW) = Cannot open busy device
0x00020002 (SORRY,HIGH) = Encountered error when closing drive 0x00020002 (SORRY,HIGH) = Encountered error when closing drive
0x00020003 (FATAL,HIGH) = Could not grab drive 0x00020003 (FATAL,HIGH) = Could not grab drive
@ -301,6 +303,12 @@ Range "scdbackup" : 0x00020000 to 0x0002ffff
0x00020006 (FATAL,HIGH) = Too many scsi siblings 0x00020006 (FATAL,HIGH) = Too many scsi siblings
0x00020007 (NOTE,HIGH) = Closed O_EXCL scsi siblings 0x00020007 (NOTE,HIGH) = Closed O_EXCL scsi siblings
From the hunt on assert:
0x00020101 (WARNING,HIGH) = Cannot find given worker item
0x00020102 (SORRY,HIGH) = A drive operation is still going on
0x00020103 (WARNING,HIGH) = After scan a drive operation is still going on
0x00020104 (SORRY,HIGH) = NULL pointer caught
------------------------------------------------------------------------------ ------------------------------------------------------------------------------