summaryrefslogtreecommitdiff
path: root/ext/socket/udpsocket.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-02-19 09:38:24 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-02-19 09:38:24 +0000
commitdd1c3a75096b97c1ebcb8597c001761ddfb3c1bf (patch)
treeba30a88f2e2fe0e036867d21abf835ccef3b29b4 /ext/socket/udpsocket.c
parent948ce9decb97e5ff0833e53a392aa9f1d42c9b0d (diff)
* 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
Diffstat (limited to 'ext/socket/udpsocket.c')
-rw-r--r--ext/socket/udpsocket.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/ext/socket/udpsocket.c b/ext/socket/udpsocket.c
index 7a40d9a..eb605ca 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);
}