Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
conduwuit
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
🥺
conduwuit
Commits
5c258f41
Commit
5c258f41
authored
7 months ago
by
Jason Volk
Committed by
Jason Volk
7 months ago
Browse files
Options
Downloads
Patches
Plain Diff
fixes for modules
Signed-off-by:
Jason Volk
<
jason@zemos.net
>
parent
15126ee1
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/core/mods/new.rs
+2
-2
2 additions, 2 deletions
src/core/mods/new.rs
src/main/mods.rs
+41
-13
41 additions, 13 deletions
src/main/mods.rs
with
43 additions
and
15 deletions
src/core/mods/new.rs
+
2
−
2
View file @
5c258f41
use
std
::
ffi
::
OsStr
;
use
std
::
ffi
::
OsStr
;
use
super
::{
path
,
Library
};
use
super
::{
path
,
Library
};
use
crate
::{
Err
or
,
Result
};
use
crate
::{
Err
,
Result
};
const
OPEN_FLAGS
:
i32
=
libloading
::
os
::
unix
::
RTLD_LAZY
|
libloading
::
os
::
unix
::
RTLD_GLOBAL
;
const
OPEN_FLAGS
:
i32
=
libloading
::
os
::
unix
::
RTLD_LAZY
|
libloading
::
os
::
unix
::
RTLD_GLOBAL
;
...
@@ -16,7 +16,7 @@ pub fn from_path(path: &OsStr) -> Result<Library> {
...
@@ -16,7 +16,7 @@ pub fn from_path(path: &OsStr) -> Result<Library> {
let
lib
=
unsafe
{
Library
::
open
(
Some
(
path
),
OPEN_FLAGS
)
};
let
lib
=
unsafe
{
Library
::
open
(
Some
(
path
),
OPEN_FLAGS
)
};
if
let
Err
(
e
)
=
lib
{
if
let
Err
(
e
)
=
lib
{
let
name
=
path
::
to_name
(
path
)
?
;
let
name
=
path
::
to_name
(
path
)
?
;
return
Err
(
Error
::
Err
(
format
!
(
"Loading module {name:?} failed: {e}"
)
))
;
return
Err!
(
"Loading module {name:?} failed: {e}"
);
}
}
Ok
(
lib
.expect
(
"module loaded"
))
Ok
(
lib
.expect
(
"module loaded"
))
...
...
This diff is collapsed.
Click to expand it.
src/main/mods.rs
+
41
−
13
View file @
5c258f41
#![cfg(conduit_mods)]
#![cfg(conduit_mods)]
#[no_link]
extern
crate
conduit_service
;
use
std
::{
use
std
::{
future
::
Future
,
future
::
Future
,
pin
::
Pin
,
pin
::
Pin
,
sync
::{
atomic
::
Ordering
,
Arc
},
sync
::{
atomic
::
Ordering
,
Arc
},
};
};
use
conduit
::{
mods
,
Error
,
Result
};
use
conduit
::{
debug
,
error
,
mods
,
Error
,
Result
};
use
tracing
::{
debug
,
error
}
;
use
conduit_service
::
Services
;
use
crate
::
Server
;
use
crate
::
Server
;
type
RunFuncResult
=
Pin
<
Box
<
dyn
Future
<
Output
=
Result
<
(),
Error
>>>>
;
type
StartFuncResult
=
Pin
<
Box
<
dyn
Future
<
Output
=
Result
<
Arc
<
Services
>>>
+
Send
>>
;
type
RunFuncProto
=
fn
(
&
Arc
<
conduit
::
Server
>
)
->
RunFuncResult
;
type
StartFuncProto
=
fn
(
&
Arc
<
conduit
::
Server
>
)
->
StartFuncResult
;
type
RunFuncResult
=
Pin
<
Box
<
dyn
Future
<
Output
=
Result
<
()
>>
+
Send
>>
;
type
RunFuncProto
=
fn
(
&
Arc
<
Services
>
)
->
RunFuncResult
;
type
StopFuncResult
=
Pin
<
Box
<
dyn
Future
<
Output
=
Result
<
()
>>
+
Send
>>
;
type
StopFuncProto
=
fn
(
Arc
<
Services
>
)
->
StopFuncResult
;
const
RESTART_THRESH
:
&
str
=
"conduit_service"
;
const
RESTART_THRESH
:
&
str
=
"conduit_service"
;
const
MODULE_NAMES
:
&
[
&
str
]
=
&
[
const
MODULE_NAMES
:
&
[
&
str
]
=
&
[
...
@@ -33,15 +42,25 @@ pub(crate) async fn run(server: &Arc<Server>, starts: bool) -> Result<(bool, boo
...
@@ -33,15 +42,25 @@ pub(crate) async fn run(server: &Arc<Server>, starts: bool) -> Result<(bool, boo
let
main_lock
=
server
.mods
.read
()
.await
;
let
main_lock
=
server
.mods
.read
()
.await
;
let
main_mod
=
(
*
main_lock
)
.last
()
.expect
(
"main module loaded"
);
let
main_mod
=
(
*
main_lock
)
.last
()
.expect
(
"main module loaded"
);
if
starts
{
if
starts
{
let
start
=
main_mod
.get
::
<
RunFuncProto
>
(
"start"
)
?
;
let
start
=
main_mod
.get
::
<
StartFuncProto
>
(
"start"
)
?
;
if
let
Err
(
error
)
=
start
(
&
server
.server
)
.await
{
match
start
(
&
server
.server
)
.await
{
error!
(
"Starting server: {error}"
);
Ok
(
services
)
=>
server
.services
.lock
()
.await
.insert
(
services
),
return
Err
(
error
);
Err
(
error
)
=>
{
}
error!
(
"Starting server: {error}"
);
return
Err
(
error
);
},
};
}
}
server
.server.stopping
.store
(
false
,
Ordering
::
Release
);
server
.server.stopping
.store
(
false
,
Ordering
::
Release
);
let
run
=
main_mod
.get
::
<
RunFuncProto
>
(
"run"
)
?
;
let
run
=
main_mod
.get
::
<
RunFuncProto
>
(
"run"
)
?
;
if
let
Err
(
error
)
=
run
(
&
server
.server
)
.await
{
if
let
Err
(
error
)
=
run
(
server
.services
.lock
()
.await
.as_ref
()
.expect
(
"services initialized"
))
.await
{
error!
(
"Running server: {error}"
);
error!
(
"Running server: {error}"
);
return
Err
(
error
);
return
Err
(
error
);
}
}
...
@@ -49,8 +68,17 @@ pub(crate) async fn run(server: &Arc<Server>, starts: bool) -> Result<(bool, boo
...
@@ -49,8 +68,17 @@ pub(crate) async fn run(server: &Arc<Server>, starts: bool) -> Result<(bool, boo
let
stops
=
!
reloads
||
stale
(
server
)
.await
?
<=
restart_thresh
();
let
stops
=
!
reloads
||
stale
(
server
)
.await
?
<=
restart_thresh
();
let
starts
=
reloads
&&
stops
;
let
starts
=
reloads
&&
stops
;
if
stops
{
if
stops
{
let
stop
=
main_mod
.get
::
<
RunFuncProto
>
(
"stop"
)
?
;
let
stop
=
main_mod
.get
::
<
StopFuncProto
>
(
"stop"
)
?
;
if
let
Err
(
error
)
=
stop
(
&
server
.server
)
.await
{
if
let
Err
(
error
)
=
stop
(
server
.services
.lock
()
.await
.take
()
.expect
(
"services initialized"
),
)
.await
{
error!
(
"Stopping server: {error}"
);
error!
(
"Stopping server: {error}"
);
return
Err
(
error
);
return
Err
(
error
);
}
}
...
@@ -103,7 +131,7 @@ pub(crate) async fn close(server: &Arc<Server>, force: bool) -> Result<usize, Er
...
@@ -103,7 +131,7 @@ pub(crate) async fn close(server: &Arc<Server>, force: bool) -> Result<usize, Er
async
fn
stale_count
(
server
:
&
Arc
<
Server
>
)
->
usize
{
async
fn
stale_count
(
server
:
&
Arc
<
Server
>
)
->
usize
{
let
watermark
=
stale
(
server
)
.await
.unwrap_or
(
available
());
let
watermark
=
stale
(
server
)
.await
.unwrap_or
(
available
());
available
()
-
watermark
available
()
.saturating_sub
(
watermark
)
}
}
async
fn
stale
(
server
:
&
Arc
<
Server
>
)
->
Result
<
usize
,
Error
>
{
async
fn
stale
(
server
:
&
Arc
<
Server
>
)
->
Result
<
usize
,
Error
>
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment