From: <svn...@op...> - 2009-02-24 16:25:01
|
Author: bellmich Date: Tue Feb 24 17:24:54 2009 New Revision: 945 URL: http://libsyncml.opensync.org/changeset/945 Log: - fixed trace statement - added two missing smlLocationUnref - removed one smlSessionRef because smlManagerSessionAdd calls smlSessionRef by itself (wrong comment) Modified: trunk/libsyncml/data_sync_api/transport_http_client.c Modified: trunk/libsyncml/data_sync_api/transport_http_client.c ============================================================================== --- trunk/libsyncml/data_sync_api/transport_http_client.c Tue Feb 24 16:08:07 2009 (r944) +++ trunk/libsyncml/data_sync_api/transport_http_client.c Tue Feb 24 17:24:54 2009 (r945) @@ -67,6 +67,9 @@ smlAssert(dsObject->manager); smlAssert(dsObject->agent); + SmlLocation *target = NULL; + SmlLocation *source = NULL; + /* If there is an old session then this is a bug. * the high level API only support one session per * OMA DS object. @@ -78,9 +81,15 @@ } /* create session */ + + target = smlLocationNew(dsObject->target, NULL, error); + if (!target) + goto error; + source = smlLocationNew(dsObject->identifier, NULL, error); + if (!source) + goto error; + char *sessionString = smlManagerGetNewSessionID(dsObject->manager); - SmlLocation *target = smlLocationNew(dsObject->target, NULL, error); - SmlLocation *source = smlLocationNew(dsObject->identifier, NULL, error); dsObject->session = smlSessionNew(SML_SESSION_TYPE_CLIENT, SML_MIMETYPE_XML, dsObject->version, @@ -91,14 +100,10 @@ if (!dsObject->session) goto error; - /* It is necessary to increment the reference counter - * because smlManagerSessionAdd consumes the session - * without incrementing the reference counter by itself. - * So if dsObject wants to use the session by itself - * then dsObject must increment the reference counter - * or dsObject->session must be set to NULL. - */ - smlSessionRef(dsObject->session); + smlLocationUnref(target); + target = NULL; + smlLocationUnref(source); + source = NULL; /* register all the add-ons */ if (!smlManagerSessionAdd(dsObject->manager, dsObject->session, NULL, error)) @@ -108,12 +113,20 @@ return TRUE; error: + if (target) { + smlLocationUnref(target); + target = NULL; + } + if (source) { + smlLocationUnref(source); + source = NULL; + } return FALSE; } SmlBool smlDataSyncTransportHttpClientConnect(SmlDataSyncObject *dsObject, SmlError **error) { - smlTrace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, dsObject, error); + smlTrace(TRACE_ENTRY, "%s(%p, %p)", __func__, dsObject, error); CHECK_ERROR_REF dsObject->tryDisconnect = FALSE; |