ext/kgio/connect.c in kgio-2.8.1 vs ext/kgio/connect.c in kgio-2.9.0
- old
+ new
@@ -1,5 +1,6 @@
+/* We do not modify RSTRING in this file, so RSTRING_MODIFIED is not needed */
#include "kgio.h"
#include "my_fileno.h"
#include "sock_for_fd.h"
#include "blocking_io_region.h"
@@ -65,11 +66,12 @@
return fd;
}
static VALUE
-my_connect(VALUE klass, int io_wait, int domain, void *addr, socklen_t addrlen)
+my_connect(VALUE klass, int io_wait, int domain,
+ const void *addr, socklen_t addrlen)
{
int fd = my_socket(domain);
if (connect(fd, addr, addrlen) < 0) {
if (errno == EINPROGRESS) {
@@ -131,29 +133,29 @@
return my_connect(klass, io_wait, hints.ai_family,
&addr, hints.ai_addrlen);
}
-static struct sockaddr *sockaddr_from(socklen_t *addrlen, VALUE addr)
+static const struct sockaddr *sockaddr_from(socklen_t *addrlen, VALUE addr)
{
if (TYPE(addr) == T_STRING) {
*addrlen = (socklen_t)RSTRING_LEN(addr);
- return (struct sockaddr *)(RSTRING_PTR(addr));
+ return (const struct sockaddr *)(RSTRING_PTR(addr));
}
rb_raise(rb_eTypeError, "invalid address");
return NULL;
}
-#if defined(MSG_FASTOPEN) && defined(HAVE_RB_THREAD_BLOCKING_REGION)
+#if defined(MSG_FASTOPEN) && defined(KGIO_HAVE_THREAD_CALL_WITHOUT_GVL)
#ifndef HAVE_RB_STR_SUBSEQ
#define rb_str_subseq rb_str_substr
#endif
struct tfo_args {
int fd;
- void *buf;
+ const void *buf;
size_t buflen;
- struct sockaddr *addr;
+ const struct sockaddr *addr;
socklen_t addrlen;
};
static VALUE tfo_sendto(void *_a)
{
@@ -294,13 +296,13 @@
static VALUE stream_connect(VALUE klass, VALUE addr, int io_wait)
{
int domain;
socklen_t addrlen;
- struct sockaddr *sockaddr = sockaddr_from(&addrlen, addr);
+ const struct sockaddr *sockaddr = sockaddr_from(&addrlen, addr);
- switch (((struct sockaddr_storage *)(sockaddr))->ss_family) {
+ switch (((const struct sockaddr_storage *)(sockaddr))->ss_family) {
case AF_UNIX: domain = PF_UNIX; break;
case AF_INET: domain = PF_INET; break;
case AF_INET6: domain = PF_INET6; break;
default:
rb_raise(rb_eArgError, "invalid address family");
@@ -379,10 +381,10 @@
cKgio_Socket = rb_define_class_under(mKgio, "Socket", cSocket);
rb_include_module(cKgio_Socket, mSocketMethods);
rb_define_singleton_method(cKgio_Socket, "new", kgio_new, -1);
rb_define_singleton_method(cKgio_Socket, "connect", kgio_connect, 1);
rb_define_singleton_method(cKgio_Socket, "start", kgio_start, 1);
-#if defined(MSG_FASTOPEN) && defined(HAVE_RB_THREAD_BLOCKING_REGION)
+#if defined(MSG_FASTOPEN) && defined(KGIO_HAVE_THREAD_CALL_WITHOUT_GVL)
rb_define_method(cKgio_Socket, "kgio_fastopen", fastopen, 2);
#endif
/*
* Document-class: Kgio::TCPSocket
*