92 curl_easy_setopt(sn->handle, CURLOPT_DEFAULT_PROTOCOL, "http"); |
92 curl_easy_setopt(sn->handle, CURLOPT_DEFAULT_PROTOCOL, "http"); |
93 #endif |
93 #endif |
94 curl_easy_setopt(sn->handle, CURLOPT_URL, base_url); |
94 curl_easy_setopt(sn->handle, CURLOPT_URL, base_url); |
95 |
95 |
96 // add to context |
96 // add to context |
97 cxListAdd(context->sessions, sn); |
97 dav_context_add_session(context, sn); |
98 sn->context = context; |
98 sn->context = context; |
99 |
99 |
100 return sn; |
100 return sn; |
101 } |
101 } |
102 |
102 |
300 sn->errorstr = errstr; |
300 sn->errorstr = errstr; |
301 } |
301 } |
302 |
302 |
303 void dav_session_destroy(DavSession *sn) { |
303 void dav_session_destroy(DavSession *sn) { |
304 // remove session from context |
304 // remove session from context |
305 CxList *sessions = sn->context->sessions; |
305 if (dav_context_remove_session(sn->context, sn)) { |
306 ssize_t i = cxListFind(sessions, sn); |
306 fprintf(stderr, "Error: session not found in ctx->sessions\n"); |
307 if(i >= 0) { |
|
308 cxListRemove(sessions, i); |
|
309 } else { |
|
310 printf("Error: session not found in ctx->sessions\n"); |
|
311 dav_session_destructor(sn); |
307 dav_session_destructor(sn); |
312 } |
308 } |
313 } |
309 } |
314 |
310 |
315 void dav_session_destructor(DavSession *sn) { |
311 void dav_session_destructor(DavSession *sn) { |