- From: Thomas Dreibholz <dreibh AT iem.uni-due.de>
- To: "Julio Kriger" <juliokriger AT gmail.com>
- Cc: discussion AT sctp.de
- Subject: Re: [SCTP-Discussion] a weird bug (segmentation fault)
- Date: Tue May 23 16:42:07 2006
- List-id: SCTP Discussions <discussion.sctp.de>
On Tuesday 23 May 2006 14:38, Julio Kriger wrote:
>
Hi!
>
I didn't knew that the library is not thread safe.
>
So to fix my app, I should put a mutex before where the calling of
>
"sctp_*" functions (for example put a mutex before SCTP_receive, SCTP_send,
>
ect) ? and what about SCTP_startTimer? should I put a mutex before calling
>
that function?
>
Well, let say that I should put a mutex before calling any function from
>
the SCTP library. That should fix the thread-safe problem.
Yes, make sure that every sctplib function is called exclusively.
For the event loop, the following das to be done: define functions to obtain
and release the mutex and give a pointer to the mutex as third argument:
void lock(void* mutexPtr)
{
mutex = (YourMutexPtrType*)mutexPtr;
Lock it ...
}
void unlock(void* mutexPtr)
{
mutex = (YourMutexPtrType*)mutexPtr;
Unlock it ...
}
sctp_extendedEventLoop(lock,unlock,mutex);
Also have a look into the file sctpsocketmaster.cc of the socket API. It
implements the thread-safe event loop for the socket API library.
Best regards
--
=======================================================================
Dipl.-Inform. Thomas Dreibholz
University of Essen, Room ES210
Inst. for Experimental Mathematics Ellernstraße 29
Computer Networking Technology Group D-45326 Essen/Germany
-----------------------------------------------------------------------
E-Mail:
dreibh AT exp-math.uni-essen.de
Homepage:
http://www.exp-math.uni-essen.de/~dreibh
=======================================================================
Attachment:
pgp5II1rzep0j.pgp
Description: PGP signature
Archive powered by MHonArc 2.6.19+.