Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mruby
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
mruby
Commits
0866fa38
Commit
0866fa38
authored
Apr 17, 2018
by
Yukihiro "Matz" Matsumoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Avoid unnecessary object allocation (addrinfo) in `_accept`; ref #3999
parent
f7cf5812
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
3 deletions
+18
-3
mrbgems/mruby-socket/mrblib/socket.rb
mrbgems/mruby-socket/mrblib/socket.rb
+3
-3
mrbgems/mruby-socket/src/socket.c
mrbgems/mruby-socket/src/socket.c
+15
-0
No files found.
mrbgems/mruby-socket/mrblib/socket.rb
View file @
0866fa38
...
@@ -302,7 +302,7 @@ class TCPServer < TCPSocket
...
@@ -302,7 +302,7 @@ class TCPServer < TCPSocket
end
end
def
sysaccept
def
sysaccept
Socket
.
_accept
(
self
.
fileno
)
[
0
]
Socket
.
_accept
(
self
.
fileno
)
end
end
end
end
...
@@ -463,7 +463,7 @@ class Socket < BasicSocket
...
@@ -463,7 +463,7 @@ class Socket < BasicSocket
end
end
def
sysaccept
def
sysaccept
Socket
.
_accept
(
self
.
fileno
)
Socket
.
_accept
2
(
self
.
fileno
)
end
end
end
end
...
@@ -566,7 +566,7 @@ class UNIXServer < UNIXSocket
...
@@ -566,7 +566,7 @@ class UNIXServer < UNIXSocket
end
end
def
sysaccept
def
sysaccept
Socket
.
_accept
(
self
.
fileno
)
[
0
]
Socket
.
_accept
(
self
.
fileno
)
end
end
end
end
...
...
mrbgems/mruby-socket/src/socket.c
View file @
0866fa38
...
@@ -588,6 +588,20 @@ mrb_socket_gethostname(mrb_state *mrb, mrb_value cls)
...
@@ -588,6 +588,20 @@ mrb_socket_gethostname(mrb_state *mrb, mrb_value cls)
static
mrb_value
static
mrb_value
mrb_socket_accept
(
mrb_state
*
mrb
,
mrb_value
klass
)
mrb_socket_accept
(
mrb_state
*
mrb
,
mrb_value
klass
)
{
int
s1
;
mrb_int
s0
;
mrb_get_args
(
mrb
,
"i"
,
&
s0
);
s1
=
(
int
)
accept
(
s0
,
NULL
,
NULL
);
if
(
s1
==
-
1
)
{
mrb_sys_fail
(
mrb
,
"accept"
);
}
return
mrb_fixnum_value
(
s1
);
}
static
mrb_value
mrb_socket_accept2
(
mrb_state
*
mrb
,
mrb_value
klass
)
{
{
mrb_value
ary
,
sastr
;
mrb_value
ary
,
sastr
;
int
s1
;
int
s1
;
...
@@ -872,6 +886,7 @@ mrb_mruby_socket_gem_init(mrb_state* mrb)
...
@@ -872,6 +886,7 @@ mrb_mruby_socket_gem_init(mrb_state* mrb)
sock
=
mrb_define_class
(
mrb
,
"Socket"
,
bsock
);
sock
=
mrb_define_class
(
mrb
,
"Socket"
,
bsock
);
mrb_define_class_method
(
mrb
,
sock
,
"_accept"
,
mrb_socket_accept
,
MRB_ARGS_REQ
(
1
));
mrb_define_class_method
(
mrb
,
sock
,
"_accept"
,
mrb_socket_accept
,
MRB_ARGS_REQ
(
1
));
mrb_define_class_method
(
mrb
,
sock
,
"_accept2"
,
mrb_socket_accept2
,
MRB_ARGS_REQ
(
1
));
mrb_define_class_method
(
mrb
,
sock
,
"_bind"
,
mrb_socket_bind
,
MRB_ARGS_REQ
(
3
));
mrb_define_class_method
(
mrb
,
sock
,
"_bind"
,
mrb_socket_bind
,
MRB_ARGS_REQ
(
3
));
mrb_define_class_method
(
mrb
,
sock
,
"_connect"
,
mrb_socket_connect
,
MRB_ARGS_REQ
(
3
));
mrb_define_class_method
(
mrb
,
sock
,
"_connect"
,
mrb_socket_connect
,
MRB_ARGS_REQ
(
3
));
mrb_define_class_method
(
mrb
,
sock
,
"_listen"
,
mrb_socket_listen
,
MRB_ARGS_REQ
(
2
));
mrb_define_class_method
(
mrb
,
sock
,
"_listen"
,
mrb_socket_listen
,
MRB_ARGS_REQ
(
2
));
...
...
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