Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
EtherBone Core
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor 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
Projects
EtherBone Core
Commits
0cee35af
Commit
0cee35af
authored
11 years ago
by
Wesley W. Terpstra
Browse files
Options
Downloads
Patches
Plain Diff
api device: cache fcntl flags => less syscalls => faster transfers
parent
97cbb6fd
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
api/transport/dev.c
+11
-6
11 additions, 6 deletions
api/transport/dev.c
api/transport/dev.h
+1
-0
1 addition, 0 deletions
api/transport/dev.h
with
12 additions
and
6 deletions
api/transport/dev.c
+
11
−
6
View file @
0cee35af
...
...
@@ -43,11 +43,14 @@
#define O_BINARY 0
#endif
static
void
eb_dev_set_blocking
(
int
fdes
,
int
block
)
{
static
void
eb_dev_set_blocking
(
struct
eb_dev_link
*
link
,
int
block
)
{
int
flags
;
flags
=
fcntl
(
fdes
,
F_GETFL
,
0
);
fcntl
(
fdes
,
F_SETFL
,
(
flags
&~
O_NONBLOCK
)
|
(
block
?
0
:
O_NONBLOCK
));
flags
=
(
link
->
flags
&
~
O_NONBLOCK
)
|
(
block
?
0
:
O_NONBLOCK
);
if
(
flags
!=
link
->
flags
)
{
fcntl
(
link
->
fdes
,
F_SETFL
,
flags
);
link
->
flags
=
flags
;
}
}
static
int
eb_dev_ewouldblock
()
{
...
...
@@ -86,6 +89,8 @@ eb_status_t eb_dev_connect(struct eb_transport* transportp, struct eb_link* link
}
link
->
fdes
=
fdes
;
link
->
flags
=
fcntl
(
fdes
,
F_GETFL
,
0
);
return
EB_OK
;
}
...
...
@@ -123,7 +128,7 @@ int eb_dev_poll(struct eb_transport* transportp, struct eb_link* linkp, eb_user_
return
0
;
/* Set non-blocking */
eb_dev_set_blocking
(
link
->
fdes
,
0
);
eb_dev_set_blocking
(
link
,
0
);
result
=
read
(
link
->
fdes
,
(
char
*
)
buf
,
len
);
if
(
result
==
-
1
&&
eb_dev_ewouldblock
())
return
0
;
...
...
@@ -140,7 +145,7 @@ int eb_dev_recv(struct eb_transport* transportp, struct eb_link* linkp, uint8_t*
link
=
(
struct
eb_dev_link
*
)
linkp
;
/* Set blocking */
eb_dev_set_blocking
(
link
->
fdes
,
1
);
eb_dev_set_blocking
(
link
,
1
);
result
=
read
(
link
->
fdes
,
buf
,
len
);
...
...
@@ -157,7 +162,7 @@ void eb_dev_send(struct eb_transport* transportp, struct eb_link* linkp, const u
link
=
(
struct
eb_dev_link
*
)
linkp
;
/* Set blocking */
eb_dev_set_blocking
(
link
->
fdes
,
1
);
eb_dev_set_blocking
(
link
,
1
);
write
(
link
->
fdes
,
buf
,
len
);
}
...
...
This diff is collapsed.
Click to expand it.
api/transport/dev.h
+
1
−
0
View file @
0cee35af
...
...
@@ -51,6 +51,7 @@ struct eb_dev_transport {
struct
eb_dev_link
{
/* Contents must fit in 12 bytes */
int
fdes
;
int
flags
;
};
#endif
This diff is collapsed.
Click to expand it.
Preview
0%
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