Skip to content
Snippets Groups Projects
Commit 4d416e8d authored by Per Hedbor's avatar Per Hedbor
Browse files

Include a constant in Stdio.Port for reuseport and fastopen support.

Especially SO_REUSEPORT needs different code if it is supported than when it is not.
parent 4e09e956
Branches
Tags
No related merge requests found
...@@ -63,7 +63,6 @@ ...@@ -63,7 +63,6 @@
#ifdef HAVE_SYS_UN_H #ifdef HAVE_SYS_UN_H
#include <sys/un.h> #include <sys/un.h>
#endif #endif
#include "dmalloc.h" #include "dmalloc.h"
/*! @module Stdio /*! @module Stdio
...@@ -735,6 +734,17 @@ static void exit_port_struct(struct object *UNUSED(o)) ...@@ -735,6 +734,17 @@ static void exit_port_struct(struct object *UNUSED(o))
/* map_variable takes care of id and accept_callback. */ /* map_variable takes care of id and accept_callback. */
} }
int fd_from_portobject( struct object *p )
{
struct port *po = get_storage( p, port_program );
if(!po) return -1;
return po->box.fd;
}
static void port_query_fd(INT32 UNUSED(args))
{
push_int(fd_from_portobject(Pike_fp->current_object));
}
/*! @endclass /*! @endclass
*/ */
...@@ -787,17 +797,19 @@ void init_stdio_port(void) ...@@ -787,17 +797,19 @@ void init_stdio_port(void)
tVoid), 0); tVoid), 0);
ADD_FUNCTION ("set_backend", port_set_backend, tFunc(tObj,tVoid), 0); ADD_FUNCTION ("set_backend", port_set_backend, tFunc(tObj,tVoid), 0);
ADD_FUNCTION ("query_backend", port_query_backend, tFunc(tVoid,tObj), 0); ADD_FUNCTION ("query_backend", port_query_backend, tFunc(tVoid,tObj), 0);
ADD_FUNCTION ("query_fd", port_query_fd, tFunc(tVoid,tInt), 0);
#ifdef SO_REUSEPORT
ADD_INT_CONSTANT( "SO_REUSEPORT_SUPPORT", SO_REUSEPORT, 0 );
#endif
#ifdef TCP_FASTOPEN
ADD_INT_CONSTANT( "TCP_FASTOPEN_SUPPORT", TCP_FASTOPEN, 0 );
#endif
set_init_callback(init_port_struct); set_init_callback(init_port_struct);
set_exit_callback(exit_port_struct); set_exit_callback(exit_port_struct);
port_program = end_program(); port_program = end_program();
add_program_constant( "_port", port_program, 0 ); add_program_constant( "_port", port_program, 0 );
}
int fd_from_portobject( struct object *p )
{
struct port *po = get_storage( p, port_program );
if(!po) return -1;
return po->box.fd;
} }
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#endif /* HAVE_SYS_SOCKET_H */ #endif /* HAVE_SYS_SOCKET_H */
#ifdef HAVE_NETINET_IN_H #ifdef HAVE_NETINET_IN_H
#include <netinet/in.h> #include <netinet/in.h>
#include <netinet/tcp.h>
#endif /* HAVE_NETINET_IN_H */ #endif /* HAVE_NETINET_IN_H */
#ifdef HAVE_WINSOCK2_H #ifdef HAVE_WINSOCK2_H
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment