Skip to content

Loading…

Socket protection. #1

Merged
merged 3 commits into from

1 participant

@toots
Savonet member

No description provided.

@toots toots merged commit 2fb5eb0 into master
@toots toots deleted the socket-test branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 28, 2013
  1. @toots
Commits on Mar 29, 2013
  1. @toots

    Added comment.

    toots committed
  2. @toots

    Fix typo.

    toots committed
Showing with 22 additions and 0 deletions.
  1. +2 −0 CHANGES
  2. +20 −0 src/duppy.ml
View
2 CHANGES
@@ -2,6 +2,8 @@
=====
* Remove Panic exception and let original exception bubble through.
* Removed win32 select work-around: patch applied upstream.
+* Added dummy [select] calls before submitting a task to try to
+ protect against exceptions when calling actual [select]
0.4.2 (08-10-2011)
=====
View
20 src/duppy.ml
@@ -105,6 +105,26 @@ struct
let time () = Unix.gettimeofday ()
let rec t_of_task (task:('a,[<event])task) =
+ (** Test task sockets. There's no easy way to test
+ * sockets passed to [select] before hand for potential
+ * exception raised there. Once [select] raises an
+ * exception with multiple sockets passed, it is impossible
+ * to know which socket caused that exception, leading to
+ * fatal errors. Thus, we test each socket individually here
+ * using a [select] to stick to actual conditions. Please
+ * note that there is still a chance that the socket is closed
+ * between this test and the time it is actually pushed down
+ * to the main [select] call. *)
+ let prepare = function
+ | `Read socket ->
+ ignore(Unix.select [socket] [] [] 0.)
+ | `Write socket ->
+ ignore(Unix.select [] [socket] [] 0.)
+ | `Exception socket ->
+ ignore(Unix.select [] [] [socket] 0.)
+ | `Delay _ -> ()
+ in
+ List.iter prepare task.events;
let t0 = time () in
{ timestamp = t0 ; prio = task.priority ;
enrich = (fun e ->
Something went wrong with that request. Please try again.