Changeset 38 in cheroxy
- Timestamp:
- 11/21/12 09:23:50 (11 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/CRXMutex.h
r10 r38 14 14 { 15 15 private: 16 CRX_MUTEX mMutex; 16 bool mIsCreated; 17 CRX_MUTEX mMutex; 17 18 18 19 public: … … 21 22 22 23 public: 24 bool IsCreated (void) const; 23 25 int Create (void); 24 26 int Destroy (void); -
trunk/include/CRXSocket.h
r30 r38 9 9 #ifdef WIN32 10 10 # include <WinSock2.h> 11 typedef int socklen_t; 11 12 #else 12 13 # include <netinet/in.h> -
trunk/src/CRXMutex.cpp
r12 r38 3 3 4 4 CRXMutex::CRXMutex (void) 5 : mIsCreated (false), 6 #ifdef _WIN32 7 mMutex (NULL) 8 #endif 5 9 { 6 #ifdef _WIN32 7 mMutex = NULL; 8 #endif 10 /*----------------------------------------------------------------*/ 11 /*----------------------------------------------------------------*/ 9 12 } 10 13 11 14 CRXMutex::~CRXMutex (void) 12 15 { 16 /*----------------------------------------------------------------*/ 13 17 this->Unlock (); 14 18 this->Destroy (); 15 #ifdef _WIN32 16 #else 17 #endif 19 /*----------------------------------------------------------------*/ 18 20 } 19 21 20 int CRXMutex::Create (void) 22 bool 23 CRXMutex::IsCreated (void) const 21 24 { 25 /*----------------------------------------------------------------*/ 26 /*----------------------------------------------------------------*/ 27 28 return mIsCreated; 29 } 30 31 int 32 CRXMutex::Create (void) 33 { 34 int aResult = 0; 35 36 /*----------------------------------------------------------------*/ 22 37 #ifdef _WIN32 23 38 if ((mMutex = ::CreateMutexA (NULL, FALSE, NULL)) == NULL) 24 return GetLastError (); 25 else 26 return 0; 39 aResult = GetLastError (); 27 40 #else 28 returnpthread_mutex_init (&mMutex, NULL);41 aResult = pthread_mutex_init (&mMutex, NULL); 29 42 #endif 43 44 mIsCreated = true; 45 /*----------------------------------------------------------------*/ 46 47 return aResult; 30 48 } 31 49 32 int CRXMutex::Destroy (void) 50 int 51 CRXMutex::Destroy (void) 33 52 { 53 int aResult = 0; 54 55 /*----------------------------------------------------------------*/ 34 56 #ifdef _WIN32 35 57 if (::CloseHandle (mMutex)) 36 return GetLastError (); 37 else 38 return 0; 58 aResult = GetLastError (); 39 59 #else 40 returnpthread_mutex_destroy (&mMutex);60 aResult = pthread_mutex_destroy (&mMutex); 41 61 #endif 62 63 mIsCreated = false; 64 /*----------------------------------------------------------------*/ 65 66 return aResult; 42 67 } 43 68 44 void CRXMutex::Lock (void) 69 void 70 CRXMutex::Lock (void) 45 71 { 72 /*----------------------------------------------------------------*/ 46 73 #ifdef _WIN32 47 74 ::WaitForSingleObject (mMutex, INFINITE); … … 49 76 pthread_mutex_lock (&mMutex); 50 77 #endif 78 /*----------------------------------------------------------------*/ 51 79 } 52 80 53 void CRXMutex::Unlock (void) 81 void 82 CRXMutex::Unlock (void) 54 83 { 84 /*----------------------------------------------------------------*/ 55 85 #ifdef _WIN32 56 86 if (mMutex != NULL) … … 59 89 pthread_mutex_unlock (&mMutex); 60 90 #endif 91 /*----------------------------------------------------------------*/ 61 92 } -
trunk/src/CRXProxy.cpp
r36 r38 7 7 #include <string.h> 8 8 9 CRXFilter 9 CRXFilter CRXProxy::mFilter; 10 10 11 11 CRXProxy::CRXProxy (void) … … 26 26 27 27 CRXProxy * 28 CRXProxy::GetNewInstance (void)28 CRXProxy::GetNewInstance (void) 29 29 { 30 30 /*----------------------------------------------------------------*/ … … 277 277 int aSize = mHttpRequest.GetHeader ().length (); 278 278 279 struct sockaddr_in aSockName; 280 socklen_t aSockLen = sizeof (aSockName); 281 279 282 /*----------------------------------------------------------------*/ 280 283 if (!mServer) … … 291 294 } 292 295 296 getsockname (mServer, (struct sockaddr *) &aSockName, &aSockLen); 297 CRX_DEBUG_TRACE ("Connected on port number (%d)\n", ntohs (aSockName.sin_port)); 298 293 299 aResult = mServer.Send (mHttpRequest.GetHeader ().c_str (), aSize); 294 300 if (aResult != aSize) -
trunk/src/CRXSocket.cpp
r35 r38 9 9 # pragma comment (lib, "ws2_32.lib") 10 10 # define close(__socket) closesocket(__socket) 11 typedef int socklen_t;12 11 #endif 13 12
Note:
See TracChangeset
for help on using the changeset viewer.