summaryrefslogtreecommitdiff
path: root/ext/socket/socket.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-04-06 11:04:45 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-04-06 11:04:45 +0000
commit67fe038d8f27a71b81a71048abd4174ded45a551 (patch)
treed927db7b306387827d611febfbfd2ae4e3671b5b /ext/socket/socket.c
parentc7135ddd2dcd59ca46ea3307b21f68dea7504ac8 (diff)
* ext/socket/socket.c (rsock_sys_fail_sockaddr): Takes struct sockaddr
and socklen_t instead of String object. (rsock_sys_fail_addrinfo_or_sockaddr): Follow the above change. * ext/socket/rubysocket.h (rsock_sys_fail_sockaddr): Follow the above change. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40157 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/socket/socket.c')
-rw-r--r--ext/socket/socket.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/ext/socket/socket.c b/ext/socket/socket.c
index 9783313..bb8bdac 100644
--- a/ext/socket/socket.c
+++ b/ext/socket/socket.c
@@ -47,14 +47,11 @@ rsock_sys_fail_path(const char *mesg, VALUE path)
}
void
-rsock_sys_fail_sockaddr(const char *mesg, VALUE addr)
+rsock_sys_fail_sockaddr(const char *mesg, struct sockaddr *addr, socklen_t len)
{
VALUE rai;
- rai = rsock_addrinfo_new(
- (struct sockaddr *)RSTRING_PTR(addr),
- (socklen_t)RSTRING_LEN(addr), /* overflow should be checked already */
- PF_UNSPEC, 0, 0, Qnil, Qnil);
+ rai = rsock_addrinfo_new(addr, len, PF_UNSPEC, 0, 0, Qnil, Qnil);
rsock_sys_fail_addrinfo(mesg, rai);
}
@@ -73,8 +70,12 @@ rsock_sys_fail_addrinfo(const char *mesg, VALUE rai)
void
rsock_sys_fail_addrinfo_or_sockaddr(const char *mesg, VALUE addr, VALUE rai)
{
- if (NIL_P(rai))
- rsock_sys_fail_sockaddr(mesg, addr);
+ if (NIL_P(rai)) {
+ StringValue(addr);
+ rsock_sys_fail_sockaddr(mesg,
+ (struct sockaddr *)RSTRING_PTR(addr),
+ (socklen_t)RSTRING_LEN(addr)); /* overflow should be checked already */
+ }
else
rsock_sys_fail_addrinfo(mesg, rai);
}