diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-07-30 10:40:30 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-07-30 10:40:30 +0000 |
commit | e811bdfae440d834eb3b5c18bda7cb6ccae103f7 (patch) | |
tree | c1e40edd16b4d18b80dbf5d05e85aea0a6e2ad69 | |
parent | 29dbb0e97a84fcaede9d333450053e61f4a24a1b (diff) | |
download | libextractor-e811bdfae440d834eb3b5c18bda7cb6ccae103f7.tar.gz libextractor-e811bdfae440d834eb3b5c18bda7cb6ccae103f7.zip |
new code could now work in theory, but untested and features missing
-rw-r--r-- | src/main/extractor.c | 89 |
1 files changed, 37 insertions, 52 deletions
diff --git a/src/main/extractor.c b/src/main/extractor.c index 29294a2..126a539 100644 --- a/src/main/extractor.c +++ b/src/main/extractor.c | |||
@@ -37,56 +37,6 @@ | |||
37 | #define DEFAULT_SHM_SIZE (16 * 1024) | 37 | #define DEFAULT_SHM_SIZE (16 * 1024) |
38 | 38 | ||
39 | 39 | ||
40 | #if 0 | ||
41 | /** | ||
42 | * Checks the seek requests that plugins made, finds the one with | ||
43 | * smallest offset from the beginning of the stream, and satisfies it. | ||
44 | * | ||
45 | * @param plugins to check | ||
46 | * @param cfs compressed file source to seek in | ||
47 | * @param current_position current stream position | ||
48 | * @param map_size number of bytes currently buffered | ||
49 | * @return new stream position, -1 on error | ||
50 | */ | ||
51 | static int64_t | ||
52 | seek_to_new_position (struct EXTRACTOR_PluginList *plugins, | ||
53 | struct CompressedFileSource *cfs, | ||
54 | int64_t current_position, | ||
55 | int64_t map_size) | ||
56 | { | ||
57 | int64_t min_pos = current_position + map_size; | ||
58 | int64_t min_plugin_pos = 0x7FFFFFFFFFFFFFF; | ||
59 | struct EXTRACTOR_PluginList *ppos; | ||
60 | |||
61 | for (ppos = plugins; NULL != ppos; ppos = ppos->next) | ||
62 | { | ||
63 | switch (ppos->flags) | ||
64 | { | ||
65 | case EXTRACTOR_OPTION_DEFAULT_POLICY: | ||
66 | case EXTRACTOR_OPTION_OUT_OF_PROCESS_NO_RESTART: | ||
67 | case EXTRACTOR_OPTION_IN_PROCESS: | ||
68 | if (ppos->seek_request >= 0 && ppos->seek_request <= min_pos) | ||
69 | min_pos = ppos->seek_request; | ||
70 | if (ppos->seek_request >= 0 && ppos->seek_request <= min_plugin_pos) | ||
71 | min_plugin_pos = ppos->seek_request; | ||
72 | break; | ||
73 | case EXTRACTOR_OPTION_DISABLED: | ||
74 | break; | ||
75 | } | ||
76 | } | ||
77 | if (min_plugin_pos == 0x7FFFFFFFFFFFFFF) | ||
78 | return -1; | ||
79 | if (min_pos < current_position - map_size) | ||
80 | { | ||
81 | if (1 != cfs_reset_stream (cfs)) | ||
82 | return -1; | ||
83 | return 0; | ||
84 | } | ||
85 | return cfs_seek (cfs, min_pos); | ||
86 | } | ||
87 | #endif | ||
88 | |||
89 | |||
90 | /** | 40 | /** |
91 | * Closure for 'process_plugin_reply' | 41 | * Closure for 'process_plugin_reply' |
92 | */ | 42 | */ |
@@ -110,6 +60,39 @@ struct PluginReplyProcessor | |||
110 | }; | 60 | }; |
111 | 61 | ||
112 | 62 | ||
63 | /** | ||
64 | * Send an 'update' message to the plugin. | ||
65 | * | ||
66 | * @param plugin plugin to notify | ||
67 | * @param shm_off new offset for the SHM | ||
68 | * @param data_available number of bytes available in shm | ||
69 | * @param ds datastore backend we are using | ||
70 | */ | ||
71 | static void | ||
72 | send_update_message (struct EXTRACTOR_PluginList *plugin, | ||
73 | int64_t shm_off, | ||
74 | size_t data_available, | ||
75 | struct EXTRACTOR_Datasource *ds) | ||
76 | { | ||
77 | struct UpdateMessage um; | ||
78 | |||
79 | um.opcode = MESSAGE_UPDATED_SHM; | ||
80 | um.reserved = 0; | ||
81 | um.reserved2 = 0; | ||
82 | um.shm_ready_bytes = (uint32_t) data_available; | ||
83 | um.shm_off = (uint64_t) shm_off; | ||
84 | um.file_size = EXTRACTOR_datasource_get_size_ (ds); | ||
85 | if (sizeof (um) != | ||
86 | EXTRACTOR_IPC_channel_send_ (plugin->channel, | ||
87 | &um, | ||
88 | sizeof (um)) ) | ||
89 | { | ||
90 | EXTRACTOR_IPC_channel_destroy_ (plugin->channel); | ||
91 | plugin->channel = NULL; | ||
92 | plugin->round_finished = 1; | ||
93 | } | ||
94 | } | ||
95 | |||
113 | 96 | ||
114 | /** | 97 | /** |
115 | * Send a 'discard state' message to the plugin and mark it as finished | 98 | * Send a 'discard state' message to the plugin and mark it as finished |
@@ -329,8 +312,10 @@ do_extract (struct EXTRACTOR_PluginList *plugins, | |||
329 | (min_seek <= pos->seek_request) && | 312 | (min_seek <= pos->seek_request) && |
330 | (min_seek + data_available > pos->seek_request) ) | 313 | (min_seek + data_available > pos->seek_request) ) |
331 | { | 314 | { |
332 | 315 | send_update_message (pos, | |
333 | /* FIXME: notify plugin about seek! */ | 316 | min_seek, |
317 | data_available, | ||
318 | ds); | ||
334 | pos->seek_request = -1; | 319 | pos->seek_request = -1; |
335 | } | 320 | } |
336 | if ( (-1 != pos->seek_request) && | 321 | if ( (-1 != pos->seek_request) && |