From dd1c3a75096b97c1ebcb8597c001761ddfb3c1bf Mon Sep 17 00:00:00 2001 From: akr Date: Wed, 19 Feb 2014 09:38:24 +0000 Subject: * ext/socket: Wrap struct addrinfo by struct rb_addrinfo. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45046 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/socket/udpsocket.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'ext/socket/udpsocket.c') diff --git a/ext/socket/udpsocket.c b/ext/socket/udpsocket.c index 7a40d9aa23..eb605cafc1 100644 --- a/ext/socket/udpsocket.c +++ b/ext/socket/udpsocket.c @@ -44,7 +44,7 @@ udp_init(int argc, VALUE *argv, VALUE sock) struct udp_arg { - struct addrinfo *res; + struct rb_addrinfo *res; int fd; }; @@ -54,7 +54,7 @@ udp_connect_internal(struct udp_arg *arg) int fd = arg->fd; struct addrinfo *res; - for (res = arg->res; res; res = res->ai_next) { + for (res = arg->res->ai; res; res = res->ai_next) { if (rsock_connect(fd, res->ai_addr, res->ai_addrlen, 0) >= 0) { return Qtrue; } @@ -62,8 +62,6 @@ udp_connect_internal(struct udp_arg *arg) return Qfalse; } -VALUE rsock_freeaddrinfo(struct addrinfo *addr); - /* * call-seq: * udpsocket.connect(host, port) => 0 @@ -113,19 +111,20 @@ static VALUE udp_bind(VALUE sock, VALUE host, VALUE port) { rb_io_t *fptr; - struct addrinfo *res0, *res; + struct rb_addrinfo *res0; + struct addrinfo *res; rb_secure(3); res0 = rsock_addrinfo(host, port, SOCK_DGRAM, 0); GetOpenFile(sock, fptr); - for (res = res0; res; res = res->ai_next) { + for (res = res0->ai; res; res = res->ai_next) { if (bind(fptr->fd, res->ai_addr, res->ai_addrlen) < 0) { continue; } - freeaddrinfo(res0); + rb_freeaddrinfo(res0); return INT2FIX(0); } - freeaddrinfo(res0); + rb_freeaddrinfo(res0); rsock_sys_fail_host_port("bind(2)", host, port); @@ -160,7 +159,8 @@ udp_send(int argc, VALUE *argv, VALUE sock) VALUE flags, host, port; rb_io_t *fptr; int n; - struct addrinfo *res0, *res; + struct rb_addrinfo *res0; + struct addrinfo *res; struct rsock_send_arg arg; if (argc == 2 || argc == 3) { @@ -173,21 +173,21 @@ udp_send(int argc, VALUE *argv, VALUE sock) GetOpenFile(sock, fptr); arg.fd = fptr->fd; arg.flags = NUM2INT(flags); - for (res = res0; res; res = res->ai_next) { + for (res = res0->ai; res; res = res->ai_next) { retry: arg.to = res->ai_addr; arg.tolen = res->ai_addrlen; rsock_maybe_fd_writable(arg.fd); n = (int)BLOCKING_REGION_FD(rsock_sendto_blocking, &arg); if (n >= 0) { - freeaddrinfo(res0); + rb_freeaddrinfo(res0); return INT2FIX(n); } if (rb_io_wait_writable(fptr->fd)) { goto retry; } } - freeaddrinfo(res0); + rb_freeaddrinfo(res0); rsock_sys_fail_host_port("sendto(2)", host, port); return INT2FIX(n); } -- cgit v1.2.3