Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
relibc
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
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
Tornax O7
relibc
Commits
25e67b9f
Verified
Commit
25e67b9f
authored
5 years ago
by
Jeremy Soller
Browse files
Options
Downloads
Patches
Plain Diff
Add setsockopt support for SO_RCVTIMEO and SO_SNDTIMEO
parent
9d7ec9b1
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
src/platform/redox/socket.rs
+66
-0
66 additions, 0 deletions
src/platform/redox/socket.rs
with
66 additions
and
0 deletions
src/platform/redox/socket.rs
+
66
−
0
View file @
25e67b9f
...
...
@@ -8,6 +8,7 @@ use super::{e, Sys};
use
header
::
netinet_in
::{
in_port_t
,
sockaddr_in
};
use
header
::
sys_socket
::
constants
::
*
;
use
header
::
sys_socket
::{
sockaddr
,
socklen_t
};
use
header
::
sys_time
::
timeval
;
macro_rules!
bind_or_connect
{
(
bind
$path:expr
)
=>
{
...
...
@@ -143,6 +144,14 @@ impl PalSocket for Sys {
option_value
:
*
mut
c_void
,
option_len
:
*
mut
socklen_t
,
)
->
c_int
{
eprintln!
(
"getsockopt({}, {}, {}, {:p}, {:p})"
,
socket
,
level
,
option_name
,
option_value
,
option_len
);
e
(
Err
(
syscall
::
Error
::
new
(
syscall
::
ENOSYS
)))
as
c_int
}
...
...
@@ -210,10 +219,60 @@ impl PalSocket for Sys {
option_value
:
*
const
c_void
,
option_len
:
socklen_t
,
)
->
c_int
{
let
set_timeout
=
|
timeout_name
:
&
[
u8
]|
->
c_int
{
if
option_value
.is_null
()
{
return
e
(
Err
(
syscall
::
Error
::
new
(
syscall
::
EFAULT
)))
as
c_int
;
}
if
(
option_len
as
usize
)
<
mem
::
size_of
::
<
timeval
>
()
{
return
e
(
Err
(
syscall
::
Error
::
new
(
syscall
::
EINVAL
)))
as
c_int
;
}
let
timeval
=
unsafe
{
&*
(
option_value
as
*
const
timeval
)
};
let
fd
=
e
(
syscall
::
dup
(
socket
as
usize
,
timeout_name
));
if
fd
==
!
0
{
return
-
1
;
}
let
timespec
=
syscall
::
TimeSpec
{
tv_sec
:
timeval
.tv_sec
,
tv_nsec
:
timeval
.tv_usec
*
1000
,
};
let
ret
=
Self
::
write
(
fd
as
c_int
,
&
timespec
);
let
_
=
syscall
::
close
(
fd
);
if
ret
>=
0
{
0
}
else
{
-
1
}
};
match
level
{
SOL_SOCKET
=>
match
option_name
{
SO_RCVTIMEO
=>
return
set_timeout
(
b"read_timeout"
),
SO_SNDTIMEO
=>
return
set_timeout
(
b"write_timeout"
),
_
=>
(),
},
_
=>
()
}
eprintln!
(
"setsockopt({}, {}, {}, {:p}, {})"
,
socket
,
level
,
option_name
,
option_value
,
option_len
);
e
(
Err
(
syscall
::
Error
::
new
(
syscall
::
ENOSYS
)))
as
c_int
}
fn
shutdown
(
socket
:
c_int
,
how
:
c_int
)
->
c_int
{
eprintln!
(
"shutdown({}, {})"
,
socket
,
how
);
e
(
Err
(
syscall
::
Error
::
new
(
syscall
::
ENOSYS
)))
as
c_int
}
...
...
@@ -250,6 +309,13 @@ impl PalSocket for Sys {
}
fn
socketpair
(
domain
:
c_int
,
kind
:
c_int
,
protocol
:
c_int
,
sv
:
&
mut
[
c_int
;
2
])
->
c_int
{
eprintln!
(
"socketpair({}, {}, {}, {:p})"
,
domain
,
kind
,
protocol
,
sv
.as_mut_ptr
()
);
unsafe
{
errno
=
syscall
::
ENOSYS
};
return
-
1
;
}
...
...
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