177 |
|
|
178 |
printf("gcvote: result handler\n"); |
printf("gcvote: result handler\n"); |
179 |
|
|
180 |
/* worker thread has already reduced its refcounter */ |
if(request->refcount < 2) { |
|
if(request->refcount < 1) { |
|
181 |
printf("gcvote: main app isn't listening anymore\n"); |
printf("gcvote: main app isn't listening anymore\n"); |
182 |
|
gcvote_request_free(request); |
183 |
return FALSE; |
return FALSE; |
184 |
} |
} |
185 |
|
|
186 |
if(request->res) { |
if(request->res) { |
187 |
printf("gcvote: curl failed\n"); |
printf("gcvote: curl failed\n"); |
188 |
request->cb(NULL, request->userdata); |
request->cb(NULL, request->userdata); |
189 |
|
gcvote_request_free(request); |
190 |
return FALSE; |
return FALSE; |
191 |
} |
} |
192 |
|
|
195 |
if(!request->mem.ptr || !request->mem.len) { |
if(!request->mem.ptr || !request->mem.len) { |
196 |
printf("gcvote: ignoring zero length reply\n"); |
printf("gcvote: ignoring zero length reply\n"); |
197 |
request->cb(NULL, request->userdata); |
request->cb(NULL, request->userdata); |
198 |
|
gcvote_request_free(request); |
199 |
return FALSE; |
return FALSE; |
200 |
} |
} |
201 |
|
|
209 |
/* nothing could be parsed, just give up */ |
/* nothing could be parsed, just give up */ |
210 |
if(!doc) { |
if(!doc) { |
211 |
request->cb(NULL, request->userdata); |
request->cb(NULL, request->userdata); |
212 |
|
gcvote_request_free(request); |
213 |
return FALSE; |
return FALSE; |
214 |
} |
} |
215 |
|
|
238 |
} else |
} else |
239 |
printf("gcvote: no vote found\n"); |
printf("gcvote: no vote found\n"); |
240 |
|
|
241 |
|
gcvote_request_free(request); |
242 |
return FALSE; |
return FALSE; |
243 |
} |
} |
244 |
|
|
303 |
CURL *curl = curl_easy_init(); |
CURL *curl = curl_easy_init(); |
304 |
if(!curl) { |
if(!curl) { |
305 |
curl_formfree(formpost); |
curl_formfree(formpost); |
|
gcvote_request_free(request); |
|
306 |
|
|
307 |
/* callback anyway, so main loop can also clean up */ |
/* callback anyway, so main loop can also clean up */ |
308 |
g_idle_add(gcvote_result_handler, request); |
g_idle_add(gcvote_result_handler, request); |
338 |
/* then cleanup the formpost chain */ |
/* then cleanup the formpost chain */ |
339 |
curl_formfree(formpost); |
curl_formfree(formpost); |
340 |
|
|
341 |
|
/* cause gtk main loop to handle result only if main loop */ |
342 |
|
/* is still interested. Don't free request then, since the */ |
343 |
|
/* gcvote_result_handler will do this */ |
344 |
|
if(request->refcount > 1) |
345 |
|
g_idle_add(gcvote_result_handler, request); |
346 |
|
else |
347 |
|
gcvote_request_free(request); |
348 |
|
|
349 |
printf("gcvote: worker thread done\n"); |
printf("gcvote: worker thread done\n"); |
|
gcvote_request_free(request); |
|
350 |
|
|
|
/* cause gtk main loop to handle result */ |
|
|
g_idle_add(gcvote_result_handler, request); |
|
|
|
|
|
printf("gcvote: thread terminating\n"); |
|
|
|
|
351 |
return NULL; |
return NULL; |
352 |
} |
} |
353 |
|
|