freebsd-ports/palm/pose/files/patch-ae
Michael Haro 4ee38fcfd8 update to 3.1
PR:		26335
Submitted by:	    William Lloyd <wlloyd@galt.slap.net> (new maintainer)
2001-04-04 09:02:43 +00:00

125 lines
2.7 KiB
Plaintext

--- ../SrcUnix/EmTransportSerialUnix.cpp.orig Fri Mar 30 11:41:13 2001
+++ ../SrcUnix/EmTransportSerialUnix.cpp Fri Mar 30 11:47:36 2001
@@ -382,9 +382,9 @@
EmHostTransportSerial::EmHostTransportSerial (void) :
fReadThread (NULL),
fWriteThread (NULL),
- fCommHandle (0),
- fCommSignalPipeA (0),
- fCommSignalPipeB (0),
+ fCommHandle (-1),
+ fCommSignalPipeA (-1),
+ fCommSignalPipeB (-1),
fTimeToQuit (false),
fDataMutex (),
fDataCondition (&fDataMutex),
@@ -412,9 +412,9 @@
{
assert (fReadThread == NULL);
assert (fWriteThread == NULL);
- assert (fCommHandle == 0);
- assert (fCommSignalPipeA == 0);
- assert (fCommSignalPipeB == 0);
+ assert (fCommHandle == -1);
+ assert (fCommSignalPipeA == -1);
+ assert (fCommSignalPipeB == -1);
}
@@ -450,7 +450,7 @@
if (fCommHandle <= 0)
{
- fCommHandle = 0;
+ fCommHandle = -1;
return errno;
}
@@ -480,7 +480,7 @@
ErrCode EmHostTransportSerial::CreateCommThreads (const EmTransportSerial::ConfigSerial& /*config*/)
{
- if (fCommHandle)
+ if (fCommHandle != -1)
{
PRINTF ("EmTransportSerial::HostOpen: Creating serial port handler threads...");
@@ -525,35 +525,38 @@
// Signal the threads to quit.
- fDataMutex.lock ();
+ if ( fCommSignalPipeA != -1 && fCommSignalPipeB != -1 ) {
+ fDataMutex.lock ();
+
+ fTimeToQuit = true;
+
+ int dummy = 0;
+ write (fCommSignalPipeB, &dummy, sizeof (dummy)); // Signals CommRead.
- fTimeToQuit = true;
+ fDataCondition.broadcast (); // Signals CommWrite.
+ fDataMutex.unlock ();
- int dummy = 0;
- write (fCommSignalPipeB, &dummy, sizeof (dummy)); // Signals CommRead.
+ // Wait for the threads to quit.
- fDataCondition.broadcast (); // Signals CommWrite.
- fDataMutex.unlock ();
-
- // Wait for the threads to quit.
+ if (fReadThread)
+ {
+ fReadThread->join (NULL);
+ fWriteThread->join (NULL);
+ }
- if (fReadThread)
- {
- fReadThread->join (NULL);
- fWriteThread->join (NULL);
- }
+ // Thread objects delete themselves, so set our references to NULL.
- // Thread objects delete themselves, so set our references to NULL.
+ fReadThread = NULL;
+ fWriteThread = NULL;
- fReadThread = NULL;
- fWriteThread = NULL;
+ // Close the signal pipe.
- // Close the signal pipe.
+ close (fCommSignalPipeA);
+ close (fCommSignalPipeB);
- close (fCommSignalPipeA);
- close (fCommSignalPipeB);
+ fCommSignalPipeA = fCommSignalPipeB = 0;
- fCommSignalPipeA = fCommSignalPipeB = 0;
+ }
return errNone;
}
@@ -573,11 +576,13 @@
ErrCode EmHostTransportSerial::CloseCommPort (void)
{
- (void) close (fCommHandle);
-
- fCommHandle = 0;
-
- return errNone;
+ if ( fCommHandle != -1 ) {
+ int result = close (fCommHandle);
+
+ fCommHandle = -1;
+ }
+
+ return errNone;
}