From: <svn...@op...> - 2009-03-26 02:58:00
|
Author: dgollub Date: Thu Mar 26 03:57:56 2009 New Revision: 5345 URL: http://www.opensync.org/changeset/5345 Log: Ignore new changes messages from plugins if they delayed/timedout. fixes #1030 Modified: trunk/opensync/client/opensync_client_proxy.c trunk/opensync/client/opensync_client_proxy_private.h trunk/tests/CMakeLists.txt trunk/tests/engine-tests/check_engine_error.c Modified: trunk/opensync/client/opensync_client_proxy.c ============================================================================== --- trunk/opensync/client/opensync_client_proxy.c Thu Mar 26 02:48:16 2009 (r5344) +++ trunk/opensync/client/opensync_client_proxy.c Thu Mar 26 03:57:56 2009 (r5345) @@ -626,6 +626,7 @@ } else if (osync_message_get_cmd(message) == OSYNC_MESSAGE_ERRORREPLY) { osync_demarshal_error(message, &error); ctx->get_changes_callback(proxy, ctx->get_changes_callback_data, error); + osync_client_proxy_set_error(proxy, error); osync_error_unref(&error); } else { osync_error_set(&locerror, OSYNC_ERROR_GENERIC, "Unexpected reply"); @@ -761,6 +762,11 @@ case OSYNC_MESSAGE_READ_CHANGE: osync_assert(proxy->change_callback); + + if (proxy->error) { + osync_trace(TRACE_INTERNAL, "WARNING: Proxy error taintend! Ignoring incoming changes!"); + break; + } if (!osync_demarshal_change(message, &change, proxy->formatenv, &error)) goto error; @@ -841,6 +847,9 @@ if (proxy->formatenv) osync_format_env_unref(proxy->formatenv); + + if (proxy->error) + osync_error_unref(&proxy->error); osync_free(proxy); } @@ -1759,3 +1768,17 @@ osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); return FALSE; } + +void osync_client_proxy_set_error(OSyncClientProxy *proxy, OSyncError *error) +{ + osync_assert(proxy); + if (proxy->error) { + osync_error_stack(&error, &proxy->error); + osync_error_unref(&proxy->error); + } + + proxy->error = error; + if (error) + osync_error_ref(&error); +} + Modified: trunk/opensync/client/opensync_client_proxy_private.h ============================================================================== --- trunk/opensync/client/opensync_client_proxy_private.h Thu Mar 26 02:48:16 2009 (r5344) +++ trunk/opensync/client/opensync_client_proxy_private.h Thu Mar 26 03:57:56 2009 (r5345) @@ -72,6 +72,11 @@ change_cb change_callback; void *change_callback_data; + + /** Proxy specific error struct */ + OSyncError *error; }; +void osync_client_proxy_set_error(OSyncClientProxy *proxy, OSyncError *error); + #endif /*OSYNC_CLIENT_PROXY_PRIVATE_H_*/ Modified: trunk/tests/CMakeLists.txt ============================================================================== --- trunk/tests/CMakeLists.txt Thu Mar 26 02:48:16 2009 (r5344) +++ trunk/tests/CMakeLists.txt Thu Mar 26 03:57:56 2009 (r5345) @@ -171,7 +171,7 @@ OSYNC_TESTCASE( engine-error engine_error_one_of_three_get_changes_error) OSYNC_TESTCASE( engine-error engine_error_one_of_three_get_changes_timeout) OSYNC_TESTCASE( engine-error engine_error_get_changes_timeout_and_error) -OSYNC_TESTCASE_DISABLED( engine-error engine_error_get_changes_timeout_sleep "1030") +OSYNC_TESTCASE( engine-error engine_error_get_changes_timeout_sleep) OSYNC_TESTCASE( engine-error engine_error_single_commit_error) OSYNC_TESTCASE( engine-error engine_error_dual_commit_error) OSYNC_TESTCASE( engine-error engine_error_single_commit_timeout) Modified: trunk/tests/engine-tests/check_engine_error.c ============================================================================== --- trunk/tests/engine-tests/check_engine_error.c Thu Mar 26 02:48:16 2009 (r5344) +++ trunk/tests/engine-tests/check_engine_error.c Thu Mar 26 03:57:56 2009 (r5345) @@ -1455,9 +1455,11 @@ END_TEST -/* FIXME: If get_changes delays and got timed out .. set change_callback to NULL. - Make sure changes from the plugin got completely ignored by the engine when the timout handler got called. - Even better would be to abort the get_changes call from the plugin process... +/* If get_changes delays and got timed out ... tainted proxy with an error. + * + * Make sure changes from the plugin got completely ignored by the engine when the timout handler got called. + * Even better would be to abort the get_changes call from the plugin process... + * */ START_TEST (engine_error_get_changes_timeout_sleep) { @@ -1506,7 +1508,9 @@ fail_unless(num_client_read == 0, NULL); fail_unless(num_client_written == 0, NULL); - // FIXME: If get_changes delays and get timed out .. set change_callback to NULL. To make sure changes got completely ignored by the engine + /* If get_changes delays and get timed out .. proxy get tainted with an error. + * To make sure changes got completely ignored by the engine. + */ fail_unless(num_change_read == 0, NULL); fail_unless(num_change_written == 0, NULL); |