[前][次][番号順一覧][スレッド一覧]

ruby-changes:28105

From: akr <ko1@a...>
Date: Sat, 6 Apr 2013 20:05:37 +0900 (JST)
Subject: [ruby-changes:28105] akr:r40157 (trunk): * ext/socket/socket.c (rsock_sys_fail_sockaddr): Takes struct sockaddr

akr	2013-04-06 20:04:45 +0900 (Sat, 06 Apr 2013)

  New Revision: 40157

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=40157

  Log:
    * 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.

  Modified files:
    trunk/ChangeLog
    trunk/ext/socket/rubysocket.h
    trunk/ext/socket/socket.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 40156)
+++ ChangeLog	(revision 40157)
@@ -1,3 +1,12 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sat Apr  6 19:24:59 2013  Tanaka Akira  <akr@f...>
+
+	* 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.
+
 Sat Apr  6 14:28:23 2013  Tanaka Akira  <akr@f...>
 
 	* ext/socket/rubysocket.h (SockAddrStringValueWithAddrinfo): New macro.
Index: ext/socket/rubysocket.h
===================================================================
--- ext/socket/rubysocket.h	(revision 40156)
+++ ext/socket/rubysocket.h	(revision 40157)
@@ -342,7 +342,7 @@ void rsock_init_socket_init(void); https://github.com/ruby/ruby/blob/trunk/ext/socket/rubysocket.h#L342
 
 NORETURN(void rsock_sys_fail_host_port(const char *, VALUE, VALUE));
 NORETURN(void rsock_sys_fail_path(const char *, VALUE));
-NORETURN(void rsock_sys_fail_sockaddr(const char *, VALUE addr));
+NORETURN(void rsock_sys_fail_sockaddr(const char *, struct sockaddr *addr, socklen_t len));
 NORETURN(void rsock_sys_fail_addrinfo(const char *, VALUE rai));
 NORETURN(void rsock_sys_fail_sockaddr_or_addrinfo(const char *, VALUE addr, VALUE rai));
 
Index: ext/socket/socket.c
===================================================================
--- ext/socket/socket.c	(revision 40156)
+++ ext/socket/socket.c	(revision 40157)
@@ -47,14 +47,11 @@ rsock_sys_fail_path(const char *mesg, VA https://github.com/ruby/ruby/blob/trunk/ext/socket/socket.c#L47
 }
 
 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 https://github.com/ruby/ruby/blob/trunk/ext/socket/socket.c#L70
 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);
 }

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]