mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-03 22:55:04 -04:00
Reworking of networking code to enable Net Restart.
* Stun code now runs continually - to check external network state. * Udpsorter controls DHT stun is on/off. (via p3ConnectMgr) * added code to enable threads to join/restart * enabled NetRestart for UDP and TCP. * tweaked networking code for faster startup (now ~30 seconds - can still be improved). * tweaked debug messages for testing networking * Added test for checking external IP address determination. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@1492 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
d5581629ef
commit
2bf94b909a
22 changed files with 774 additions and 81 deletions
|
@ -55,8 +55,24 @@ pthread_t createThread(RsThread &thread)
|
|||
|
||||
thread.mMutex.lock();
|
||||
{
|
||||
pthread_create(&tid, 0, &rsthread_init, data);
|
||||
thread.mTid = tid;
|
||||
|
||||
#if 0
|
||||
int ret;
|
||||
ret = pthread_attr_init(&tattr);
|
||||
if (doDetached)
|
||||
{
|
||||
ret = pthread_attr_setdetachstate(&tattr,PTHREAD_CREATE_DETACHED);
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = pthread_attr_setdetachstate(&tattr,PTHREAD_CREATE_JOINABLE);
|
||||
}
|
||||
|
||||
pthread_create(&tid, &tattr, &rsthread_init, data);
|
||||
#endif
|
||||
|
||||
pthread_create(&tid, 0, &rsthread_init, data);
|
||||
thread.mTid = tid;
|
||||
}
|
||||
thread.mMutex.unlock();
|
||||
|
||||
|
@ -64,6 +80,16 @@ pthread_t createThread(RsThread &thread)
|
|||
|
||||
}
|
||||
|
||||
void RsThread::join() /* waits for the the mTid thread to stop */
|
||||
{
|
||||
void *ptr;
|
||||
pthread_join(mTid, &ptr);
|
||||
}
|
||||
|
||||
void RsThread::stop()
|
||||
{
|
||||
pthread_exit(NULL);
|
||||
}
|
||||
|
||||
RsQueueThread::RsQueueThread(uint32_t min, uint32_t max, double relaxFactor )
|
||||
:mMinSleep(min), mMaxSleep(max), mRelaxFactor(relaxFactor)
|
||||
|
|
|
@ -70,6 +70,8 @@ virtual ~RsThread() { return; }
|
|||
|
||||
virtual void start() { createThread(*this); }
|
||||
virtual void run() = 0; /* called once the thread is started */
|
||||
virtual void join(); /* waits for the the mTid thread to stop */
|
||||
virtual void stop(); /* calls pthread_exit() */
|
||||
|
||||
pthread_t mTid;
|
||||
RsMutex mMutex;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue