Skip to content

Commit 3340a97

Browse files
committed
Rework the session startup to avoid a potentially blocking operation.
Indeed, starting a task from a protected object is a potentially blocking operation and is detected when using the global configuration pragma Detect_Blocking. Fixes T415-011.
1 parent caf3906 commit 3340a97

File tree

3 files changed

+24
-8
lines changed

3 files changed

+24
-8
lines changed

src/core/aws-session-control.adb

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
------------------------------------------------------------------------------
22
-- Ada Web Server --
33
-- --
4-
-- Copyright (C) 2000-2012, AdaCore --
4+
-- Copyright (C) 2000-2020, AdaCore --
55
-- --
66
-- This library is free software; you can redistribute it and/or modify --
77
-- it under terms of the GNU General Public License as published by the --
@@ -80,9 +80,18 @@ package body AWS.Session.Control is
8080
-----------
8181

8282
procedure Start
83-
(Session_Check_Interval : Duration; Session_Lifetime : Duration) is
83+
(Session_Check_Interval : Duration; Session_Lifetime : Duration)
84+
is
85+
Init_Cleaner : Boolean;
8486
begin
85-
Cleaner_Control.Start (Session_Check_Interval, Session_Lifetime);
87+
Cleaner_Control.Start
88+
(Session_Check_Interval, Session_Lifetime, Init_Cleaner);
89+
90+
-- Wether the cleaner task is to be initialized
91+
92+
if Init_Cleaner then
93+
Cleaner_Task := new Cleaner;
94+
end if;
8695
end Start;
8796

8897
end AWS.Session.Control;

src/core/aws-session.adb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
------------------------------------------------------------------------------
22
-- Ada Web Server --
33
-- --
4-
-- Copyright (C) 2000-2017, AdaCore --
4+
-- Copyright (C) 2000-2020, AdaCore --
55
-- --
66
-- This library is free software; you can redistribute it and/or modify --
77
-- it under terms of the GNU General Public License as published by the --
@@ -318,14 +318,18 @@ package body AWS.Session is
318318
-- Start --
319319
-----------
320320

321-
procedure Start (Check_Interval : Duration; Lifetime : Duration) is
321+
procedure Start
322+
(Check_Interval : Duration;
323+
Lifetime : Duration;
324+
Init_Cleaner : out Boolean) is
322325
begin
323326
S_Count := S_Count + 1;
327+
Init_Cleaner := False;
324328

325329
if S_Count = 1 then
326330
Session.Check_Interval := Start.Check_Interval;
327331
Session.Lifetime := Real_Time.To_Time_Span (Start.Lifetime);
328-
Cleaner_Task := new Cleaner;
332+
Init_Cleaner := True;
329333
end if;
330334
end Start;
331335

src/core/aws-session.ads

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
------------------------------------------------------------------------------
22
-- Ada Web Server --
33
-- --
4-
-- Copyright (C) 2000-2017, AdaCore --
4+
-- Copyright (C) 2000-2020, AdaCore --
55
-- --
66
-- This library is free software; you can redistribute it and/or modify --
77
-- it under terms of the GNU General Public License as published by the --
@@ -252,7 +252,10 @@ private
252252

253253
protected Cleaner_Control is
254254

255-
procedure Start (Check_Interval : Duration; Lifetime : Duration);
255+
procedure Start
256+
(Check_Interval : Duration;
257+
Lifetime : Duration;
258+
Init_Cleaner : out Boolean);
256259
-- Launch the cleaner task the first time and does nothing after
257260

258261
procedure Stop (Need_Release : out Boolean);

0 commit comments

Comments
 (0)