libextractor

GNU libextractor
Log | Files | Refs | Submodules | README | LICENSE

commit 7bca31aa6999d987f509a60bbbf9348e3c485906
parent 8ac48d575a488bb8e20494b285b611656dc97787
Author: Christian Grothoff <christian@grothoff.org>
Date:   Sun,  5 Aug 2012 18:29:23 +0000

fixing two bugs

Diffstat:
Msrc/main/extractor.c | 20++++++++++++++++----
Msrc/main/extractor_ipc.c | 2+-
Msrc/main/extractor_ipc_gnu.c | 1+
Msrc/main/extractor_plugin_main.c | 8+++++---
Msrc/main/test2_extractor.c | 17-----------------
5 files changed, 23 insertions(+), 25 deletions(-)

diff --git a/src/main/extractor.c b/src/main/extractor.c @@ -458,8 +458,14 @@ do_extract (struct EXTRACTOR_PluginList *plugins, plugin_count = 0; for (pos = plugins; NULL != pos; pos = pos->next) { - if (NULL == channels[plugin_count]) - pos->channel = NULL; + if ( (NULL == channels[plugin_count]) && + (-1 == pos->seek_request) ) + { + /* EXTRACTOR_IPC_channel_recv_ got a non-NULL channel (-1 == seek_request) + but set it to NULL; that means the channel had an IPC error and was closed; + so we need to update the plugin accordingly */ + pos->channel = NULL; + } plugin_count++; if ( (1 == pos->round_finished) || (NULL == pos->channel) ) @@ -495,6 +501,7 @@ do_extract (struct EXTRACTOR_PluginList *plugins, } } } + data_available = -1; if ( (1 == done) && (-1 != min_seek) ) { @@ -516,7 +523,10 @@ do_extract (struct EXTRACTOR_PluginList *plugins, for (pos = plugins; NULL != pos; pos = pos->next) { if (NULL == (channel = pos->channel)) - continue; + { + /* Skipping plugin: channel down */ + continue; + } if ( (-1 != pos->seek_request) && (1 == prp.file_finished) ) { @@ -524,11 +534,13 @@ do_extract (struct EXTRACTOR_PluginList *plugins, pos->round_finished = 1; pos->seek_request = -1; } - if ( (-1 != pos->seek_request) && + if ( (-1 != data_available) && + (-1 != pos->seek_request) && (min_seek <= pos->seek_request) && ( (min_seek + data_available > pos->seek_request) || (min_seek == EXTRACTOR_datasource_get_size_ (ds, 0))) ) { + /* Notify plugin about seek to 'min_seek' */ send_update_message (pos, min_seek, data_available, diff --git a/src/main/extractor_ipc.c b/src/main/extractor_ipc.c @@ -85,7 +85,7 @@ EXTRACTOR_IPC_process_reply_ (struct EXTRACTOR_PluginList *plugin, return -1; /* not allowing more than MAX_META_DATA meta data */ } if (size < sizeof (meta) + meta.mime_length + meta.value_size) - { + { plugin->seek_request = -1; return 0; } diff --git a/src/main/extractor_ipc_gnu.c b/src/main/extractor_ipc_gnu.c @@ -508,6 +508,7 @@ EXTRACTOR_IPC_channel_recv_ (struct EXTRACTOR_Channel **channels, { if (-1 == iret) LOG_STRERROR ("read"); + LOG ("Read error from channel, closing channel %d\n", i+1); EXTRACTOR_IPC_channel_destroy_ (channel); channels[i] = NULL; } diff --git a/src/main/extractor_plugin_main.c b/src/main/extractor_plugin_main.c @@ -194,7 +194,8 @@ plugin_env_seek (void *cls, EXTRACTOR_read_all_ (pc->in, &reply, sizeof (reply))) { - LOG ("Failed to read response to MESSAGE_SEEK\n"); + LOG ("Plugin `%s' failed to read response to MESSAGE_SEEK\n", + pc->plugin->short_libname); return -1; } if (MESSAGE_UPDATED_SHM != reply) @@ -215,7 +216,7 @@ plugin_env_seek (void *cls, /* convert offset to be absolute from beginning of the file */ npos = pc->file_size - npos; } - if ( (pc->shm_off <= npos) && + if ( (pc->shm_off <= npos) && ((pc->shm_off + pc->shm_ready_bytes > npos) || (pc->file_size == pc->shm_off)) ) { @@ -224,7 +225,8 @@ plugin_env_seek (void *cls, } /* oops, serious missunderstanding, we asked to seek and then were notified about a different position!? */ - LOG ("Got invalid MESSAGE_UPDATED_SHM in response to my %d-seek (%llu not in %llu-%llu)\n", + LOG ("Plugin `%s' got invalid MESSAGE_UPDATED_SHM in response to my %d-seek (%llu not in %llu-%llu)\n", + pc->plugin->short_libname, (int) wval, (unsigned long long) npos, (unsigned long long) pc->shm_off, diff --git a/src/main/test2_extractor.c b/src/main/test2_extractor.c @@ -123,23 +123,6 @@ EXTRACTOR_test2_extract_method (struct EXTRACTOR_ExtractContext *ec) fprintf (stderr, "Unexpected data at offset 150k - 3\n"); ABORT (); } - if (0 != ec->proc (ec->cls, "test2", EXTRACTOR_METATYPE_COMMENT, - EXTRACTOR_METAFORMAT_UTF8, "<no mime>", "Hello world!", - strlen ("Hello world!") + 1)) - { - fprintf (stderr, "Unexpected return value from 'proc'\n"); - ABORT (); - } - /* The test assumes that client orders us to stop extraction - * after seeing "Goodbye!". - */ - if (1 != ec->proc (ec->cls, "test2", EXTRACTOR_METATYPE_COMMENT, - EXTRACTOR_METAFORMAT_UTF8, "<no mime>", "Goodbye!", - strlen ("Goodbye!") + 1)) - { - fprintf (stderr, "Unexpected return value from 'proc'\n"); - ABORT (); - } } /* end of test2_extractor.c */