Changeset 33729 in vbox for trunk/src/VBox
- Timestamp:
- Nov 3, 2010 3:13:21 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Serial/DrvHostSerial.cpp
r33728 r33729 501 501 * Write the character to the host device. 502 502 */ 503 #ifdef RT_OS_DARWIN504 503 while (pThread->enmState == PDMTHREADSTATE_RUNNING) 505 504 { … … 593 592 } 594 593 } /* write loop */ 595 596 #else /* old code */597 uint32_t iTail;598 while ( pThread->enmState == PDMTHREADSTATE_RUNNING599 && (iTail = ASMAtomicUoReadU32(&pThis->iSendQueueTail)) != ASMAtomicUoReadU32(&pThis->iSendQueueHead))600 {601 /** @todo process more than one byte? */602 unsigned cbProcessed = 1;603 uint8_t abBuf[1];604 abBuf[0] = pThis->aSendQueue[iTail];605 606 # if defined(RT_OS_LINUX) || defined(RT_OS_DARWIN) || defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD)607 608 rc = RTFileWrite(pThis->DeviceFile, abBuf, cbProcessed, NULL);609 610 # elif defined(RT_OS_WINDOWS)611 612 DWORD cbBytesWritten;613 memset(&pThis->overlappedSend, 0, sizeof(pThis->overlappedSend));614 pThis->overlappedSend.hEvent = pThis->hEventSend;615 616 if (!WriteFile(pThis->hDeviceFile, abBuf, cbProcessed, &cbBytesWritten, &pThis->overlappedSend))617 {618 dwRet = GetLastError();619 if (dwRet == ERROR_IO_PENDING)620 {621 /*622 * write blocked, wait ...623 */624 dwRet = WaitForMultipleObjects(2, haWait, FALSE, INFINITE);625 if (dwRet != WAIT_OBJECT_0)626 {627 AssertMsg(pThread->enmState != PDMTHREADSTATE_RUNNING, ("The halt event semaphore is set but the thread is still in running state\n"));628 break;629 }630 }631 else632 rc = RTErrConvertFromWin32(dwRet);633 }634 635 # endif636 637 if (RT_SUCCESS(rc))638 {639 Assert(cbProcessed == 1);640 ASMAtomicWriteU32(&pThis->iSendQueueTail, (iTail + 1) & CHAR_MAX_SEND_QUEUE_MASK);641 }642 else if (RT_FAILURE(rc))643 {644 LogRel(("HostSerial#%d: Serial Write failed with %Rrc; terminating send thread\n", pDrvIns->iInstance, rc));645 return rc;646 }647 }648 #endif /* old code */649 594 } 650 595 … … 1364 1309 uint32_t fOpen = RTFILE_O_READWRITE | RTFILE_O_OPEN | RTFILE_O_DENY_NONE; 1365 1310 # ifdef RT_OS_LINUX 1366 /* This seems to be necessary on some Linux hosts, otherwise we hang here forever. 1367 * Surprisingly, I've never seen VERR_TRY_AGAIN as result even if RTFileOpen() 1368 * would block without that flag. */ 1311 /* This seems to be necessary on some Linux hosts, otherwise we hang here forever. */ 1369 1312 fOpen |= RTFILE_O_NON_BLOCK; 1370 1313 # endif 1371 1314 rc = RTFileOpen(&pThis->DeviceFile, pThis->pszDevicePath, fOpen); 1372 1315 # ifdef RT_OS_LINUX 1316 /* RTFILE_O_NON_BLOCK not supported? */ 1373 1317 if (rc == VERR_INVALID_PARAMETER) 1374 1318 rc = RTFileOpen(&pThis->DeviceFile, pThis->pszDevicePath, fOpen & ~RTFILE_O_NON_BLOCK);
Note:
See TracChangeset
for help on using the changeset viewer.