From: <svn...@op...> - 2009-03-18 17:37:08
|
Author: bellmich Date: Wed Mar 18 18:37:04 2009 New Revision: 997 URL: http://libsyncml.opensync.org/changeset/997 Log: fixed remote device handling to be multi session safe This is important if you ever implement long living processes or if you implement a client which wants to use its own session ID. Modified: trunk/libsyncml/data_sync_api/data_sync_devinf.c Modified: trunk/libsyncml/data_sync_api/data_sync_devinf.c ============================================================================== --- trunk/libsyncml/data_sync_api/data_sync_devinf.c Wed Mar 18 18:33:12 2009 (r996) +++ trunk/libsyncml/data_sync_api/data_sync_devinf.c Wed Mar 18 18:37:04 2009 (r997) @@ -568,6 +568,7 @@ smlTrace(TRACE_ENTRY, "%s(%p,%p)", __func__, dsObject, error); CHECK_ERROR_REF smlAssert(dsObject); + smlAssertMsg(dsObject->session, "an active session is needed to have a remote device"); /* if there is already a remote device information * then cleanup the reference. @@ -575,7 +576,7 @@ if (dsObject->remoteDevInf) smlDevInfUnref(dsObject->remoteDevInf); - dsObject->remoteDevInf = smlDevInfAgentGetDevInf(dsObject->agent); + dsObject->remoteDevInf = smlDevInfAgentGetSessionDevInf(dsObject->agent, dsObject->session); if (dsObject->remoteDevInf) { smlTrace(TRACE_INTERNAL, "%s: The remote DevInf was received.", __func__); @@ -605,8 +606,17 @@ if (!devinf && *error) goto error; if (devinf) { - smlDevInfAgentSetDevInf(dsObject->agent, devinf); - dsObject->remoteDevInf = smlDevInfAgentGetDevInf(dsObject->agent); + if (!smlDevInfAgentSetSessionDevInf( + dsObject->agent, + dsObject->session, + devinf, + error)) + { + goto error; + } + dsObject->remoteDevInf = smlDevInfAgentGetSessionDevInf( + dsObject->agent, + dsObject->session); /* smlDevInfAgentSetDevInf consumes the DevInf object. * So the reference counter must be incremented for * remoteDevInf. @@ -714,6 +724,7 @@ { smlTrace(TRACE_ENTRY, "%s(%p, %p)", __func__, dsObject, error); CHECK_ERROR_REF + smlAssertMsg(dsObject->session, "an active session is needed to manage device informations"); /* If the callback is available * then we dump the local device information first. |