You can subscribe to this list here.
2005 |
Jan
|
Feb
|
Mar
(56) |
Apr
(109) |
May
(15) |
Jun
(3) |
Jul
(37) |
Aug
(96) |
Sep
(40) |
Oct
(4) |
Nov
(54) |
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2006 |
Jan
(47) |
Feb
(30) |
Mar
(102) |
Apr
(120) |
May
(68) |
Jun
(54) |
Jul
(53) |
Aug
(122) |
Sep
(190) |
Oct
(71) |
Nov
(85) |
Dec
(108) |
2007 |
Jan
(72) |
Feb
(190) |
Mar
(53) |
Apr
(101) |
May
(145) |
Jun
(148) |
Jul
(167) |
Aug
(143) |
Sep
(23) |
Oct
(198) |
Nov
(223) |
Dec
(195) |
2008 |
Jan
(100) |
Feb
(129) |
Mar
(79) |
Apr
(77) |
May
(34) |
Jun
(95) |
Jul
(112) |
Aug
(160) |
Sep
(82) |
Oct
(124) |
Nov
(199) |
Dec
(355) |
2009 |
Jan
(436) |
Feb
(89) |
Mar
(298) |
Apr
(189) |
May
(33) |
Jun
(88) |
Jul
(105) |
Aug
(44) |
Sep
(181) |
Oct
(87) |
Nov
(75) |
Dec
(1) |
2010 |
Jan
(63) |
Feb
(21) |
Mar
(3) |
Apr
(1) |
May
(1) |
Jun
(3) |
Jul
(26) |
Aug
(37) |
Sep
(26) |
Oct
(15) |
Nov
(13) |
Dec
|
From: <svn...@op...> - 2005-03-21 16:31:37
|
Author: azrael Date: 2005-03-21 17:32:18 +0100 (Mon, 21 Mar 2005) New Revision: 382 Modified: trunk/opensync/opensync_format_internals.h trunk/opensync/opensync_plugin.c trunk/opensync/opensync_plugin.h trunk/osengine/osengine_client.c trunk/osengine/osengine_client_internals.h trunk/osengine/osengine_deciders.c trunk/osengine/osengine_engine.c trunk/osengine/osengine_engine_internals.h trunk/osengine/osengine_mapping.c trunk/plugins/file-sync/src/file_sync.c Log: First implementation of the committed_all signal Modified: trunk/opensync/opensync_format_internals.h =================================================================== --- trunk/opensync/opensync_format_internals.h 2005-03-21 00:07:30 UTC (rev 381) +++ trunk/opensync/opensync_format_internals.h 2005-03-21 16:32:18 UTC (rev 382) @@ -110,6 +110,8 @@ osync_bool (* commit_change) (OSyncContext *, OSyncChange *); osync_bool (* access) (OSyncContext *, OSyncChange *); void (* read) (OSyncContext *, OSyncChange *); + void (* committed_all) (void *); + void (* batch_commit) (void *, OSyncContext **, OSyncChange **); OSyncFormatCompareFunc cmp_func; OSyncFormatMergeFunc merge_func; OSyncFormatDuplicateFunc duplicate_func; Modified: trunk/opensync/opensync_plugin.c =================================================================== --- trunk/opensync/opensync_plugin.c 2005-03-21 00:07:30 UTC (rev 381) +++ trunk/opensync/opensync_plugin.c 2005-03-21 16:32:18 UTC (rev 382) @@ -293,6 +293,8 @@ sink->functions.commit_change = template->commit_change; sink->functions.access = template->access; sink->functions.read = template->read; + sink->functions.committed_all = template->committed_all; + sink->functions.batch_commit = template->batch_commit; sink->extension_name = g_strdup(template->extension_name); return sink; } @@ -346,6 +348,24 @@ format_template->read = read; } +void osync_plugin_set_batch_commit_objformat(OSyncPluginInfo *info, const char *objtypestr, const char *formatstr, void (* batch) (void *, OSyncContext **, OSyncChange **)) +{ + OSyncObjTypeTemplate *template = osync_plugin_find_objtype_template(info->plugin, objtypestr); + osync_assert(template, "Unable to accept objformat. Did you forget to add the objtype?"); + OSyncObjFormatTemplate *format_template = osync_plugin_find_objformat_template(template, formatstr); + osync_assert(format_template, "Unable to set batch commit function. Did you forget to add the objformat?"); + format_template->batch_commit = batch; +} + +void osync_plugin_set_committed_all_objformat(OSyncPluginInfo *info, const char *objtypestr, const char *formatstr, void (* committed_all) (void *)) +{ + OSyncObjTypeTemplate *template = osync_plugin_find_objtype_template(info->plugin, objtypestr); + osync_assert(template, "Unable to accept objformat. Did you forget to add the objtype?"); + OSyncObjFormatTemplate *format_template = osync_plugin_find_objformat_template(template, formatstr); + osync_assert(format_template, "Unable to set committed_all function. Did you forget to add the objformat?"); + format_template->committed_all = committed_all; +} + OSyncObjFormatSink *osync_objtype_find_format_sink(OSyncObjTypeSink *sink, const char *formatstr) { GList *f; Modified: trunk/opensync/opensync_plugin.h =================================================================== --- trunk/opensync/opensync_plugin.h 2005-03-21 00:07:30 UTC (rev 381) +++ trunk/opensync/opensync_plugin.h 2005-03-21 16:32:18 UTC (rev 382) @@ -71,5 +71,7 @@ void osync_plugin_set_commit_objformat(OSyncPluginInfo *info, const char *objtypestr, const char *formatstr, osync_bool (* commit_change) (OSyncContext *, OSyncChange *)); void osync_plugin_set_access_objformat(OSyncPluginInfo *info, const char *objtypestr, const char *formatstr, osync_bool (* access_fn) (OSyncContext *, OSyncChange *)); void osync_plugin_set_read_objformat(OSyncPluginInfo *info, const char *objtypestr, const char *formatstr, void (* read) (OSyncContext *, OSyncChange *)); +void osync_plugin_set_batch_commit_objformat(OSyncPluginInfo *info, const char *objtypestr, const char *formatstr, void (* batch) (void *, OSyncContext **, OSyncChange **)); +void osync_plugin_set_committed_all_objformat(OSyncPluginInfo *info, const char *objtypestr, const char *formatstr, void (* committed_all) (void *)); /*@}*/ Modified: trunk/osengine/osengine_client.c =================================================================== --- trunk/osengine/osengine_client.c 2005-03-21 00:07:30 UTC (rev 381) +++ trunk/osengine/osengine_client.c 2005-03-21 16:32:18 UTC (rev 382) @@ -42,9 +42,6 @@ client->fl_done = osync_flag_new(NULL); client->fl_finished = osync_flag_new(engine->cmb_finished); - client->cmb_written = osync_comb_flag_new(FALSE, FALSE); - osync_flag_set_pos_trigger(client->cmb_written, (MSyncFlagTriggerFunc)send_committed_all, client, engine); - return client; } @@ -62,7 +59,6 @@ osync_flag_free(client->fl_sent_changes); osync_flag_free(client->fl_done); osync_flag_free(client->fl_finished); - osync_flag_free(client->cmb_written); g_free(client); osync_trace(TRACE_EXIT, "osync_client_free"); @@ -173,7 +169,7 @@ return; } - if (itm_message_is_methodcall(message, "COMMITTED_ALL")) { + if (itm_message_is_signal(message, "COMMITTED_ALL")) { osync_member_committed_all(client->member); osync_trace(TRACE_EXIT, "client_message_handler"); return; Modified: trunk/osengine/osengine_client_internals.h =================================================================== --- trunk/osengine/osengine_client_internals.h 2005-03-21 00:07:30 UTC (rev 381) +++ trunk/osengine/osengine_client_internals.h 2005-03-21 16:32:18 UTC (rev 382) @@ -14,7 +14,6 @@ MSyncFlag *fl_sent_changes; MSyncFlag *fl_done; MSyncFlag *fl_finished; - MSyncFlag *cmb_written; GThread *thread; GMainContext *context; Modified: trunk/osengine/osengine_deciders.c =================================================================== --- trunk/osengine/osengine_deciders.c 2005-03-21 00:07:30 UTC (rev 381) +++ trunk/osengine/osengine_deciders.c 2005-03-21 16:32:18 UTC (rev 382) @@ -166,13 +166,16 @@ void osengine_client_decider(OSyncEngine *engine, OSyncClient *client) { osync_trace(TRACE_ENTRY, "osengine_client_decider(%p, %p)", engine, client); - osync_trace(TRACE_INTERNAL, "ENG(SENT%i,READ%i,MAP%i),CON%i,SENT%i,DONE%i,FIN%i", \ + osync_trace(TRACE_INTERNAL, "ENG(RUN%i,STOP%i,SENT%i,READ%i,MAP%i,SYNC%i),CON%i,SENT%i,DONE%i,FIN%i", \ + osync_flag_is_set(engine->fl_running), \ + osync_flag_is_not_set(engine->fl_stop), \ osync_flag_is_set(engine->cmb_sent_changes), \ osync_flag_is_set(engine->cmb_read_all), \ osync_flag_is_set(engine->cmb_entries_mapped), \ + osync_flag_is_set(engine->cmb_synced), \ osync_flag_is_set(client->fl_connected), \ osync_flag_is_set(client->fl_sent_changes), \ - osync_flag_is_set(client->fl_done), \ + osync_flag_is_not_set(client->fl_done), \ osync_flag_is_set(client->fl_finished)); if (osync_flag_is_set(engine->fl_running) \ Modified: trunk/osengine/osengine_engine.c =================================================================== --- trunk/osengine/osengine_engine.c 2005-03-21 00:07:30 UTC (rev 381) +++ trunk/osengine/osengine_engine.c 2005-03-21 16:32:18 UTC (rev 382) @@ -349,7 +349,6 @@ void send_committed_all(OSyncClient *target, OSyncEngine *sender) { - osync_flag_changing(target->fl_done); ITMessage *message = itm_message_new_signal(sender, "COMMITTED_ALL"); itm_queue_send(target->incoming, message); } @@ -515,6 +514,19 @@ osync_trace(TRACE_EXIT, "%s", __func__); } +static void trigger_engine_multiplied(OSyncEngine *engine) +{ + osync_trace(TRACE_ENTRY, "%s(%p)", __func__, engine); + + GList *c = NULL; + for (c = engine->clients; c; c = c->next) { + OSyncClient *client = c->data; + send_committed_all(client, engine); + } + + osync_trace(TRACE_EXIT, "%s", __func__); +} + static gboolean startupfunc(gpointer data) { OSyncEngine *engine = data; @@ -566,6 +578,7 @@ osync_flag_set_state(engine->cmb_finished, FALSE); osync_flag_set_state(engine->cmb_connected, FALSE); osync_flag_set_state(engine->cmb_read_all, TRUE); + osync_flag_set_state(engine->cmb_multiplied, FALSE); itm_queue_flush(engine->incoming); osync_status_update_engine(engine, ENG_ENDPHASE_DISCON, NULL); @@ -653,6 +666,9 @@ engine->cmb_chkconflict = osync_comb_flag_new(FALSE, TRUE); osync_flag_set_pos_trigger(engine->cmb_chkconflict, (MSyncFlagTriggerFunc)trigger_status_end_conflicts, engine, NULL); + engine->cmb_multiplied = osync_comb_flag_new(FALSE, FALSE); + osync_flag_set_pos_trigger(engine->cmb_multiplied, (MSyncFlagTriggerFunc)trigger_engine_multiplied, engine, NULL); + osync_flag_set(engine->fl_sync); int i; @@ -697,6 +713,7 @@ osync_flag_free(engine->cmb_finished); osync_flag_free(engine->cmb_connected); osync_flag_free(engine->cmb_read_all); + osync_flag_free(engine->cmb_multiplied); itm_queue_flush(engine->incoming); itm_queue_free(engine->incoming); Modified: trunk/osengine/osengine_engine_internals.h =================================================================== --- trunk/osengine/osengine_engine_internals.h 2005-03-21 00:07:30 UTC (rev 381) +++ trunk/osengine/osengine_engine_internals.h 2005-03-21 16:32:18 UTC (rev 382) @@ -48,6 +48,7 @@ MSyncFlag *cmb_finished; //Are all clients done and disconnected? MSyncFlag *cmb_chkconflict; MSyncFlag *cmb_read_all; + MSyncFlag *cmb_multiplied; osync_bool man_dispatch; osync_bool allow_sync_alert; Modified: trunk/osengine/osengine_mapping.c =================================================================== --- trunk/osengine/osengine_mapping.c 2005-03-21 00:07:30 UTC (rev 381) +++ trunk/osengine/osengine_mapping.c 2005-03-21 16:32:18 UTC (rev 382) @@ -281,7 +281,7 @@ osync_flag_attach(mapping->cmb_synced, table->engine->cmb_synced); osync_flag_attach(mapping->fl_chkconflict, table->engine->cmb_chkconflict); - + osync_flag_attach(mapping->fl_multiplied, table->engine->cmb_multiplied); } osync_trace(TRACE_INTERNAL, "osengine_mapping_new(%p): %p", table, mapping); return mapping; Modified: trunk/plugins/file-sync/src/file_sync.c =================================================================== --- trunk/plugins/file-sync/src/file_sync.c 2005-03-21 00:07:30 UTC (rev 381) +++ trunk/plugins/file-sync/src/file_sync.c 2005-03-21 16:32:18 UTC (rev 382) @@ -474,6 +474,20 @@ } return TRUE; } + +static void fs_batch_commit(void *data, OSyncContext **contexts, OSyncChange **changes) +{ + filesyncinfo *env = (filesyncinfo *)data; + osync_trace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, env, contexts, changes); + osync_trace(TRACE_EXIT, "%s", __func__); +} + +static void fs_committed_all(void *data) +{ + filesyncinfo *env = (filesyncinfo *)data; + osync_trace(TRACE_ENTRY, "%s(%p)", __func__, env); + osync_trace(TRACE_EXIT, "%s", __func__); +} #endif void get_info(OSyncPluginInfo *info) @@ -492,6 +506,12 @@ info->functions.get_changeinfo = fs_get_changeinfo; info->functions.get_data = fs_get_data; + osync_plugin_accept_objtype(info, "data"); + osync_plugin_accept_objformat(info, "data", "file", NULL); + osync_plugin_set_commit_objformat(info, "data", "file", fs_commit_change); + osync_plugin_set_access_objformat(info, "data", "file", fs_access); + osync_plugin_set_read_objformat(info, "data", "file", fs_read); + #ifdef ERROR_TEST //Lets reduce the timeouts a bit so the checks work faster info->timeouts.disconnect_timeout = 5; @@ -503,11 +523,13 @@ if (g_getenv("IS_AVAILABLE")) info->functions.is_available = fs_is_available; + + if (g_getenv("BATCH_COMMIT1")) + osync_plugin_set_batch_commit_objformat(info, "data", "file", fs_batch_commit); + + if (g_getenv("BATCH_COMMIT2")) + osync_plugin_set_committed_all_objformat(info, "data", "file", fs_committed_all); #endif - osync_plugin_accept_objtype(info, "data"); - osync_plugin_accept_objformat(info, "data", "file", NULL); - osync_plugin_set_commit_objformat(info, "data", "file", fs_commit_change); - osync_plugin_set_access_objformat(info, "data", "file", fs_access); - osync_plugin_set_read_objformat(info, "data", "file", fs_read); + } |
From: <svn...@op...> - 2005-03-21 00:06:49
|
Author: azrael Date: 2005-03-21 01:07:30 +0100 (Mon, 21 Mar 2005) New Revision: 381 Modified: trunk/Makefile.am trunk/opensync/opensync_format_internals.h trunk/opensync/opensync_member.c trunk/opensync/opensync_member.h trunk/opensync/opensync_plugin.h trunk/osengine/osengine_client.c trunk/osengine/osengine_client_internals.h trunk/osengine/osengine_engine.c trunk/osengine/osengine_engine_internals.h Log: Added skeleton for the new batch commit plugin functions. Added a new signal to the members "committed_all" that will be called by the engine when all changes to be written have been sent to a member. Modified: trunk/Makefile.am =================================================================== --- trunk/Makefile.am 2005-03-18 16:16:20 UTC (rev 380) +++ trunk/Makefile.am 2005-03-21 00:07:30 UTC (rev 381) @@ -17,10 +17,11 @@ EXTRA_DIST = \ autogen.sh \ - buildtest.sh \ plugins \ opensync-1.0.pc.in \ - osengine-1.0.pc.in + osengine-1.0.pc.in \ + misc/buildtest.sh \ + misc/doxygen.css dist-hook: find $(distdir) -name .svn -print0 | xargs -0 rm -rf Modified: trunk/opensync/opensync_format_internals.h =================================================================== --- trunk/opensync/opensync_format_internals.h 2005-03-18 16:16:20 UTC (rev 380) +++ trunk/opensync/opensync_format_internals.h 2005-03-21 00:07:30 UTC (rev 381) @@ -83,6 +83,8 @@ OSyncFormatFunctions functions; char *extension_name; struct OSyncObjTypeSink *objtype_sink; + GList *commit_changes; + GList *commit_contexts; } OSyncObjFormatSink; typedef struct OSyncObjTypeSink { Modified: trunk/opensync/opensync_member.c =================================================================== --- trunk/opensync/opensync_member.c 2005-03-18 16:16:20 UTC (rev 380) +++ trunk/opensync/opensync_member.c 2005-03-21 00:07:30 UTC (rev 381) @@ -562,12 +562,12 @@ g_assert(member); g_assert(change); + OSyncFormatEnv *env = osync_member_get_format_env(member); OSyncContext *context = osync_context_new(member); context->callback_function = function; context->calldata = user_data; - - OSyncFormatEnv *env = osync_member_get_format_env(member); + OSyncObjType *type = change->objtype; /* This is just an optmization: @@ -617,10 +617,18 @@ osync_debug("OSYNC", 2, "Comparing change %s with sink %s", osync_change_get_objformat(change)->name, fmtsink->format ? fmtsink->format->name : "None"); if (fmtsink->format == osync_change_get_objformat(change)) { - // Send the change - fmtsink->functions.commit_change(context, change); - osync_trace(TRACE_EXIT, "%s", __func__); - return; + if (fmtsink->functions.batch_commit) { + //Append to the stored changes + fmtsink->commit_changes = g_list_append(fmtsink->commit_changes, change); + fmtsink->commit_contexts = g_list_append(fmtsink->commit_contexts, context); + osync_trace(TRACE_EXIT, "%s: Waiting for batch processing", __func__); + return; + } else { + // Send the change + fmtsink->functions.commit_change(context, change); + osync_trace(TRACE_EXIT, "%s", __func__); + return; + } } } @@ -628,6 +636,56 @@ osync_trace(TRACE_EXIT_ERROR, "%s: Unable to find a sink", __func__); } +void osync_member_committed_all(OSyncMember *member) +{ + osync_trace(TRACE_ENTRY, "%s(%p)", __func__, member); + + GList *f; + for (f = member->format_sinks; f; f = f->next) { + OSyncObjFormatSink *fmtsink = f->data; + osync_debug("OSYNC", 2, "Sending committed all to sink %s", fmtsink->format ? fmtsink->format->name : "None"); + + OSyncFormatFunctions functions = fmtsink->functions; + + if (functions.batch_commit) { + GList *o = fmtsink->commit_contexts; + GList *c = NULL; + + int i = 0; + OSyncChange **changes = g_malloc0(sizeof(OSyncChange *) * (g_list_length(fmtsink->commit_changes) + 1)); + OSyncContext **contexts = g_malloc0(sizeof(OSyncContext *) * (g_list_length(fmtsink->commit_changes) + 1));; + + for (c = fmtsink->commit_changes; c && o; c = c->next) { + OSyncChange *change = c->data; + OSyncContext *context = o->data; + + changes[i] = change; + contexts[i] = context; + + i++; + o = o->next; + } + + changes[i] = NULL; + contexts[i] = NULL; + functions.batch_commit(member->plugindata, contexts, changes); + + g_free(changes); + g_free(contexts); + + g_list_free(fmtsink->commit_changes); + fmtsink->commit_changes = NULL; + + g_list_free(fmtsink->commit_contexts); + fmtsink->commit_contexts = NULL; + } else if (functions.committed_all) { + functions.committed_all(member->plugindata); + } + } + + osync_trace(TRACE_EXIT, "%s", __func__); +} + OSyncObjFormatSink *osync_member_make_random_data(OSyncMember *member, OSyncChange *change, const char *objtypename) { int retry = 0; Modified: trunk/opensync/opensync_member.h =================================================================== --- trunk/opensync/opensync_member.h 2005-03-18 16:16:20 UTC (rev 380) +++ trunk/opensync/opensync_member.h 2005-03-21 00:07:30 UTC (rev 381) @@ -39,6 +39,7 @@ void osync_member_disconnect(OSyncMember *member, OSyncEngCallback function, void *user_data); void osync_member_get_changeinfo(OSyncMember *member, OSyncEngCallback function, void *user_data); void osync_member_read_change(OSyncMember *member, OSyncChange *change, OSyncEngCallback function, void *user_data); +void osync_member_committed_all(OSyncMember *member); void *osync_member_call_plugin(OSyncMember *member, const char *function, void *data, OSyncError **error); void osync_member_commit_change(OSyncMember *member, OSyncChange *change, OSyncEngCallback function, void *user_data); Modified: trunk/opensync/opensync_plugin.h =================================================================== --- trunk/opensync/opensync_plugin.h 2005-03-18 16:16:20 UTC (rev 380) +++ trunk/opensync/opensync_plugin.h 2005-03-21 00:07:30 UTC (rev 381) @@ -35,6 +35,8 @@ /*! @brief The functions for accessing formats on a plugin */ typedef struct OSyncFormatFunctions { osync_bool (* commit_change) (OSyncContext *, OSyncChange *); + void (* committed_all) (void *); + void (* batch_commit) (void *, OSyncContext **, OSyncChange **); osync_bool (* access) (OSyncContext *, OSyncChange *); void (* read) (OSyncContext *, OSyncChange *); } OSyncFormatFunctions; Modified: trunk/osengine/osengine_client.c =================================================================== --- trunk/osengine/osengine_client.c 2005-03-18 16:16:20 UTC (rev 380) +++ trunk/osengine/osengine_client.c 2005-03-21 00:07:30 UTC (rev 381) @@ -41,8 +41,10 @@ client->fl_sent_changes = osync_flag_new(engine->cmb_sent_changes); client->fl_done = osync_flag_new(NULL); client->fl_finished = osync_flag_new(engine->cmb_finished); - //client->fl_reset = osync_flag_new(engine->cmb_reset); + client->cmb_written = osync_comb_flag_new(FALSE, FALSE); + osync_flag_set_pos_trigger(client->cmb_written, (MSyncFlagTriggerFunc)send_committed_all, client, engine); + return client; } @@ -60,6 +62,7 @@ osync_flag_free(client->fl_sent_changes); osync_flag_free(client->fl_done); osync_flag_free(client->fl_finished); + osync_flag_free(client->cmb_written); g_free(client); osync_trace(TRACE_EXIT, "osync_client_free"); @@ -170,6 +173,12 @@ return; } + if (itm_message_is_methodcall(message, "COMMITTED_ALL")) { + osync_member_committed_all(client->member); + osync_trace(TRACE_EXIT, "client_message_handler"); + return; + } + if (itm_message_is_methodcall(message, "READ_CHANGE")) { OSyncChange *change = itm_message_get_data(message, "change"); osync_member_read_change(client->member, change, (OSyncEngCallback)message_callback, message); Modified: trunk/osengine/osengine_client_internals.h =================================================================== --- trunk/osengine/osengine_client_internals.h 2005-03-18 16:16:20 UTC (rev 380) +++ trunk/osengine/osengine_client_internals.h 2005-03-21 00:07:30 UTC (rev 381) @@ -14,6 +14,7 @@ MSyncFlag *fl_sent_changes; MSyncFlag *fl_done; MSyncFlag *fl_finished; + MSyncFlag *cmb_written; GThread *thread; GMainContext *context; Modified: trunk/osengine/osengine_engine.c =================================================================== --- trunk/osengine/osengine_engine.c 2005-03-18 16:16:20 UTC (rev 380) +++ trunk/osengine/osengine_engine.c 2005-03-21 00:07:30 UTC (rev 381) @@ -347,6 +347,13 @@ itm_queue_send_with_timeout(target->incoming, message, timeouts.sync_done_timeout, target); } +void send_committed_all(OSyncClient *target, OSyncEngine *sender) +{ + osync_flag_changing(target->fl_done); + ITMessage *message = itm_message_new_signal(sender, "COMMITTED_ALL"); + itm_queue_send(target->incoming, message); +} + void send_disconnect(OSyncClient *target, OSyncEngine *sender) { osync_flag_changing(target->fl_connected); Modified: trunk/osengine/osengine_engine_internals.h =================================================================== --- trunk/osengine/osengine_engine_internals.h 2005-03-18 16:16:20 UTC (rev 380) +++ trunk/osengine/osengine_engine_internals.h 2005-03-21 00:07:30 UTC (rev 381) @@ -69,3 +69,4 @@ void send_disconnect(OSyncClient *target, OSyncEngine *sender); void send_read_change(OSyncEngine *sender, OSyncMappingEntry *entry); void send_engine_changed(OSyncEngine *engine); +void send_committed_all(OSyncClient *target, OSyncEngine *sender); |
From: <svn...@op...> - 2005-03-20 23:54:50
|
Author: abauer Date: 2005-03-17 15:58:35 +0100 (Do, 17 M2005) New Revision: 375 Modified: trunk/opensync/opensync_db.c trunk/opensync/opensync_plugin.c trunk/opensync/opensync_plugin.h trunk/osengine/osengine_client.c trunk/osengine/osengine_deciders.c trunk/osengine/osengine_engine.c trunk/osengine/osengine_engine_internals.h trunk/osengine/osengine_mapcmds.c trunk/osengine/osengine_mapping.c trunk/osengine/osengine_mapping_internals.h trunk/tests/check_multisync.c Log: Some more updates to support ignore_change Geert: trunk/opensync/opensync_db.c =================================================================== --- trunk/opensync/opensync_db.c 2005-03-16 23:33:07 UTC (rev 374) +++ trunk/opensync/opensync_db.c 2005-03-17 14:58:35 UTC (rev 375) @@ -18,7 +18,7 @@ * */ -#include <opensync.h> +#include "opensync.h" #include "opensync_internals.h" void osync_db_trace(void *data, const char *query) @@ -61,6 +61,77 @@ return ret; } +osync_bool osync_db_open_changelog(OSyncGroup *group, char ***uids, int **changetypes, OSyncError **error) +{ + g_assert(group); + OSyncDB *log_db; + + group->changes_path = g_strdup(group->configdir); + char *filename = g_strdup_printf("%s/changelog.db", group->changes_path); + if (!(log_db = osync_db_open(filename, error))) { + osync_error_update(error, "Unable to load changelog: %s", osync_error_print(error)); + return FALSE; + } + osync_debug("OSDB", 3, "Preparing to changelog from file %s", filename); + g_free(filename); + + sqlite3 *sdb = log_db->db; + + if (sqlite3_exec(sdb, "CREATE TABLE tbl_log (uid VARCHAR PRIMARY KEY, changetype INTEGER)", NULL, NULL, NULL) != SQLITE_OK) + osync_debug("OSDB", 2, "Unable create log table! %s", sqlite3_errmsg(sdb)); + + int count = osync_db_count(group->changes_db, "SELECT count(*) FROM tbl_log"); + *uids = g_malloc0(sizeof(char *) * (count + 1)); + *changetypes = g_malloc0(sizeof(int) * (count + 1)); + + sqlite3_stmt *ppStmt = NULL; + sqlite3_prepare(sdb, "SELECT uid, changetype FROM tbl_log", -1, &ppStmt, NULL); + int i = 0; + while (sqlite3_step(ppStmt) == SQLITE_ROW) { + (*uids)[i] = g_strdup(sqlite3_column_text(ppStmt, 0)); + (*changetypes)[i] = sqlite3_column_int(ppStmt, 1); + i++; + } + (*uids)[i] = NULL; + (*changetypes)[i] = 0; + sqlite3_finalize(ppStmt); + + osync_db_close(log_db); + return TRUE; +} + +osync_bool osync_db_save_changelog(OSyncGroup *group, OSyncChange *change, OSyncError **error) +{ + g_assert(group); + OSyncDB *log_db; + + group->changes_path = g_strdup(group->configdir); + char *filename = g_strdup_printf("%s/changelog.db", group->changes_path); + if (!(log_db = osync_db_open(filename, error))) { + osync_error_update(error, "Unable to load changelog: %s", osync_error_print(error)); + return FALSE; + } + osync_debug("OSDB", 3, "Preparing to changelog from file %s", filename); + g_free(filename); + + sqlite3 *sdb = log_db->db; + + if (sqlite3_exec(sdb, "CREATE TABLE tbl_log (uid VARCHAR PRIMARY KEY, changetype INTEGER)", NULL, NULL, NULL) != SQLITE_OK) + osync_debug("OSDB", 2, "Unable create log table! %s", sqlite3_errmsg(sdb)); + + char *query = g_strdup_printf("INSERT INTO tbl_log (uid, changetype) VALUES('%s', '%i')", change->uid, change->changetype); + if (sqlite3_exec(sdb, query, NULL, NULL, NULL) != SQLITE_OK) { + osync_error_set(error, OSYNC_ERROR_PARAMETER, "Unable to insert log! %s", sqlite3_errmsg(sdb)); + g_free(query); + return FALSE; + } + change->id = sqlite3_last_insert_rowid(sdb); + g_free(query); + + osync_db_close(log_db); + return TRUE; +} + osync_bool osync_db_open_changes(OSyncGroup *group, OSyncChange ***changes, OSyncError **error) { g_assert(group); @@ -76,14 +147,14 @@ sqlite3 *sdb = group->changes_db->db; - if (sqlite3_exec(sdb, "CREATE TABLE tbl_changes (id INTEGER PRIMARY KEY, uid VARCHAR, objtype VARCHAR, format VARCHAR, memberid INTEGER, mappingid INTEGER, changetype INTEGER)", NULL, NULL, NULL) != SQLITE_OK) + if (sqlite3_exec(sdb, "CREATE TABLE tbl_changes (id INTEGER PRIMARY KEY, uid VARCHAR, objtype VARCHAR, format VARCHAR, memberid INTEGER, mappingid INTEGER)", NULL, NULL, NULL) != SQLITE_OK) osync_debug("OSDB", 2, "Unable create changes table! %s", sqlite3_errmsg(sdb)); int count = osync_db_count(group->changes_db, "SELECT count(*) FROM tbl_changes"); *changes = g_malloc0(sizeof(OSyncChange *) * (count + 1)); sqlite3_stmt *ppStmt = NULL; - sqlite3_prepare(sdb, "SELECT id, uid, objtype, format, memberid, mappingid, changetype FROM tbl_changes ORDER BY mappingid", -1, &ppStmt, NULL); + sqlite3_prepare(sdb, "SELECT id, uid, objtype, format, memberid, mappingid FROM tbl_changes ORDER BY mappingid", -1, &ppStmt, NULL); int i = 0; while (sqlite3_step(ppStmt) == SQLITE_ROW) { OSyncChange *change = osync_change_new(); @@ -93,7 +164,6 @@ change->format_name = g_strdup(sqlite3_column_text(ppStmt, 3)); change->initial_format_name = g_strdup(change->format_name); change->mappingid = sqlite3_column_int64(ppStmt, 5); - change->changetype = sqlite3_column_int64(ppStmt, 6); long long int memberid = sqlite3_column_int64(ppStmt, 4); change->changes_db = group->changes_db; osync_change_set_member(change, osync_member_from_id(group, memberid)); @@ -121,7 +191,7 @@ char *query = NULL; if (!change->id) { - query = g_strdup_printf("INSERT INTO tbl_changes (uid, objtype, format, memberid, mappingid, changetype) VALUES('%s', '%s', '%s', '%lli', '%lli', '%i')", change->uid, osync_change_get_objtype(change)->name, osync_change_get_objformat(change)->name, change->member->id, change->mappingid, change->changetype); + query = g_strdup_printf("INSERT INTO tbl_changes (uid, objtype, format, memberid, mappingid) VALUES('%s', '%s', '%s', '%lli', '%lli')", change->uid, osync_change_get_objtype(change)->name, osync_change_get_objformat(change)->name, change->member->id, change->mappingid); if (sqlite3_exec(sdb, query, NULL, NULL, NULL) != SQLITE_OK) { osync_error_set(error, OSYNC_ERROR_PARAMETER, "Unable to insert change! %s", sqlite3_errmsg(sdb)); g_free(query); @@ -131,9 +201,9 @@ change->id = sqlite3_last_insert_rowid(sdb); } else { if (save_format) - query = g_strdup_printf("UPDATE tbl_changes SET uid='%s', objtype='%s', format='%s', memberid='%lli', mappingid='%lli', changetype='%i' WHERE id=%lli", change->uid, osync_change_get_objtype(change)->name, osync_change_get_objformat(change)->name, change->member->id, change->mappingid, change->changetype, change->id); + query = g_strdup_printf("UPDATE tbl_changes SET uid='%s', objtype='%s', format='%s', memberid='%lli', mappingid='%lli' WHERE id=%lli", change->uid, osync_change_get_objtype(change)->name, osync_change_get_objformat(change)->name, change->member->id, change->mappingid, change->id); else - query = g_strdup_printf("UPDATE tbl_changes SET uid='%s', memberid='%lli', mappingid='%lli', changetype='%i' WHERE id=%lli", change->uid, change->member->id, change->mappingid, change->changetype, change->id); + query = g_strdup_printf("UPDATE tbl_changes SET uid='%s', memberid='%lli', mappingid='%lli' WHERE id=%lli", change->uid, change->member->id, change->mappingid, change->id); if (sqlite3_exec(sdb, query, NULL, NULL, NULL) != SQLITE_OK) { osync_error_set(error, OSYNC_ERROR_PARAMETER, "Unable to update change! %s", sqlite3_errmsg(sdb)); g_free(query); Geert: trunk/opensync/opensync_plugin.c =================================================================== --- trunk/opensync/opensync_plugin.c 2005-03-16 23:33:07 UTC (rev 374) +++ trunk/opensync/opensync_plugin.c 2005-03-17 14:58:35 UTC (rev 375) @@ -50,6 +50,7 @@ plugin->info.timeouts.get_changeinfo_timeout = 60; plugin->info.timeouts.get_data_timeout = 60; plugin->info.timeouts.commit_timeout = 60; + plugin->info.timeouts.read_change_timeout = 60; plugin->info.plugin = plugin; Geert: trunk/opensync/opensync_plugin.h =================================================================== --- trunk/opensync/opensync_plugin.h 2005-03-16 23:33:07 UTC (rev 374) +++ trunk/opensync/opensync_plugin.h 2005-03-17 14:58:35 UTC (rev 375) @@ -29,6 +29,7 @@ unsigned int get_changeinfo_timeout; unsigned int get_data_timeout; unsigned int commit_timeout; + unsigned int read_change_timeout; } OSyncPluginTimeouts; /*! @brief The functions for accessing formats on a plugin */ Geert: trunk/osengine/osengine_client.c =================================================================== --- trunk/osengine/osengine_client.c 2005-03-16 23:33:07 UTC (rev 374) +++ trunk/osengine/osengine_client.c 2005-03-17 14:58:35 UTC (rev 375) @@ -172,7 +172,7 @@ if (itm_message_is_methodcall(message, "READ_CHANGE")) { OSyncChange *change = itm_message_get_data(message, "change"); - osync_member_read_change(client->member, change, (OSyncEngCallback)osync_client_changes_sink, message); + osync_member_read_change(client->member, change, (OSyncEngCallback)message_callback, message); osync_trace(TRACE_EXIT, "client_message_handler"); return; } Geert: trunk/osengine/osengine_deciders.c =================================================================== --- trunk/osengine/osengine_deciders.c 2005-03-16 23:33:07 UTC (rev 374) +++ trunk/osengine/osengine_deciders.c 2005-03-17 14:58:35 UTC (rev 375) @@ -35,7 +35,18 @@ void osengine_mappingentry_decider(OSyncEngine *engine, OSyncMappingEntry *entry) { osync_trace(TRACE_ENTRY, "osengine_mappingentry_decider(%p, %p)", engine, entry); - + osync_trace(TRACE_INTERNAL, "ENG(SYNC%i,SENT%i,READ%i)DATA%i,DRY%i,MAP%i,INFO%i,SYNC%i,DEL%i", \ + osync_flag_is_set(engine->cmb_synced), \ + osync_flag_is_set(engine->cmb_sent_changes), \ + osync_flag_is_set(engine->cmb_read_all), \ + osync_flag_is_set(entry->fl_has_data), \ + osync_flag_is_set(entry->fl_dirty), \ + osync_flag_is_set(entry->fl_mapped), \ + osync_flag_is_set(entry->fl_has_info), \ + osync_flag_is_set(entry->fl_synced), \ + osync_flag_is_set(entry->fl_deleted)); + + if (osync_flag_is_set(engine->fl_running) \ && osync_flag_is_set(engine->fl_sync) \ && osync_flag_is_set(entry->fl_has_info) \ @@ -47,6 +58,7 @@ } if (osync_flag_is_set(engine->fl_running) \ + && osync_flag_is_set(engine->cmb_read_all) \ && osync_flag_is_set(engine->cmb_sent_changes) \ && osync_flag_is_set(engine->fl_sync) \ && osync_flag_is_set(entry->fl_has_info) \ @@ -80,7 +92,10 @@ void osengine_mapping_decider(OSyncEngine *engine, OSyncMapping *mapping) { osync_trace(TRACE_ENTRY, "osengine_mapping_decider(%p, %p)", engine, mapping); - osync_trace(TRACE_INTERNAL, "SOLV%i,SYNC%i,DATA%i,INFO%i,DEL%i,CHK%i,MUL%i", \ + osync_trace(TRACE_INTERNAL, "ENG(SENT%i,READ%i,MAP%i),SOLV%i,SYNC%i,DATA%i,INFO%i,DEL%i,CHK%i,MUL%i", \ + osync_flag_is_set(engine->cmb_sent_changes), \ + osync_flag_is_set(engine->cmb_read_all), \ + osync_flag_is_set(engine->cmb_entries_mapped), \ osync_flag_is_set(mapping->fl_solved), \ osync_flag_is_set(mapping->cmb_synced), \ osync_flag_is_set(mapping->cmb_has_data), \ @@ -91,6 +106,7 @@ if (osync_flag_is_set(engine->fl_running) \ && osync_flag_is_set(engine->cmb_sent_changes) \ + && osync_flag_is_set(engine->cmb_read_all) \ && osync_flag_is_set(engine->cmb_entries_mapped) \ && osync_flag_is_set(mapping->cmb_has_data) \ && osync_flag_is_not_set(mapping->cmb_synced) \ @@ -103,6 +119,7 @@ if (osync_flag_is_set(engine->fl_running) \ && osync_flag_is_set(engine->cmb_sent_changes) \ + && osync_flag_is_set(engine->cmb_read_all) \ && osync_flag_is_set(engine->cmb_entries_mapped) \ && osync_flag_is_set(mapping->cmb_has_data) \ && osync_flag_is_not_set(mapping->cmb_synced) \ @@ -149,7 +166,15 @@ void osengine_client_decider(OSyncEngine *engine, OSyncClient *client) { osync_trace(TRACE_ENTRY, "osengine_client_decider(%p, %p)", engine, client); - + osync_trace(TRACE_INTERNAL, "ENG(SENT%i,READ%i,MAP%i),CON%i,SENT%i,DONE%i,FIN%i", \ + osync_flag_is_set(engine->cmb_sent_changes), \ + osync_flag_is_set(engine->cmb_read_all), \ + osync_flag_is_set(engine->cmb_entries_mapped), \ + osync_flag_is_set(client->fl_connected), \ + osync_flag_is_set(client->fl_sent_changes), \ + osync_flag_is_set(client->fl_done), \ + osync_flag_is_set(client->fl_finished)); + if (osync_flag_is_set(engine->fl_running) \ && osync_flag_is_not_set(engine->fl_stop) \ && osync_flag_is_not_set(client->fl_done) \ @@ -184,6 +209,7 @@ && osync_flag_is_not_set(client->fl_done) \ && osync_flag_is_set(client->fl_connected) \ && osync_flag_is_set(client->fl_sent_changes) \ + && osync_flag_is_set(engine->cmb_read_all) \ && osync_flag_is_set(engine->cmb_sent_changes) \ && osync_flag_is_set(engine->cmb_synced) \ && osync_flag_is_set(engine->cmb_entries_mapped)) { Geert: trunk/osengine/osengine_engine.c =================================================================== --- trunk/osengine/osengine_engine.c 2005-03-16 23:33:07 UTC (rev 374) +++ trunk/osengine/osengine_engine.c 2005-03-17 14:58:35 UTC (rev 375) @@ -156,6 +156,8 @@ return; } + engine->maptable->logchanges = g_list_remove(engine->maptable->logchanges, entry); + //We convert to the common format here to make sure we always pass it osync_change_convert_to_common(change, NULL); @@ -216,6 +218,28 @@ osync_trace(TRACE_EXIT, "_get_change_data_reply_receiver"); } +void _read_change_reply_receiver(OSyncClient *sender, ITMessage *message, OSyncEngine *engine) +{ + osync_trace(TRACE_ENTRY, "_read_change_reply_receiver(%p, %p, %p)", sender, message, engine); + + OSyncMappingEntry *entry = itm_message_get_data(message, "entry"); + + osync_flag_detach(entry->fl_read); + + osync_flag_unset(entry->mapping->fl_solved); + osync_flag_unset(entry->mapping->fl_chkconflict); + + if (osync_change_get_changetype(entry->change) == CHANGE_DELETED) + osync_flag_set(entry->fl_deleted); + + osync_flag_set(entry->fl_has_info); + osync_flag_unset(entry->fl_synced); + + osync_change_save(entry->change, TRUE, NULL); + osengine_mappingentry_decider(engine, entry); + osync_trace(TRACE_EXIT, "_read_change_reply_receiver"); +} + void _commit_change_reply_receiver(OSyncClient *sender, ITMessage *message, OSyncEngine *engine) { osync_trace(TRACE_ENTRY, "_commit_change_reply_receiver(%p, %p, %p)", sender, message, engine); @@ -238,11 +262,16 @@ osync_flag_set(entry->fl_synced); } - OSyncError *error = NULL; - osync_change_save(entry->change, TRUE, &error); + engine->maptable->logchanges = g_list_remove(engine->maptable->logchanges, entry); + if (osync_change_get_changetype(entry->change) == CHANGE_DELETED) osync_flag_set(entry->fl_deleted); + osync_change_reset(entry->change); + + OSyncError *error = NULL; + osync_change_save(entry->change, TRUE, &error); + osengine_mappingentry_decider(engine, entry); osync_trace(TRACE_EXIT, "_commit_change_reply_receiver"); } @@ -272,6 +301,19 @@ itm_queue_send_with_timeout(entry->client->incoming, message, timeouts.get_data_timeout, sender); } +void send_read_change(OSyncEngine *sender, OSyncMappingEntry *entry) +{ + //osync_flag_changing(entry->fl_has_data); + ITMessage *message = itm_message_new_methodcall(sender, "READ_CHANGE"); + itm_message_set_handler(message, sender->incoming, (ITMessageHandler)_read_change_reply_receiver, sender); + itm_message_set_data(message, "change", entry->change); + itm_message_set_data(message, "entry", entry); + osync_debug("ENG", 3, "Sending read_change message %p to client %p", message, entry->client); + + OSyncPluginTimeouts timeouts = osync_client_get_timeouts(entry->client); + itm_queue_send_with_timeout(entry->client->incoming, message, timeouts.read_change_timeout, sender); +} + void send_connect(OSyncClient *target, OSyncEngine *sender) { osync_flag_changing(target->fl_connected); @@ -435,6 +477,12 @@ static void trigger_clients_sent_changes(OSyncEngine *engine) { + //Load the old mappings + osengine_mappingtable_inject_changes(engine->maptable); +} + +static void trigger_clients_read_all(OSyncEngine *engine) +{ osync_status_update_engine(engine, ENG_ENDPHASE_READ, NULL); g_mutex_lock(engine->info_received_mutex); @@ -454,9 +502,8 @@ static void trigger_clients_connected(OSyncEngine *engine) { osync_trace(TRACE_ENTRY, "%s(%p)", __func__, engine); - //Load the old mappings - osengine_mappintable_load_mappings(engine->maptable); send_engine_changed(engine); + osync_trace(TRACE_EXIT, "%s", __func__); } @@ -510,6 +557,7 @@ osync_flag_set_state(engine->cmb_chkconflict, TRUE); osync_flag_set_state(engine->cmb_finished, FALSE); osync_flag_set_state(engine->cmb_connected, FALSE); + osync_flag_set_state(engine->cmb_read_all, TRUE); itm_queue_flush(engine->incoming); osync_status_update_engine(engine, ENG_ENDPHASE_DISCON, NULL); @@ -579,6 +627,9 @@ engine->cmb_sent_changes = osync_comb_flag_new(FALSE, FALSE); osync_flag_set_pos_trigger(engine->cmb_sent_changes, (MSyncFlagTriggerFunc)trigger_clients_sent_changes, engine, NULL); + engine->cmb_read_all = osync_comb_flag_new(FALSE, TRUE); + osync_flag_set_pos_trigger(engine->cmb_read_all, (MSyncFlagTriggerFunc)trigger_clients_read_all, engine, NULL); + engine->cmb_entries_mapped = osync_comb_flag_new(FALSE, FALSE); osync_flag_set_pos_trigger(engine->cmb_entries_mapped, (MSyncFlagTriggerFunc)send_engine_changed, engine, NULL); @@ -637,6 +688,7 @@ osync_flag_free(engine->cmb_chkconflict); osync_flag_free(engine->cmb_finished); osync_flag_free(engine->cmb_connected); + osync_flag_free(engine->cmb_read_all); itm_queue_flush(engine->incoming); itm_queue_free(engine->incoming); Geert: trunk/osengine/osengine_engine_internals.h =================================================================== --- trunk/osengine/osengine_engine_internals.h 2005-03-16 23:33:07 UTC (rev 374) +++ trunk/osengine/osengine_engine_internals.h 2005-03-17 14:58:35 UTC (rev 375) @@ -47,6 +47,7 @@ MSyncFlag *cmb_synced; //Are all mappings synced? MSyncFlag *cmb_finished; //Are all clients done and disconnected? MSyncFlag *cmb_chkconflict; + MSyncFlag *cmb_read_all; osync_bool man_dispatch; osync_bool allow_sync_alert; @@ -66,3 +67,5 @@ void send_get_changes(OSyncClient *target, OSyncEngine *sender, osync_bool data); void send_sync_done(OSyncClient *target, OSyncEngine *sender); void send_disconnect(OSyncClient *target, OSyncEngine *sender); +void send_read_change(OSyncEngine *sender, OSyncMappingEntry *entry); +void send_engine_changed(OSyncEngine *engine); Geert: trunk/osengine/osengine_mapcmds.c =================================================================== --- trunk/osengine/osengine_mapcmds.c 2005-03-16 23:33:07 UTC (rev 374) +++ trunk/osengine/osengine_mapcmds.c 2005-03-17 14:58:35 UTC (rev 375) @@ -116,6 +116,7 @@ OSyncMappingEntry *master = NULL; master = mapping->master; + g_assert(master); if (osync_flag_is_not_set(master->fl_dirty)) osync_flag_set(master->fl_synced); @@ -164,6 +165,11 @@ } } + osync_change_reset(master->change); + + OSyncError *error = NULL; + osync_change_save(master->change, TRUE, &error); + osync_flag_set(mapping->fl_multiplied); osync_trace(TRACE_EXIT, "osync_mapping_multiply_master"); } @@ -182,26 +188,25 @@ g_assert(engine != NULL); g_assert(mapping != NULL); + g_assert(!mapping->master); - if (!mapping->master) { - for (e = mapping->entries; e; e = e->next) { - leftentry = e->data; - if (osync_change_get_changetype(leftentry->change) == CHANGE_UNKNOWN) + for (e = mapping->entries; e; e = e->next) { + leftentry = e->data; + if (osync_change_get_changetype(leftentry->change) == CHANGE_UNKNOWN) + continue; + mapping->master = leftentry; + for (n = e->next; n; n = n->next) { + rightentry = n->data; + if (osync_change_get_changetype(rightentry->change) == CHANGE_UNKNOWN) continue; - mapping->master = leftentry; - for (n = e->next; n; n = n->next) { - rightentry = n->data; - if (osync_change_get_changetype(rightentry->change) == CHANGE_UNKNOWN) - continue; - - if (osync_change_compare(leftentry->change, rightentry->change) != CONV_DATA_SAME) { - is_conflict = TRUE; - goto conflict; - } else { - is_same++; - } - } - } + + if (osync_change_compare(leftentry->change, rightentry->change) != CONV_DATA_SAME) { + is_conflict = TRUE; + goto conflict; + } else { + is_same++; + } + } } conflict: @@ -213,6 +218,7 @@ osync_trace(TRACE_EXIT, "osync_mapping_check_conflict: Got conflict"); return; } + g_assert(mapping->master); osync_flag_set(mapping->fl_chkconflict); //Our mapping is already solved since there is no conflict @@ -385,8 +391,12 @@ { osync_trace(TRACE_ENTRY, "%s(%p, %p)", __func__, engine, mapping); - //Mark all members of this conflict to be reloaded again next time. - osengine_mappintable_store_mapping(mapping); + GList *e = NULL; + for (e = mapping->entries; e; e = e->next) { + OSyncMappingEntry *entry = e->data; + osync_trace(TRACE_INTERNAL, "Adding %p to logchanges", entry); + engine->maptable->logchanges = g_list_append(engine->maptable->logchanges, entry); + } //And make sure we dont synchronize it this time osengine_mapping_reset(mapping); Geert: trunk/osengine/osengine_mapping.c =================================================================== --- trunk/osengine/osengine_mapping.c 2005-03-16 23:33:07 UTC (rev 374) +++ trunk/osengine/osengine_mapping.c 2005-03-17 14:58:35 UTC (rev 375) @@ -143,27 +143,32 @@ entry->change = change; //entry->orig_change = change; entry->client = (OSyncClient *)osync_member_get_data(osync_change_get_member(change)); + + if (!osync_change_get_mappingid(change)) { + table->unmapped = g_list_append(table->unmapped, entry); + } else { + if (!mapping || mapping->id != osync_change_get_mappingid(change)) { + mapping = osengine_mapping_new(table); + mapping->id = osync_change_get_mappingid(change); + } + osengine_mapping_add_entry(mapping, entry); + } + + osync_flag_set(entry->fl_has_data); + + OSyncMappingView *view = osengine_mappingtable_find_view(table, osync_change_get_member(change)); + if (view) + osengine_mappingview_add_entry(view, entry); + if (osync_change_get_changetype(change) != CHANGE_UNKNOWN) { - table->logchange = g_list_append(table->logchange, change); - } else { - if (!osync_change_get_mappingid(change)) { - table->unmapped = g_list_append(table->unmapped, entry); - } else { - if (!mapping || mapping->id != osync_change_get_mappingid(change)) { - mapping = osengine_mapping_new(table); - mapping->id = osync_change_get_mappingid(change); - } - osengine_mapping_add_entry(mapping, entry); - } - - osync_flag_set(entry->fl_has_data); - - OSyncMappingView *view = osengine_mappingtable_find_view(table, osync_change_get_member(change)); - if (view) - osengine_mappingview_add_entry(view, entry); + osync_trace(TRACE_INTERNAL, "Adding %p to logchanges", entry); + table->logchanges = g_list_append(table->logchanges, entry); } + i++; } + + osync_trace(TRACE_INTERNAL, "#logchanges: %i", g_list_length(table->logchanges)); osync_trace(TRACE_EXIT, "osengine_mappingtable_load: TRUE"); return TRUE; } @@ -180,22 +185,31 @@ return new_id; } -void osync_mappingtable_inject_changes(OSyncMappingTable *table) +void osengine_mappingtable_inject_changes(OSyncMappingTable *table) { + osync_trace(TRACE_ENTRY, "%s(%p)", __func__, table); OSyncEngine *engine = table->engine; + + char **uids = NULL; + int *types = NULL; + char *uid = NULL; + int type = 0; + int i = 0; + osync_db_load_changelog(table->engine->group, &uids, &types, NULL); - GList *c; - OSyncChange *change = NULL; - while ((change = g_list_nth_data(table->logchanges, 0))) { - table->logchange = g_list_remove(table->logchange, change); - OSyncMember *member = osync_change_get_member(change); - OSyncClient *client = osync_member_get_data(member); - - ITMessage *message = itm_message_new_signal(client, "NEW_CHANGE"); - itm_message_set_data(message, "change", change); - itm_message_reset_timeout(orig); - itm_queue_send(engine->incoming, message); + if (!uids) + send_engine_changed(engine); + + while ((uid = uids[i])) { + type = types[i]; + OSyncMappingEntry *entry = osengine_mappingtable_find_entry(table, uid); + osync_change_set_changetype(entry->change, type); + osync_trace(TRACE_INTERNAL, "Injecting %p with changetype %i", entry, osync_change_get_changetype(entry->change)); + osync_flag_attach(entry->fl_read, table->engine->cmb_read_all); + send_read_change(engine, entry); + i++; } + osync_trace(TRACE_EXIT, "%s", __func__); } OSyncMappingTable *_osengine_mappingtable_load_group(OSyncGroup *group) @@ -447,6 +461,7 @@ entry->fl_has_info = osync_flag_new(NULL); entry->fl_synced = osync_flag_new(NULL); entry->fl_deleted = osync_flag_new(NULL); + entry->fl_read = osync_flag_new(NULL); osync_flag_set(entry->fl_synced); if (mapping) @@ -468,6 +483,7 @@ osync_flag_free(entry->fl_has_info); osync_flag_free(entry->fl_synced); osync_flag_free(entry->fl_deleted); + osync_flag_free(entry->fl_read); entry->view->changes = g_list_remove(entry->view->changes, entry); entry->view = NULL; Geert: trunk/osengine/osengine_mapping_internals.h =================================================================== --- trunk/osengine/osengine_mapping_internals.h 2005-03-16 23:33:07 UTC (rev 374) +++ trunk/osengine/osengine_mapping_internals.h 2005-03-17 14:58:35 UTC (rev 375) @@ -15,6 +15,7 @@ OSyncGroup *group; GList *views; GList *entries; + GList *logchanges; }; /*! @brief A view to the mappingtable, represents one source @@ -58,6 +59,7 @@ MSyncFlag *fl_has_info; MSyncFlag *fl_synced; MSyncFlag *fl_deleted; + MSyncFlag *fl_read; }; OSyncMappingTable *osengine_mappingtable_new(OSyncEngine *engine); @@ -71,6 +73,7 @@ void osengine_mappingtable_close(OSyncMappingTable *table); long long int osengine_mappingtable_get_next_id(OSyncMappingTable *table); void osengine_mappingtable_reset(OSyncMappingTable *table); +void osengine_mappingtable_inject_changes(OSyncMappingTable *table); OSyncMapping *osengine_mapping_new(OSyncMappingTable *table); void osengine_mapping_free(OSyncMapping *mapping); Geert: trunk/tests/check_multisync.c =================================================================== --- trunk/tests/check_multisync.c 2005-03-16 23:33:07 UTC (rev 374) +++ trunk/tests/check_multisync.c 2005-03-17 14:58:35 UTC (rev 375) @@ -1742,9 +1742,72 @@ synchronize_once(engine, NULL); - fail_unless(num_read == 0, NULL); - fail_unless(num_conflicts == 0, NULL); + fail_unless(num_read == 5, NULL); + fail_unless(num_conflicts == 2, NULL); + fail_unless(num_written == 0, NULL); + fail_unless(num_engine_end_conflicts == 1, NULL); + + fail_unless(!system("test \"x$(diff -x \".*\" data1 data2)\" != \"x\""), NULL); + fail_unless(!system("test \"x$(diff -x \".*\" data1 data3)\" != \"x\""), NULL); + maptable = mappingtable_load(group, 2, 0); + check_mapping(maptable, 1, -1, 3, "testdata", "file", "data"); + check_mapping(maptable, 2, -1, 3, "testdata", "file", "data"); + check_mapping(maptable, 3, -1, 3, "testdata", "file", "data"); + check_mapping(maptable, 1, -1, 3, "testdata1", "file", "data"); + check_mapping(maptable, 2, -1, 3, "testdata1", "file", "data"); + check_mapping(maptable, 3, -1, 3, "testdata1", "file", "data"); + mappingtable_close(maptable); + + table = hashtable_load(group, 1, 2); + check_hash(table, "testdata"); + check_hash(table, "testdata1"); + osync_hashtable_close(table); + + table = hashtable_load(group, 2, 1); + check_hash(table, "testdata1"); + osync_hashtable_close(table); + + table = hashtable_load(group, 3, 2); + check_hash(table, "testdata"); + check_hash(table, "testdata1"); + osync_hashtable_close(table); + + + osync_engine_set_conflict_callback(engine, conflict_handler_choose_modified, (void *)3); + synchronize_once(engine, NULL); + + fail_unless(num_read == 5, NULL); + fail_unless(num_conflicts == 2, NULL); + fail_unless(num_written == 4, NULL); + fail_unless(num_engine_end_conflicts == 1, NULL); + + fail_unless(!system("test \"x$(diff -x \".*\" data1 data2)\" = \"x\""), NULL); + fail_unless(!system("test \"x$(diff -x \".*\" data1 data3)\" = \"x\""), NULL); + + maptable = mappingtable_load(group, 2, 0); + check_mapping(maptable, 1, -1, 3, "testdata", "file", "data"); + check_mapping(maptable, 2, -1, 3, "testdata", "file", "data"); + check_mapping(maptable, 3, -1, 3, "testdata", "file", "data"); + check_mapping(maptable, 1, -1, 3, "testdata1", "file", "data"); + check_mapping(maptable, 2, -1, 3, "testdata1", "file", "data"); + check_mapping(maptable, 3, -1, 3, "testdata1", "file", "data"); + mappingtable_close(maptable); + + table = hashtable_load(group, 1, 2); + check_hash(table, "testdata"); + check_hash(table, "testdata1"); + osync_hashtable_close(table); + + table = hashtable_load(group, 2, 1); + check_hash(table, "testdata1"); + osync_hashtable_close(table); + + table = hashtable_load(group, 3, 2); + check_hash(table, "testdata"); + check_hash(table, "testdata1"); + osync_hashtable_close(table); + system("rm -f data1/*"); synchronize_once(engine, NULL); @@ -1880,7 +1943,7 @@ Suite *multisync_suite(void) { Suite *s = suite_create("Multisync"); - //Suite *s2 = suite_create("Multisync"); + Suite *s2 = suite_create("Multisync"); create_case(s, "multisync_easy_new", multisync_easy_new); create_case(s, "multisync_dual_new", multisync_dual_new); create_case(s, "multisync_triple_new", multisync_triple_new); @@ -1905,10 +1968,10 @@ create_case(s, "multisync_multi_conflict", multisync_multi_conflict); create_case(s, "multisync_delayed_conflict_handler", multisync_delayed_conflict_handler); - create_case(s, "multisync_conflict_ignore", multisync_conflict_ignore); + create_case(s2, "multisync_conflict_ignore", multisync_conflict_ignore); create_case(s, "multisync_conflict_ignore2", multisync_conflict_ignore2); - return s; + return s2; } int main(void) |