mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-03-03 15:26:07 +00:00
Added support for Suspend/Resume...
This commit is contained in:
parent
69710c988d
commit
941c492269
@ -110,6 +110,8 @@ nsSocketTransport::nsSocketTransport()
|
||||
mSocketFD = nsnull;
|
||||
mLock = nsnull;
|
||||
|
||||
mSuspendCount = 0;
|
||||
|
||||
mCurrentState = eSocketState_Created;
|
||||
mOperation = eSocketOperation_None;
|
||||
mSelectFlags = 0;
|
||||
@ -215,6 +217,15 @@ nsresult nsSocketTransport::Process(PRInt16 aSelectFlags)
|
||||
//
|
||||
Lock();
|
||||
|
||||
//
|
||||
// If the transport has been suspended, then return NS_OK immediately...
|
||||
// This removes the transport from the select list...
|
||||
//
|
||||
if (mSuspendCount) {
|
||||
done = PR_TRUE;
|
||||
rv = NS_OK;
|
||||
}
|
||||
|
||||
while (!done)
|
||||
{
|
||||
switch (mCurrentState) {
|
||||
@ -714,13 +725,55 @@ nsSocketTransport::Cancel(void)
|
||||
NS_IMETHODIMP
|
||||
nsSocketTransport::Suspend(void)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
// Enter the socket transport lock...
|
||||
Lock();
|
||||
|
||||
mSuspendCount += 1;
|
||||
//
|
||||
// Wake up the transport on the socket transport thread so it can
|
||||
// be removed from the select list...
|
||||
//
|
||||
// Only do this the first time a transport is suspended...
|
||||
//
|
||||
if (1 == mSuspendCount) {
|
||||
rv = mService->AddToWorkQ(this);
|
||||
}
|
||||
|
||||
// Leave the socket transport lock...
|
||||
Unlock();
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSocketTransport::Resume(void)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
// Enter the socket transport lock...
|
||||
Lock();
|
||||
|
||||
if (mSuspendCount) {
|
||||
mSuspendCount -= 1;
|
||||
//
|
||||
// Wake up the transport on the socket transport thread so it can
|
||||
// be resumed...
|
||||
//
|
||||
if (0 == mSuspendCount) {
|
||||
rv = mService->AddToWorkQ(this);
|
||||
}
|
||||
} else {
|
||||
// Only a suspended transport can be resumed...
|
||||
rv = NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// Leave the socket transport lock...
|
||||
Unlock();
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
|
@ -110,6 +110,8 @@ protected:
|
||||
nsSocketState mCurrentState;
|
||||
nsSocketOperation mOperation;
|
||||
|
||||
PRInt32 mSuspendCount;
|
||||
|
||||
PRFileDesc* mSocketFD;
|
||||
PRNetAddr mNetAddress;
|
||||
PRInt16 mSelectFlags;
|
||||
|
@ -21,7 +21,7 @@
|
||||
#include "nsSocketTransport.h"
|
||||
|
||||
|
||||
#define MAX_OPEN_CONNECTIONS 10
|
||||
#define MAX_OPEN_CONNECTIONS 50
|
||||
|
||||
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
|
Loading…
x
Reference in New Issue
Block a user