diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-08-04 01:01:10 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-08-04 01:01:10 +0000 |
commit | 14f8181fe2edef2dbfa6606ec55718f00b79f660 (patch) | |
tree | 61fd9db305ac49bcb02ce8b4590146fe0bc94eae | |
parent | fdc5ca9b7e4037c1db48e85e0d5c97a39aaa8db6 (diff) | |
download | libextractor-14f8181fe2edef2dbfa6606ec55718f00b79f660.tar.gz libextractor-14f8181fe2edef2dbfa6606ec55718f00b79f660.zip |
-bugfixes
-rw-r--r-- | src/main/TODO | 2 | ||||
-rw-r--r-- | src/main/extractor.c | 36 | ||||
-rw-r--r-- | src/main/extractor_ipc_gnu.c | 7 | ||||
-rw-r--r-- | src/main/extractor_plugin_main.c | 23 | ||||
-rw-r--r-- | src/main/extractor_plugins.c | 23 |
5 files changed, 62 insertions, 29 deletions
diff --git a/src/main/TODO b/src/main/TODO index 4527caf..73dafe7 100644 --- a/src/main/TODO +++ b/src/main/TODO | |||
@@ -3,3 +3,5 @@ | |||
3 | * testcases for extract-from-file, extract-from-gz-file, extract-from-bz2-file | 3 | * testcases for extract-from-file, extract-from-gz-file, extract-from-bz2-file |
4 | * testcases for running multiple files in one run (known to fail!) | 4 | * testcases for running multiple files in one run (known to fail!) |
5 | 5 | ||
6 | * MAX_META_DATA buffer of 32 MB is a bit big as a non-growing default size; | ||
7 | also, valgrind reports it is leaked even though printf-debugging shows it is not (!?) \ No newline at end of file | ||
diff --git a/src/main/extractor.c b/src/main/extractor.c index da75e71..d3bf0a8 100644 --- a/src/main/extractor.c +++ b/src/main/extractor.c | |||
@@ -414,15 +414,21 @@ do_extract (struct EXTRACTOR_PluginList *plugins, | |||
414 | while (! done) | 414 | while (! done) |
415 | { | 415 | { |
416 | struct EXTRACTOR_Channel *channels[plugin_count]; | 416 | struct EXTRACTOR_Channel *channels[plugin_count]; |
417 | 417 | ||
418 | /* calculate current 'channels' array */ | 418 | /* calculate current 'channels' array */ |
419 | plugin_count = 0; | 419 | plugin_count = 0; |
420 | for (pos = plugins; NULL != pos; pos = pos->next) | 420 | for (pos = plugins; NULL != pos; pos = pos->next) |
421 | { | 421 | { |
422 | if (-1 != pos->seek_request) | 422 | if (-1 == pos->seek_request) |
423 | channels[plugin_count] = pos->channel; | 423 | { |
424 | /* channel is not seeking, must be running or done */ | ||
425 | channels[plugin_count] = pos->channel; | ||
426 | } | ||
424 | else | 427 | else |
425 | channels[plugin_count] = NULL; /* not running this round, seeking! */ | 428 | { |
429 | /* not running this round, seeking! */ | ||
430 | channels[plugin_count] = NULL; | ||
431 | } | ||
426 | plugin_count++; | 432 | plugin_count++; |
427 | } | 433 | } |
428 | 434 | ||
@@ -438,6 +444,7 @@ do_extract (struct EXTRACTOR_PluginList *plugins, | |||
438 | abort_all_channels (plugins); | 444 | abort_all_channels (plugins); |
439 | break; | 445 | break; |
440 | } | 446 | } |
447 | |||
441 | /* calculate minimum seek request (or set done=0 to continue here) */ | 448 | /* calculate minimum seek request (or set done=0 to continue here) */ |
442 | done = 1; | 449 | done = 1; |
443 | min_seek = -1; | 450 | min_seek = -1; |
@@ -482,24 +489,26 @@ do_extract (struct EXTRACTOR_PluginList *plugins, | |||
482 | { | 489 | { |
483 | if (NULL == (channel = pos->channel)) | 490 | if (NULL == (channel = pos->channel)) |
484 | continue; | 491 | continue; |
492 | if ( (-1 != pos->seek_request) && | ||
493 | (1 == prp.file_finished) ) | ||
494 | { | ||
495 | send_discard_message (pos); | ||
496 | pos->round_finished = 1; | ||
497 | pos->seek_request = -1; | ||
498 | } | ||
485 | if ( (-1 != pos->seek_request) && ((last_position > pos->seek_request) || | 499 | if ( (-1 != pos->seek_request) && ((last_position > pos->seek_request) || |
486 | (last_position + data_available <= pos->seek_request)) && | 500 | (last_position + data_available <= pos->seek_request)) && |
487 | (min_seek <= pos->seek_request) && | 501 | (min_seek <= pos->seek_request) && |
488 | ((min_seek + data_available > pos->seek_request) || | 502 | ((min_seek + data_available > pos->seek_request) || |
489 | (min_seek == EXTRACTOR_datasource_get_size_ (ds))) ) | 503 | (min_seek == EXTRACTOR_datasource_get_size_ (ds))) ) |
490 | { | 504 | { |
505 | LOG ("Sending update message\n"); | ||
491 | send_update_message (pos, | 506 | send_update_message (pos, |
492 | min_seek, | 507 | min_seek, |
493 | data_available, | 508 | data_available, |
494 | ds); | 509 | ds); |
495 | /*pos->seek_request = -1;*/ | 510 | pos->seek_request = -1; |
496 | } | 511 | } |
497 | if ( (-1 != pos->seek_request) && | ||
498 | (1 == prp.file_finished) ) | ||
499 | { | ||
500 | send_discard_message (pos); | ||
501 | pos->round_finished = 1; | ||
502 | } | ||
503 | if (0 == pos->round_finished) | 512 | if (0 == pos->round_finished) |
504 | done = 0; /* can't be done, plugin still active */ | 513 | done = 0; /* can't be done, plugin still active */ |
505 | } | 514 | } |
@@ -576,10 +585,11 @@ EXTRACTOR_extract (struct EXTRACTOR_PluginList *plugins, | |||
576 | have_oop = 0; | 585 | have_oop = 0; |
577 | for (pos = plugins; NULL != pos; pos = pos->next) | 586 | for (pos = plugins; NULL != pos; pos = pos->next) |
578 | { | 587 | { |
579 | if (NULL != (shm = pos->shm)) | 588 | if (NULL == shm) |
580 | break; | 589 | shm = pos->shm; |
581 | if (EXTRACTOR_OPTION_IN_PROCESS != pos->flags) | 590 | if (EXTRACTOR_OPTION_IN_PROCESS != pos->flags) |
582 | have_oop = 1; | 591 | have_oop = 1; |
592 | pos->round_finished = 0; | ||
583 | } | 593 | } |
584 | if ( (NULL == shm) && | 594 | if ( (NULL == shm) && |
585 | (1 == have_oop) ) | 595 | (1 == have_oop) ) |
diff --git a/src/main/extractor_ipc_gnu.c b/src/main/extractor_ipc_gnu.c index 6ef6013..34a9699 100644 --- a/src/main/extractor_ipc_gnu.c +++ b/src/main/extractor_ipc_gnu.c | |||
@@ -236,6 +236,7 @@ EXTRACTOR_IPC_shared_memory_set_ (struct EXTRACTOR_SharedMemory *shm, | |||
236 | size); | 236 | size); |
237 | } | 237 | } |
238 | 238 | ||
239 | |||
239 | /** | 240 | /** |
240 | * Query datasource for current position | 241 | * Query datasource for current position |
241 | * | 242 | * |
@@ -251,6 +252,7 @@ EXTRACTOR_datasource_get_pos_ (struct EXTRACTOR_Datasource *ds) | |||
251 | return pos; | 252 | return pos; |
252 | } | 253 | } |
253 | 254 | ||
255 | |||
254 | /** | 256 | /** |
255 | * Create a channel to communicate with a process wrapping | 257 | * Create a channel to communicate with a process wrapping |
256 | * the plugin of the given name. Starts the process as well. | 258 | * the plugin of the given name. Starts the process as well. |
@@ -440,7 +442,10 @@ EXTRACTOR_IPC_channel_recv_ (struct EXTRACTOR_Channel **channels, | |||
440 | max = channel->cpipe_out; | 442 | max = channel->cpipe_out; |
441 | } | 443 | } |
442 | if (-1 == max) | 444 | if (-1 == max) |
443 | return 1; /* nothing left to do! */ | 445 | { |
446 | LOG ("No channels to select on...\n"); | ||
447 | return 1; /* nothing left to do! */ | ||
448 | } | ||
444 | tv.tv_sec = 10; | 449 | tv.tv_sec = 10; |
445 | tv.tv_usec = 0; | 450 | tv.tv_usec = 0; |
446 | if (-1 == select (max + 1, &to_check, NULL, NULL, &tv)) | 451 | if (-1 == select (max + 1, &to_check, NULL, NULL, &tv)) |
diff --git a/src/main/extractor_plugin_main.c b/src/main/extractor_plugin_main.c index f9eed28..10dcbac 100644 --- a/src/main/extractor_plugin_main.c +++ b/src/main/extractor_plugin_main.c | |||
@@ -318,8 +318,13 @@ plugin_env_send_proc (void *cls, | |||
318 | LOG ("Failed to read response to meta message\n"); | 318 | LOG ("Failed to read response to meta message\n"); |
319 | return 1; | 319 | return 1; |
320 | } | 320 | } |
321 | if (MESSAGE_CONTINUE_EXTRACTING != reply) | 321 | if (MESSAGE_DISCARD_STATE == reply) |
322 | return 1; | 322 | return 1; |
323 | if (MESSAGE_CONTINUE_EXTRACTING != reply) | ||
324 | { | ||
325 | LOG ("Received unexpected reply to meta data: %d\n", reply); | ||
326 | return 1; | ||
327 | } | ||
323 | return 0; | 328 | return 0; |
324 | } | 329 | } |
325 | 330 | ||
@@ -467,7 +472,7 @@ process_requests (struct ProcessingContext *pc) | |||
467 | while (1) | 472 | while (1) |
468 | { | 473 | { |
469 | unsigned char code; | 474 | unsigned char code; |
470 | 475 | ||
471 | if (1 != EXTRACTOR_read_all_ (pc->in, &code, 1)) | 476 | if (1 != EXTRACTOR_read_all_ (pc->in, &code, 1)) |
472 | { | 477 | { |
473 | LOG ("Failed to read next request\n"); | 478 | LOG ("Failed to read next request\n"); |
@@ -477,12 +482,20 @@ process_requests (struct ProcessingContext *pc) | |||
477 | { | 482 | { |
478 | case MESSAGE_INIT_STATE: | 483 | case MESSAGE_INIT_STATE: |
479 | if (0 != handle_init_message (pc)) | 484 | if (0 != handle_init_message (pc)) |
480 | return; | 485 | { |
486 | LOG ("Failure to handle INIT\n"); | ||
487 | return; | ||
488 | } | ||
481 | break; | 489 | break; |
482 | case MESSAGE_EXTRACT_START: | 490 | case MESSAGE_EXTRACT_START: |
483 | if (0 != handle_start_message (pc)) | 491 | if (0 != handle_start_message (pc)) |
484 | return; | 492 | { |
493 | LOG ("Failure to handle START\n"); | ||
494 | return; | ||
495 | } | ||
496 | break; | ||
485 | case MESSAGE_UPDATED_SHM: | 497 | case MESSAGE_UPDATED_SHM: |
498 | LOG ("Illegal message\n"); | ||
486 | /* not allowed here, we're not waiting for SHM to move! */ | 499 | /* not allowed here, we're not waiting for SHM to move! */ |
487 | return; | 500 | return; |
488 | case MESSAGE_DISCARD_STATE: | 501 | case MESSAGE_DISCARD_STATE: |
@@ -579,6 +592,8 @@ EXTRACTOR_plugin_main_ (struct EXTRACTOR_PluginList *plugin, | |||
579 | pc.shm = NULL; | 592 | pc.shm = NULL; |
580 | pc.shm_map_size = 0; | 593 | pc.shm_map_size = 0; |
581 | process_requests (&pc); | 594 | process_requests (&pc); |
595 | LOG ("IPC error; plugin `%s' terminates!\n", | ||
596 | plugin->short_libname); | ||
582 | #if WINDOWS | 597 | #if WINDOWS |
583 | if (NULL != pc.shm) | 598 | if (NULL != pc.shm) |
584 | UnmapViewOfFile (pc.shm); | 599 | UnmapViewOfFile (pc.shm); |
diff --git a/src/main/extractor_plugins.c b/src/main/extractor_plugins.c index 3e77bae..ddff7d9 100644 --- a/src/main/extractor_plugins.c +++ b/src/main/extractor_plugins.c | |||
@@ -208,7 +208,7 @@ EXTRACTOR_plugin_add (struct EXTRACTOR_PluginList *prev, | |||
208 | const char *options, | 208 | const char *options, |
209 | enum EXTRACTOR_Options flags) | 209 | enum EXTRACTOR_Options flags) |
210 | { | 210 | { |
211 | struct EXTRACTOR_PluginList *result; | 211 | struct EXTRACTOR_PluginList *plugin; |
212 | struct EXTRACTOR_PluginList *pos; | 212 | struct EXTRACTOR_PluginList *pos; |
213 | char *libname; | 213 | char *libname; |
214 | 214 | ||
@@ -221,22 +221,23 @@ EXTRACTOR_plugin_add (struct EXTRACTOR_PluginList *prev, | |||
221 | library); | 221 | library); |
222 | return prev; | 222 | return prev; |
223 | } | 223 | } |
224 | if (NULL == (result = malloc (sizeof (struct EXTRACTOR_PluginList)))) | 224 | if (NULL == (plugin = malloc (sizeof (struct EXTRACTOR_PluginList)))) |
225 | return prev; | 225 | return prev; |
226 | memset (result, 0, sizeof (struct EXTRACTOR_PluginList)); | 226 | memset (plugin, 0, sizeof (struct EXTRACTOR_PluginList)); |
227 | result->next = prev; | 227 | plugin->next = prev; |
228 | if (NULL == (result->short_libname = strdup (library))) | 228 | if (NULL == (plugin->short_libname = strdup (library))) |
229 | { | 229 | { |
230 | free (result); | 230 | free (plugin); |
231 | return NULL; | 231 | return NULL; |
232 | } | 232 | } |
233 | result->libname = libname; | 233 | plugin->libname = libname; |
234 | result->flags = flags; | 234 | plugin->flags = flags; |
235 | if (NULL != options) | 235 | if (NULL != options) |
236 | result->plugin_options = strdup (options); | 236 | plugin->plugin_options = strdup (options); |
237 | else | 237 | else |
238 | result->plugin_options = NULL; | 238 | plugin->plugin_options = NULL; |
239 | return result; | 239 | plugin->seek_request = -1; |
240 | return plugin; | ||
240 | } | 241 | } |
241 | 242 | ||
242 | 243 | ||