Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
0964495b
Commit
0964495b
authored
Jan 07, 2002
by
Mike McCormack
Committed by
Alexandre Julliard
Jan 07, 2002
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- Don't use event flags with ReadFileEx and WriteFileEx.
- Use overlapped structure with WriteFile, since FILE_FLAG_OVERLAPPED is specified. - Cancel overlapped operations in CloseComm.
parent
5016e921
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
18 deletions
+38
-18
comm16.c
dlls/user/comm16.c
+38
-18
No files found.
dlls/user/comm16.c
View file @
0964495b
...
...
@@ -259,9 +259,16 @@ static VOID WINAPI COMM16_ReadComplete(DWORD status, DWORD len, LPOVERLAPPED ov)
}
ptr
=
&
COM
[
cid
];
/* we get cancelled when CloseComm is called */
if
(
status
==
STATUS_CANCELLED
)
{
TRACE
(
"Cancelled
\n
"
);
return
;
}
/* read data from comm port */
if
(
status
!=
STATUS_SUCCESS
)
{
ERR
(
"async read failed
\n
"
);
ERR
(
"async read failed
%08lx
\n
"
,
status
);
COM
[
cid
].
commerror
=
CE_RXOVER
;
return
;
}
...
...
@@ -303,6 +310,29 @@ static VOID WINAPI COMM16_ReadComplete(DWORD status, DWORD len, LPOVERLAPPED ov)
comm_waitread
(
ptr
);
}
/* this is meant to work like write() */
static
INT
COMM16_WriteFile
(
HANDLE
hComm
,
LPCVOID
buffer
,
DWORD
len
)
{
OVERLAPPED
ov
;
DWORD
count
=
-
1
;
ZeroMemory
(
&
ov
,
sizeof
ov
);
ov
.
hEvent
=
CreateEventA
(
NULL
,
0
,
0
,
NULL
);
if
(
ov
.
hEvent
==
INVALID_HANDLE_VALUE
)
return
-
1
;
if
(
!
WriteFile
(
hComm
,
buffer
,
len
,
&
count
,
&
ov
))
{
if
(
GetLastError
()
==
ERROR_IO_PENDING
)
{
GetOverlappedResult
(
hComm
,
&
ov
,
&
count
,
TRUE
);
}
}
CloseHandle
(
ov
.
hEvent
);
return
count
;
}
static
VOID
WINAPI
COMM16_WriteComplete
(
DWORD
status
,
DWORD
len
,
LPOVERLAPPED
ov
)
{
int
prev
,
bleft
;
...
...
@@ -332,8 +362,7 @@ static VOID WINAPI COMM16_WriteComplete(DWORD status, DWORD len, LPOVERLAPPED ov
/* write any TransmitCommChar character */
if
(
ptr
->
xmit
>=
0
)
{
if
(
!
WriteFile
(
ptr
->
handle
,
&
(
ptr
->
xmit
),
1
,
&
len
,
NULL
))
len
=
-
1
;
len
=
COMM16_WriteFile
(
ptr
->
handle
,
&
(
ptr
->
xmit
),
1
);
if
(
len
>
0
)
ptr
->
xmit
=
-
1
;
}
...
...
@@ -564,8 +593,6 @@ INT16 WINAPI OpenComm16(LPCSTR device,UINT16 cbInQueue,UINT16 cbOutQueue)
ZeroMemory
(
&
COM
[
port
].
read_ov
,
sizeof
(
OVERLAPPED
));
ZeroMemory
(
&
COM
[
port
].
write_ov
,
sizeof
(
OVERLAPPED
));
COM
[
port
].
read_ov
.
hEvent
=
CreateEventA
(
NULL
,
0
,
0
,
NULL
);
COM
[
port
].
write_ov
.
hEvent
=
CreateEventA
(
NULL
,
0
,
0
,
NULL
);
comm_waitread
(
&
COM
[
port
]
);
USER16_AlertableWait
++
;
...
...
@@ -611,9 +638,8 @@ INT16 WINAPI CloseComm16(INT16 cid)
if
(
!
(
cid
&
FLAG_LPT
))
{
/* COM port */
UnMapLS
(
COM
[
cid
].
seg_unknown
);
CloseHandle
(
COM
[
cid
].
read_ov
.
hEvent
);
CloseHandle
(
COM
[
cid
].
write_ov
.
hEvent
);
USER16_AlertableWait
--
;
CancelIo
(
ptr
->
handle
);
/* free buffers */
free
(
ptr
->
outbuf
);
...
...
@@ -793,14 +819,9 @@ INT16 WINAPI GetCommError16(INT16 cid,LPCOMSTAT16 lpStat)
COMM_MSRUpdate
(
ptr
->
handle
,
stol
);
if
(
lpStat
)
{
HANDLE
rw_events
[
2
];
lpStat
->
status
=
0
;
rw_events
[
0
]
=
COM
[
cid
].
read_ov
.
hEvent
;
rw_events
[
1
]
=
COM
[
cid
].
write_ov
.
hEvent
;
WaitForMultipleObjectsEx
(
2
,
&
rw_events
[
0
],
FALSE
,
1
,
TRUE
);
WaitForMultipleObjectsEx
(
0
,
NULL
,
FALSE
,
1
,
TRUE
);
lpStat
->
cbOutQue
=
comm_outbuf
(
ptr
);
lpStat
->
cbInQue
=
comm_inbuf
(
ptr
);
...
...
@@ -1002,8 +1023,8 @@ INT16 WINAPI TransmitCommChar16(INT16 cid,CHAR chTransmit)
if
(
ptr
->
obuf_head
==
ptr
->
obuf_tail
)
{
/* transmit queue empty, try to transmit directly */
DWORD
len
;
if
(
!
WriteFile
(
ptr
->
handle
,
&
chTransmit
,
1
,
&
len
,
NULL
))
{
if
(
1
!=
COMM16_WriteFile
(
ptr
->
handle
,
&
chTransmit
,
1
))
{
/* didn't work, queue it */
ptr
->
xmit
=
chTransmit
;
comm_waitwrite
(
ptr
);
...
...
@@ -1070,7 +1091,7 @@ INT16 WINAPI ReadComm16(INT16 cid,LPSTR lpvBuf,INT16 cbRead)
}
if
(
0
==
comm_inbuf
(
ptr
))
WaitFor
SingleObjectEx
(
COM
[
cid
].
read_ov
.
hEvent
,
1
,
TRUE
);
WaitFor
MultipleObjectsEx
(
0
,
NULL
,
FALSE
,
1
,
TRUE
);
/* read unget character */
if
(
ptr
->
unget
>=
0
)
{
...
...
@@ -1128,8 +1149,7 @@ INT16 WINAPI WriteComm16(INT16 cid, LPSTR lpvBuf, INT16 cbWrite)
while
(
length
<
cbWrite
)
{
if
((
ptr
->
obuf_head
==
ptr
->
obuf_tail
)
&&
(
ptr
->
xmit
<
0
))
{
/* no data queued, try to write directly */
if
(
!
WriteFile
(
ptr
->
handle
,
lpvBuf
,
cbWrite
-
length
,
(
LPDWORD
)
&
status
,
NULL
))
status
=
-
1
;
status
=
COMM16_WriteFile
(
ptr
->
handle
,
lpvBuf
,
cbWrite
-
length
);
if
(
status
>
0
)
{
lpvBuf
+=
status
;
length
+=
status
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment