Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
wine
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Package registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Alexey Alyaev
wine
Commits
fd6f83d0
Commit
fd6f83d0
authored
17 years ago
by
Alexandre Julliard
Browse files
Options
Downloads
Patches
Plain Diff
server: Take advantage of the fd generic wait queue to remove a lot of serial code.
parent
e92f8547
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
server/serial.c
+7
-87
7 additions, 87 deletions
server/serial.c
with
7 additions
and
87 deletions
server/serial.c
+
7
−
87
View file @
fd6f83d0
...
...
@@ -61,12 +61,9 @@ static struct fd *serial_get_fd( struct object *obj );
static
unsigned
int
serial_map_access
(
struct
object
*
obj
,
unsigned
int
access
);
static
void
serial_destroy
(
struct
object
*
obj
);
static
int
serial_get_poll_events
(
struct
fd
*
fd
);
static
void
serial_poll_event
(
struct
fd
*
fd
,
int
event
);
static
enum
server_fd_type
serial_get_info
(
struct
fd
*
fd
,
int
*
flags
);
static
void
serial_flush
(
struct
fd
*
fd
,
struct
event
**
event
);
static
void
serial_queue_async
(
struct
fd
*
fd
,
const
async_data_t
*
data
,
int
type
,
int
count
);
static
void
serial_cancel_async
(
struct
fd
*
fd
);
struct
serial
{
...
...
@@ -85,10 +82,6 @@ struct serial
struct
termios
original
;
struct
list
read_q
;
struct
list
write_q
;
struct
list
wait_q
;
/* FIXME: add dcb, comm status, handler module, sharing */
};
...
...
@@ -111,12 +104,12 @@ static const struct object_ops serial_ops =
static
const
struct
fd_ops
serial_fd_ops
=
{
serial
_get_poll_events
,
/* get_poll_events */
serial
_poll_event
,
/* poll_event */
default_fd
_get_poll_events
,
/* get_poll_events */
default
_poll_event
,
/* poll_event */
serial_flush
,
/* flush */
serial_get_info
,
/* get_file_info */
serial_queue_async
,
/* queue_async */
serial
_cancel_async
/* cancel_async */
default_fd
_cancel_async
/* cancel_async */
};
/* check if the given fd is a serial port */
...
...
@@ -146,9 +139,6 @@ struct object *create_serial( struct fd *fd, unsigned int options )
serial
->
writemult
=
0
;
serial
->
writeconst
=
0
;
serial
->
eventmask
=
0
;
list_init
(
&
serial
->
read_q
);
list_init
(
&
serial
->
write_q
);
list_init
(
&
serial
->
wait_q
);
serial
->
fd
=
(
struct
fd
*
)
grab_object
(
fd
);
set_fd_user
(
fd
,
&
serial_fd_ops
,
&
serial
->
obj
);
return
&
serial
->
obj
;
...
...
@@ -172,11 +162,7 @@ static unsigned int serial_map_access( struct object *obj, unsigned int access )
static
void
serial_destroy
(
struct
object
*
obj
)
{
struct
serial
*
serial
=
(
struct
serial
*
)
obj
;
async_terminate_queue
(
&
serial
->
read_q
,
STATUS_CANCELLED
);
async_terminate_queue
(
&
serial
->
write_q
,
STATUS_CANCELLED
);
async_terminate_queue
(
&
serial
->
wait_q
,
STATUS_CANCELLED
);
if
(
serial
->
fd
)
release_object
(
serial
->
fd
);
release_object
(
serial
->
fd
);
}
static
void
serial_dump
(
struct
object
*
obj
,
int
verbose
)
...
...
@@ -191,21 +177,6 @@ static struct serial *get_serial_obj( struct process *process, obj_handle_t hand
return
(
struct
serial
*
)
get_handle_obj
(
process
,
handle
,
access
,
&
serial_ops
);
}
static
int
serial_get_poll_events
(
struct
fd
*
fd
)
{
struct
serial
*
serial
=
get_fd_user
(
fd
);
int
events
=
0
;
assert
(
serial
->
obj
.
ops
==
&
serial_ops
);
if
(
!
list_empty
(
&
serial
->
read_q
))
events
|=
POLLIN
;
if
(
!
list_empty
(
&
serial
->
write_q
))
events
|=
POLLOUT
;
if
(
!
list_empty
(
&
serial
->
wait_q
))
events
|=
POLLIN
;
/* fprintf(stderr,"poll events are %04x\n",events); */
return
events
;
}
static
enum
server_fd_type
serial_get_info
(
struct
fd
*
fd
,
int
*
flags
)
{
struct
serial
*
serial
=
get_fd_user
(
fd
);
...
...
@@ -224,77 +195,26 @@ static enum server_fd_type serial_get_info( struct fd *fd, int *flags )
return
FD_TYPE_SERIAL
;
}
static
void
serial_poll_event
(
struct
fd
*
fd
,
int
event
)
{
struct
serial
*
serial
=
get_fd_user
(
fd
);
/* fprintf(stderr,"Poll event %02x\n",event); */
if
(
!
list_empty
(
&
serial
->
read_q
)
&&
(
POLLIN
&
event
)
)
async_terminate_head
(
&
serial
->
read_q
,
STATUS_ALERTED
);
if
(
!
list_empty
(
&
serial
->
write_q
)
&&
(
POLLOUT
&
event
)
)
async_terminate_head
(
&
serial
->
write_q
,
STATUS_ALERTED
);
if
(
!
list_empty
(
&
serial
->
wait_q
)
&&
(
POLLIN
&
event
)
)
async_terminate_head
(
&
serial
->
wait_q
,
STATUS_ALERTED
);
set_fd_events
(
fd
,
serial_get_poll_events
(
fd
)
);
}
static
void
serial_queue_async
(
struct
fd
*
fd
,
const
async_data_t
*
data
,
int
type
,
int
count
)
{
struct
serial
*
serial
=
get_fd_user
(
fd
);
struct
list
*
queue
;
struct
timeval
when
=
current_time
;
int
timeout
;
int
events
;
int
timeout
=
0
;
assert
(
serial
->
obj
.
ops
==
&
serial_ops
);
switch
(
type
)
{
case
ASYNC_TYPE_READ
:
queue
=
&
serial
->
read_q
;
timeout
=
serial
->
readconst
+
serial
->
readmult
*
count
;
break
;
case
ASYNC_TYPE_WAIT
:
queue
=
&
serial
->
wait_q
;
timeout
=
0
;
break
;
case
ASYNC_TYPE_WRITE
:
queue
=
&
serial
->
write_q
;
timeout
=
serial
->
writeconst
+
serial
->
writemult
*
count
;
break
;
default:
set_error
(
STATUS_INVALID_PARAMETER
);
return
;
}
add_timeout
(
&
when
,
timeout
);
if
(
!
create_async
(
current
,
timeout
?
&
when
:
NULL
,
queue
,
data
))
return
;
set_error
(
STATUS_PENDING
);
/* Check if the new pending request can be served immediately */
events
=
check_fd_events
(
fd
,
serial_get_poll_events
(
fd
)
);
if
(
events
)
{
/* serial_poll_event() calls set_select_events() */
serial_poll_event
(
fd
,
events
);
return
;
}
set_fd_events
(
fd
,
serial_get_poll_events
(
fd
)
);
}
static
void
serial_cancel_async
(
struct
fd
*
fd
)
{
struct
serial
*
serial
=
get_fd_user
(
fd
);
assert
(
serial
->
obj
.
ops
==
&
serial_ops
);
async_terminate_queue
(
&
serial
->
read_q
,
STATUS_CANCELLED
);
async_terminate_queue
(
&
serial
->
write_q
,
STATUS_CANCELLED
);
async_terminate_queue
(
&
serial
->
wait_q
,
STATUS_CANCELLED
);
fd_queue_async_timeout
(
fd
,
data
,
type
,
count
,
timeout
?
&
when
:
NULL
);
}
static
void
serial_flush
(
struct
fd
*
fd
,
struct
event
**
event
)
...
...
@@ -347,7 +267,7 @@ DECL_HANDLER(set_serial_info)
serial
->
eventmask
=
req
->
eventmask
;
if
(
!
serial
->
eventmask
)
{
async_terminate_queue
(
&
serial
->
wait_q
,
STATUS_SUCCESS
);
fd_
async_terminate_queue
(
serial
->
fd
,
ASYNC_TYPE_WAIT
,
STATUS_SUCCESS
);
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment