issue #9090 : Take the same approach for socketmodule as daytimemodule

when it needs support from timemodule (which is a .so on linux):
link in timemodule.c for the required functions.
parent a39c47aa
...@@ -16,6 +16,9 @@ extern "C" { ...@@ -16,6 +16,9 @@ extern "C" {
*/ */
PyAPI_FUNC(time_t) _PyTime_DoubleToTimet(double x); PyAPI_FUNC(time_t) _PyTime_DoubleToTimet(double x);
/* Get the current time since the epoch in seconds */
PyAPI_FUNC(double) _PyTime_FloatTime(void);
#ifdef __cplusplus #ifdef __cplusplus
} }
......
...@@ -92,6 +92,7 @@ Local naming conventions: ...@@ -92,6 +92,7 @@ Local naming conventions:
#include "Python.h" #include "Python.h"
#include "structmember.h" #include "structmember.h"
#include "timefuncs.h"
#undef MAX #undef MAX
#define MAX(x, y) ((x) < (y) ? (y) : (x)) #define MAX(x, y) ((x) < (y) ? (y) : (x))
...@@ -751,43 +752,23 @@ internal_select(PySocketSockObject *s, int writing) ...@@ -751,43 +752,23 @@ internal_select(PySocketSockObject *s, int writing)
} }
END_SELECT_LOOP(s) END_SELECT_LOOP(s)
*/ */
#ifdef _WIN32
/* _PyTime_floattime is exported from timemodule.c which is a builtin on windows
* but not on linux. The problem we are fixing is mostly a windows problem so
* we leave it at that.
*/
#define HAVE_PYTIME_FLOATTIME
#endif
#ifdef HAVE_PYTIME_FLOATTIME
PyAPI_FUNC(double) _PyTime_floattime(void); /* defined in timemodule.c */
#define BEGIN_SELECT_LOOP(s) \ #define BEGIN_SELECT_LOOP(s) \
{ \ { \
double deadline, interval = s->sock_timeout; \ double deadline, interval = s->sock_timeout; \
int has_timeout = s->sock_timeout > 0.0; \ int has_timeout = s->sock_timeout > 0.0; \
if (has_timeout) { \ if (has_timeout) { \
deadline = _PyTime_floattime() + s->sock_timeout; \ deadline = _PyTime_FloatTime() + s->sock_timeout; \
} \ } \
while (1) { \ while (1) { \
errno = 0; \ errno = 0;
#define END_SELECT_LOOP(s) \ #define END_SELECT_LOOP(s) \
if (!has_timeout || \ if (!has_timeout || \
(!CHECK_ERRNO(EWOULDBLOCK) && !CHECK_ERRNO(EAGAIN))) \ (!CHECK_ERRNO(EWOULDBLOCK) && !CHECK_ERRNO(EAGAIN))) \
break; \ break; \
interval = deadline - _PyTime_floattime(); \ interval = deadline - _PyTime_FloatTime(); \
} \ } \
} }
#else
#define BEGIN_SELECT_LOOP(s) \
{ \
double interval = s->sock_timeout; \
do { \
errno = 0; \
#define END_SELECT_LOOP(s) \
} while(0); \
}
#endif
/* Initialize a new socket object. */ /* Initialize a new socket object. */
......
...@@ -1058,7 +1058,7 @@ floatsleep(double secs) ...@@ -1058,7 +1058,7 @@ floatsleep(double secs)
/* export floattime to socketmodule.c */ /* export floattime to socketmodule.c */
PyAPI_FUNC(double) PyAPI_FUNC(double)
_PyTime_floattime(void) _PyTime_FloatTime(void)
{ {
return floattime(); return floattime();
} }
...@@ -777,8 +777,9 @@ class PyBuildExt(build_ext): ...@@ -777,8 +777,9 @@ class PyBuildExt(build_ext):
exts.append( Extension('_csv', ['_csv.c']) ) exts.append( Extension('_csv', ['_csv.c']) )
# socket(2) # socket(2)
exts.append( Extension('_socket', ['socketmodule.c'], exts.append( Extension('_socket', ['socketmodule.c', 'timemodule.c'],
depends = ['socketmodule.h']) ) depends=['socketmodule.h'],
libraries=math_libs) )
# Detect SSL support for the socket module (via _ssl) # Detect SSL support for the socket module (via _ssl)
search_for_ssl_incs_in = [ search_for_ssl_incs_in = [
'/usr/local/ssl/include', '/usr/local/ssl/include',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment