mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* ext/socket/init.c (struct recvfrom_arg): use struct
sockaddr_storage. (recvfrom_blocking): follow struct recvfrom_arg change. (s_recvfrom): ditto. (s_recvfrom_nonblock): use struct sockaddr_storage. * ext/socket/socket.c (sock_accept): use struct sockaddr_storage. (sock_accept_nonblock): ditto. (sock_sysaccept): ditto. * ext/socket/ancdata.c (bsock_recvmsg_internal): use struct sockaddr_storage. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22214 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
6245caf58c
commit
2ee0859119
4 changed files with 36 additions and 21 deletions
15
ChangeLog
15
ChangeLog
|
@ -1,3 +1,18 @@
|
|||
Tue Feb 10 23:44:53 2009 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* ext/socket/init.c (struct recvfrom_arg): use struct
|
||||
sockaddr_storage.
|
||||
(recvfrom_blocking): follow struct recvfrom_arg change.
|
||||
(s_recvfrom): ditto.
|
||||
(s_recvfrom_nonblock): use struct sockaddr_storage.
|
||||
|
||||
* ext/socket/socket.c (sock_accept): use struct sockaddr_storage.
|
||||
(sock_accept_nonblock): ditto.
|
||||
(sock_sysaccept): ditto.
|
||||
|
||||
* ext/socket/ancdata.c (bsock_recvmsg_internal): use struct
|
||||
sockaddr_storage.
|
||||
|
||||
Tue Feb 10 23:30:32 2009 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* ext/socket/basicsocket.c (bsock_getpeername): use struct
|
||||
|
|
|
@ -952,7 +952,7 @@ bsock_recvmsg_internal(int argc, VALUE *argv, VALUE sock, int nonblock)
|
|||
#if defined(HAVE_ST_MSG_CONTROL)
|
||||
struct cmsghdr *cmh;
|
||||
#endif
|
||||
char namebuf[1024];
|
||||
struct sockaddr_storage namebuf;
|
||||
char datbuf0[4096], *datbuf;
|
||||
char ctlbuf0[4096], *ctlbuf;
|
||||
VALUE dat_str = Qnil;
|
||||
|
@ -1014,8 +1014,8 @@ bsock_recvmsg_internal(int argc, VALUE *argv, VALUE sock, int nonblock)
|
|||
|
||||
memset(&mh, 0, sizeof(mh));
|
||||
|
||||
memset(namebuf, 0, sizeof(namebuf));
|
||||
mh.msg_name = namebuf;
|
||||
memset(&namebuf, 0, sizeof(namebuf));
|
||||
mh.msg_name = (struct sockaddr *)&namebuf;
|
||||
mh.msg_namelen = sizeof(namebuf);
|
||||
|
||||
mh.msg_iov = &iov;
|
||||
|
|
|
@ -78,7 +78,7 @@ struct recvfrom_arg {
|
|||
int fd, flags;
|
||||
VALUE str;
|
||||
socklen_t alen;
|
||||
char buf[1024];
|
||||
struct sockaddr_storage buf;
|
||||
};
|
||||
|
||||
static VALUE
|
||||
|
@ -86,7 +86,7 @@ recvfrom_blocking(void *data)
|
|||
{
|
||||
struct recvfrom_arg *arg = data;
|
||||
return (VALUE)recvfrom(arg->fd, RSTRING_PTR(arg->str), RSTRING_LEN(arg->str),
|
||||
arg->flags, (struct sockaddr*)arg->buf, &arg->alen);
|
||||
arg->flags, (struct sockaddr*)&arg->buf, &arg->alen);
|
||||
}
|
||||
|
||||
VALUE
|
||||
|
@ -139,16 +139,16 @@ s_recvfrom(VALUE sock, int argc, VALUE *argv, enum sock_recv_type from)
|
|||
}
|
||||
#endif
|
||||
if (arg.alen && arg.alen != sizeof(arg.buf)) /* OSX doesn't return a from result for connection-oriented sockets */
|
||||
return rb_assoc_new(str, ipaddr((struct sockaddr*)arg.buf, fptr->mode & FMODE_NOREVLOOKUP));
|
||||
return rb_assoc_new(str, ipaddr((struct sockaddr*)&arg.buf, fptr->mode & FMODE_NOREVLOOKUP));
|
||||
else
|
||||
return rb_assoc_new(str, Qnil);
|
||||
|
||||
#ifdef HAVE_SYS_UN_H
|
||||
case RECV_UNIX:
|
||||
return rb_assoc_new(str, unixaddr((struct sockaddr_un*)arg.buf, arg.alen));
|
||||
return rb_assoc_new(str, unixaddr((struct sockaddr_un*)&arg.buf, arg.alen));
|
||||
#endif
|
||||
case RECV_SOCKET:
|
||||
return rb_assoc_new(str, io_socket_addrinfo(sock, (struct sockaddr*)arg.buf, arg.alen));
|
||||
return rb_assoc_new(str, io_socket_addrinfo(sock, (struct sockaddr*)&arg.buf, arg.alen));
|
||||
default:
|
||||
rb_bug("s_recvfrom called with bad value");
|
||||
}
|
||||
|
@ -159,7 +159,7 @@ s_recvfrom_nonblock(VALUE sock, int argc, VALUE *argv, enum sock_recv_type from)
|
|||
{
|
||||
rb_io_t *fptr;
|
||||
VALUE str;
|
||||
char buf[1024];
|
||||
struct sockaddr_storage buf;
|
||||
socklen_t alen = sizeof buf;
|
||||
VALUE len, flg;
|
||||
long buflen;
|
||||
|
@ -189,7 +189,7 @@ s_recvfrom_nonblock(VALUE sock, int argc, VALUE *argv, enum sock_recv_type from)
|
|||
|
||||
rb_io_check_closed(fptr);
|
||||
rb_io_set_nonblock(fptr);
|
||||
slen = recvfrom(fd, RSTRING_PTR(str), buflen, flags, (struct sockaddr*)buf, &alen);
|
||||
slen = recvfrom(fd, RSTRING_PTR(str), buflen, flags, (struct sockaddr*)&buf, &alen);
|
||||
|
||||
if (slen < 0) {
|
||||
rb_sys_fail("recvfrom(2)");
|
||||
|
@ -204,11 +204,11 @@ s_recvfrom_nonblock(VALUE sock, int argc, VALUE *argv, enum sock_recv_type from)
|
|||
|
||||
case RECV_IP:
|
||||
if (alen && alen != sizeof(buf)) /* connection-oriented socket may not return a from result */
|
||||
addr = ipaddr((struct sockaddr*)buf, fptr->mode & FMODE_NOREVLOOKUP);
|
||||
addr = ipaddr((struct sockaddr*)&buf, fptr->mode & FMODE_NOREVLOOKUP);
|
||||
break;
|
||||
|
||||
case RECV_SOCKET:
|
||||
addr = io_socket_addrinfo(sock, (struct sockaddr*)buf, alen);
|
||||
addr = io_socket_addrinfo(sock, (struct sockaddr*)&buf, alen);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
|
@ -688,13 +688,13 @@ sock_accept(VALUE sock)
|
|||
{
|
||||
rb_io_t *fptr;
|
||||
VALUE sock2;
|
||||
char buf[1024];
|
||||
struct sockaddr_storage buf;
|
||||
socklen_t len = sizeof buf;
|
||||
|
||||
GetOpenFile(sock, fptr);
|
||||
sock2 = s_accept(rb_cSocket,fptr->fd,(struct sockaddr*)buf,&len);
|
||||
sock2 = s_accept(rb_cSocket,fptr->fd,(struct sockaddr*)&buf,&len);
|
||||
|
||||
return rb_assoc_new(sock2, io_socket_addrinfo(sock2, (struct sockaddr*)buf, len));
|
||||
return rb_assoc_new(sock2, io_socket_addrinfo(sock2, (struct sockaddr*)&buf, len));
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -750,12 +750,12 @@ sock_accept_nonblock(VALUE sock)
|
|||
{
|
||||
rb_io_t *fptr;
|
||||
VALUE sock2;
|
||||
char buf[1024];
|
||||
struct sockaddr_storage buf;
|
||||
socklen_t len = sizeof buf;
|
||||
|
||||
GetOpenFile(sock, fptr);
|
||||
sock2 = s_accept_nonblock(rb_cSocket, fptr, (struct sockaddr *)buf, &len);
|
||||
return rb_assoc_new(sock2, io_socket_addrinfo(sock2, (struct sockaddr*)buf, len));
|
||||
sock2 = s_accept_nonblock(rb_cSocket, fptr, (struct sockaddr *)&buf, &len);
|
||||
return rb_assoc_new(sock2, io_socket_addrinfo(sock2, (struct sockaddr*)&buf, len));
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -802,13 +802,13 @@ sock_sysaccept(VALUE sock)
|
|||
{
|
||||
rb_io_t *fptr;
|
||||
VALUE sock2;
|
||||
char buf[1024];
|
||||
struct sockaddr_storage buf;
|
||||
socklen_t len = sizeof buf;
|
||||
|
||||
GetOpenFile(sock, fptr);
|
||||
sock2 = s_accept(0,fptr->fd,(struct sockaddr*)buf,&len);
|
||||
sock2 = s_accept(0,fptr->fd,(struct sockaddr*)&buf,&len);
|
||||
|
||||
return rb_assoc_new(sock2, io_socket_addrinfo(sock2, (struct sockaddr*)buf, len));
|
||||
return rb_assoc_new(sock2, io_socket_addrinfo(sock2, (struct sockaddr*)&buf, len));
|
||||
}
|
||||
|
||||
#ifdef HAVE_GETHOSTNAME
|
||||
|
|
Loading…
Reference in a new issue