no message

This was SVN commit r64.
This commit is contained in:
janwas 2003-11-13 20:10:15 +00:00
parent 5faca15d7f
commit f12dd7dc94
3 changed files with 10 additions and 5 deletions

View File

@ -38,7 +38,7 @@
#define UNUSED(param) (void)param; #define UNUSED(param) (void)param;
#define ONCE(code) { pthread_mutex_t mutex=PTHREAD_MUTEX_INITIALIZER; if(pthread_mutex_trylock(&(mutex))==0) { code; } } #define ONCE(code) { static pthread_mutex_t mutex=PTHREAD_MUTEX_INITIALIZER; if(pthread_mutex_trylock(&(mutex))==0) { code; } }
template<bool> template<bool>

View File

@ -53,10 +53,12 @@ struct Req
static const int MAX_REQS = 4; static const int MAX_REQS = 4;
static Req reqs[MAX_REQS]; static Req reqs[MAX_REQS];
static HANDLE open_mutex, reqs_mutex; // TODO: use pthread mutex
static HANDLE open_mutex = INVALID_HANDLE_VALUE;
static HANDLE reqs_mutex = INVALID_HANDLE_VALUE;
#define LOCK(what)\ #define LOCK(what)\
{\ {\
if(!what##_mutex)\ if(what##_mutex == INVALID_HANDLE_VALUE)\
what##_mutex = CreateMutex(0,0,"aio_"#what);\ what##_mutex = CreateMutex(0,0,"aio_"#what);\
WaitForSingleObject(what##_mutex, INFINITE);\ WaitForSingleObject(what##_mutex, INFINITE);\
} }
@ -117,7 +119,10 @@ static void cleanup(void)
} }
CloseHandle(open_mutex); CloseHandle(open_mutex);
CloseHandle(reqs_mutex); open_mutex = INVALID_HANDLE_VALUE;
if(reqs_mutex != INVALID_HANDLE_VALUE) // happens if not initialized, i.e. aio_rw wasn't called
CloseHandle(reqs_mutex);
reqs_mutex = INVALID_HANDLE_VALUE;
} }
// called by aio_open and aio_open_winhandle // called by aio_open and aio_open_winhandle

View File

@ -219,7 +219,7 @@ void CStr::Replace(const CStr &ToReplace, const CStr &ReplaceWith)
// returns a trimed string, removes whitespace from the left/right/both // returns a trimed string, removes whitespace from the left/right/both
CStr CStr::Trim(PS_TRIM_MODE Mode) CStr CStr::Trim(PS_TRIM_MODE Mode)
{ {
size_t Left, Right; int Left, Right;
switch (Mode) switch (Mode)