-
Notifications
You must be signed in to change notification settings - Fork 19
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
Break up setsockopt support and its TCP options. #7
Conversation
Ack on the coding style. I was rereading the code, if we raise Not_available at the setsockopt option, it would be the first raising of Not_available from C code, also the first case of something inside ExtUnixSpecific that can raise Not_available. This premise would have to be changed as well:
Still wanna do it ? Fine for me. |
I'm having some issues registering the exception back to C, the code in question doesn't run: let () = Callback.register_exception "Not_available" (Not_available "nothing") I've tried adding it right after the Not_available definition, but it doesn't run. When I add that line to my test program, everything works and I can call the exception from C code. |
The plan is to add preprocessing so that e.g. TCP_KEEPIDLE will not be visible in |
What if we cheat, we raise "invalid_arg" on the external setsockopt/getsockopt, and then on the ocaml setsockopt/getsockopt we convert the invalid_arg into a Not_available. Just reread the code, invalid_arg is already raised on an invalid value for k, which should also be impossible. But at any rate, we could still convert the Unix errno=ENOPROTOOPT, or use some other errno as the indicator, we catch it and convert to a Not_available. |
Yes, I agree, seems less hacky way to do it. |
Right on, not found should be fine.
|
Take a look, if that is fine, please don't merge the pull request, I want to rebase and clean the history. |
@@ -772,11 +772,22 @@ type socket_int_option = | |||
keepalive probes, if the socket option SO_KEEPALIVE has been set on this socket *) | |||
| TCP_KEEPINTVL (** The time (in seconds) between individual keepalive probes *) | |||
|
|||
external setsockopt_int_ext : Unix.file_descr -> socket_int_option -> int -> unit = "caml_extunix_setsockopt_int" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename as setsockopt_int so that it is shadowed and cannot be used accidentaly
Ah, missed the latest commit.
Looks fine, should I merge it? |
Awesome, thanks, I've more stuff to send. |
This makes sockopt available to OS X and very likely to other BSD systems, more especifically, OS X does not have TCP_KEEPIDLE, but has all the others. If we can't detect the TCP option, we define the value to -1, then we fake a ENOPROTOOPT if the user passed an option defined to -1. The risk, although virtually impossible, is that there is a unix system actually using -1 to the value of those tcp options. checking VMSPLICE............failed -checking SOCKOPT.............failed +checking SOCKOPT.............ok +checking TCP_KEEPCNT.........ok +checking TCP_KEEPIDLE........failed +checking TCP_KEEPINTVL.......ok checking POLL................ok
Updated comment and committed. Thanks! |
This makes sockopt available to OS X and very likely to other BSD systems, more
especifically, OS X does not have TCP_KEEPIDLE, but has all the others.
If we can't detect the TCP option, we define the value to -1, then we fake a
ENOPROTOOPT if the user passed an option defined to -1.
The risk, although virtually impossible, is that there is a unix system actually
using -1 to the value of those tcp options.
checking VMSPLICE............failed
-checking SOCKOPT.............failed
+checking SOCKOPT.............ok
+checking TCP_KEEPCNT.........ok
+checking TCP_KEEPIDLE........failed
+checking TCP_KEEPINTVL.......ok
checking POLL................ok