problem using libsoup and libpthread in same app.
- From: "Sagaert Johan" <sagaert johan skynet be>
- To: "'Dan Winship'" <danw gnome org>
- Cc: libsoup-list gnome org
- Subject: problem using libsoup and libpthread in same app.
- Date: Mon, 12 Mar 2012 12:00:02 +0100
Hi
Usage context :
uclibc 0.9.33 , crosscompiled for arm EABI gcc 4.5.3
i have a problem
when using libsoup in an apllication that also uses the standard
pthreads.
I have created a
small app. in order to try to isolate the problem:
I just have no
explanation why ths happens, i have already spent days on it and ended up
in the libglib2 source in
g_socket_factory_create_connection.
I need libpthread
since my app already uses this and i just needed to add some functionality that
required libsoup.and ended up in a nightmare.
scenario
1
=========
libpthread not added
to the list of libs to link wiith.
When i call my
function from the main thread -> it works
When i call my
function from a gthread -> it works
scenario
2
========
Now i added
libpthread to the list of used libs for the linker
(i just added the
libpthread and did not use any of its functions in my small test
program.)
When i call my
function from the main thread -> it works
When i call my
function from a gthread ->
FAIL
Here is the output
of both scenarios:
scenario 1
OK
=========
starting...
init
done...
Running from main
get request done
Accepted 202
status returned=202
body returned=<?xml
version="1.0"?>
<clickAPI>
<sendMsgResp>
<fault>001, Authentication
failed</fault>
<sequence_no></sequence_no>
</sendMsgResp>
</clickAPI>
header
returned=0x1adb8
Running from
gthread
get request done Accepted 202
status returned=202
body
returned=<?xml
version="1.0"?>
<clickAPI>
<sendMsgResp>
<fault>001, Authentication
failed</fault>
<sequence_no></sequence_no>
</sendMsgResp>
</clickAPI>
header
returned=0x28168
#
scenario 2
FAIL
=========
starting...
init
done...
Running from main
get request done
Accepted 202
status returned=202
body returned=<?xml
version="1.0"?>
<clickAPI>
<sendMsgResp>
<fault>001, Authentication
failed</fault>
<sequence_no></sequence_no>
</sendMsgResp>
</clickAPI>
header
returned=0x1adb8
Running from gthread
get request done Cannot connect to destination (api.clickatell.com)
4
status returned=4
body returned=(null)
header
returned=0x1b340
#
source
: *************************************************************************
***********************************************************************************
/*
*
main.c
*
* Created on: feb 26,
2012
* Author:
Johan
*/
#include
<ctype.h>
#include <errno.h>
#include
<fcntl.h>
#include <stdio.h>
#include
<stdlib.h>
#include <string.h>
#include
<sys/stat.h>
#include <unistd.h>
#include
<libsoup/soup.h>
void soaptest(void)
{
SoupMessage
*msg;
SoupSession *session=NULL;
guint status;
char
encoded[1024] ;
session=soup_session_sync_new();
if
(session==NULL)
{
printf("Could not
soup_session_sync_new\n");
return;
}
char request[]
="<clickAPI><sendMsg><api_id>3179973</api_id><user>apexbe</user><password>hidden</password><to>32479504265</to><text>testmet
Veel__spatieoverxml</text><from>ApexSyst</from></sendMsg></clickAPI>";
char
* uriencoded=soup_uri_encode(request,NULL);
sprintf(encoded,"