Skip to content
This repository
Browse code

[fix] ping_register: A client connection is created on first ping, bu…

…t in some case client can don't ping the server and some ressources can be allocated and never collected because we don't trigger Disconnect if client conenction is never created
  • Loading branch information...
commit 523cb664f6e3133cf57b8feca0c8043149f015e7 1 parent 267f125
Quentin Bourgerie BourgerieQuentin authored Thomas Refis committed
3  opabsl/mlbsl/bslPingRegister.ml
@@ -123,5 +123,8 @@ end
123 123 (** Instantiated ping register with opa scheduler and op client *)
124 124 module M = PingRegister.Make(PingScheduler)(Client)
125 125
  126 +##register client_start : opa[ThreadContext.client] -> void
  127 +let client_start ck = M.create (Obj.magic ck)
  128 +
126 129 ##register client_stop : opa[ThreadContext.client] -> void
127 130 let client_stop ck = M.delete (Obj.magic ck)
9 oparuntime/pingRegister.ml
@@ -352,7 +352,10 @@ module Make (S : SCHEDULER) (C : CLIENT) = struct
352 352 [event_key]. *)
353 353 val remove_event : event_key -> unit
354 354
355   - (** Delete connextion of a client. *)
  355 + (** Create connexion of a client. *)
  356 + val create : C.key -> unit
  357 +
  358 + (** Delete connexion of a client. *)
356 359 val delete : C.key -> unit
357 360
358 361 (** Return [true] if the client connection identifier exists on
@@ -475,6 +478,8 @@ module Make (S : SCHEDULER) (C : CLIENT) = struct
475 478 | Not_found ->
476 479 Hashtbl.add state_tbl key (nb, s, ping_delay_client_msecond_rush)
477 480
  481 + let create key = update key 0
  482 +
478 483 let find_delay key =
479 484 try
480 485 let (_, _, d) = Hashtbl.find state_tbl key in d
@@ -554,4 +559,6 @@ module Make (S : SCHEDULER) (C : CLIENT) = struct
554 559
555 560 let delete = Connection.delete
556 561
  562 + let create = Connection.create
  563 +
557 564 end
3  oparuntime/pingRegister.mli
@@ -98,4 +98,7 @@ module Make (S : SCHEDULER) (C : CLIENT) : sig
98 98 (** Delete a client entry. *)
99 99 val delete : C.key -> unit
100 100
  101 + (** Create a client entry (Is needed ...). *)
  102 + val create : C.key -> unit
  103 +
101 104 end
2  stdlib/core/web/resource/resource_private.opa
@@ -834,7 +834,7 @@ export_resource(external_css_files: list(string),
834 834 user_agent = get_request_ua(req)
835 835 uri = get_request_uri(req)
836 836 num_page = match thread_context().key with
837   - | ~{client}-> client.page
  837 + | ~{client}-> do %%BslPingRegister.client_start%%(client) client.page
838 838 | _ -> result = Random.int(max_int)
839 839 do Log.warning("Resource export",
840 840 "This page is exported from a context that doesn't have a valid client thread context. Replacing by random value {result}")

0 comments on commit 523cb66

Please sign in to comment.
Something went wrong with that request. Please try again.