Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename SO_{RCV,SND}TIMEO for Linux 5.1 #3498

Closed
J0WI opened this issue Apr 9, 2020 · 4 comments · Fixed by #3515
Closed

Rename SO_{RCV,SND}TIMEO for Linux 5.1 #3498

J0WI opened this issue Apr 9, 2020 · 4 comments · Fixed by #3515

Comments

@J0WI
Copy link

J0WI commented Apr 9, 2020

#ifdef SO_RCVTIMEO
case 887: return SO_RCVTIMEO;

#ifdef SO_SNDTIMEO
case 906: return SO_SNDTIMEO;

They have been renamed in Linux 5.1.

@slfritchie
Copy link
Contributor

slfritchie commented Apr 13, 2020

Hi, @J0WI, thanks for opening this ticket; I didn't know that this renaming is happening in the Linux kernel.

If you (or anyone else) has the need to use these constants, with the _OLD or _NEW suffix, it would be straightforward to add them. A PR with that patch would be nice, but not strictly necessary if you need something to work right now.

At the moment, it looks like UDP_VENDOR is the last #ifdef in

#ifdef UDP_VENDOR
case 1097: return UDP_VENDOR;
and uses the constant 1097. The _OLD symbols can be added at the end with constants 1098 and 1099. The _NEW symbols can be added also, with constants 1100-1101, assuming of course that the same #ifdef wrappers are used around both old & new constants.

@J0WI
Copy link
Author

J0WI commented Apr 14, 2020

This will still fail to compile on Linux 5.1+:

In file included from src/libponyrt/lang/socket.c:49:
src/libponyrt/lang/socket.c: In function 'pony_os_sockopt_option':
src/libponyrt/lang/socket.c:4474:22: error: 'SO_RCVTIMEO_OLD' undeclared (first use in this function); did you mean 'SO_RCVTIMEO_NEW'?
 4474 |     case 887: return SO_RCVTIMEO;
      |                      ^~~~~~~~~~~
src/libponyrt/lang/socket.c:4474:22: note: each undeclared identifier is reported only once for each function it appears in
src/libponyrt/lang/socket.c:4531:22: error: 'SO_SNDTIMEO_OLD' undeclared (first use in this function); did you mean 'SO_SNDTIMEO_NEW'?
 4531 |     case 906: return SO_SNDTIMEO;
      |                      ^~~~~~~~~~~
make: *** [Makefile:941: build/release/obj-native/libponyrt/lang/socket.o] Error 1

Renaming them with _OLD works fine for me.

@slfritchie
Copy link
Contributor

Thanks, @J0WI. Could you try the patch at https://gist.github.com/slfritchie/954557a58e1afce558db912356ee3c7a ? That creates the new constants plus the OSSockOpt glue to use them.

use "net"

actor Main
  new create(env: Env) =>
    @printf[I32]("so_rcvtimeo_new = %d\n".cstring(), OSSockOpt.so_rcvtimeo_new())

When I run this on a machine that doesn't have SO_RCVTIMEO_NEW available (like my OS X laptop), the value printed is -1.

@J0WI
Copy link
Author

J0WI commented Apr 15, 2020

It does not compile, same error as before.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants