conflict
This commit is contained in:
commit
76e2226978
@ -80,7 +80,7 @@ unsafe fn test_adder_clientloop(client: *mut llmp_client, _data: *mut c_void) ->
|
|||||||
}
|
}
|
||||||
|
|
||||||
unsafe fn broker_message_hook(
|
unsafe fn broker_message_hook(
|
||||||
_broker: *mut llmp_broker_state,
|
_broker: *mut llmp_broker,
|
||||||
client_metadata: *mut llmp_broker_client_metadata,
|
client_metadata: *mut llmp_broker_client_metadata,
|
||||||
message: *mut llmp_message,
|
message: *mut llmp_message,
|
||||||
_data: *mut c_void,
|
_data: *mut c_void,
|
||||||
@ -118,7 +118,7 @@ fn main() {
|
|||||||
counter_thread_count
|
counter_thread_count
|
||||||
);
|
);
|
||||||
|
|
||||||
let mut broker = llmp_broker_state {
|
let mut broker = llmp_broker {
|
||||||
last_msg_sent: ptr::null_mut(),
|
last_msg_sent: ptr::null_mut(),
|
||||||
broadcast_map_count: 0,
|
broadcast_map_count: 0,
|
||||||
broadcast_maps: ptr::null_mut(),
|
broadcast_maps: ptr::null_mut(),
|
||||||
@ -127,20 +127,20 @@ fn main() {
|
|||||||
llmp_client_count: 0,
|
llmp_client_count: 0,
|
||||||
llmp_clients: ptr::null_mut(),
|
llmp_clients: ptr::null_mut(),
|
||||||
};
|
};
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
|
|
||||||
llmp_broker_init(&mut broker).expect("Could not init");
|
llmp_broker_init(&mut broker).expect("Could not init");
|
||||||
for i in 0..counter_thread_count {
|
for i in 0..counter_thread_count {
|
||||||
println!("Adding client {}", i);
|
println!("Adding client {}", i);
|
||||||
llmp_broker_register_childprocess_clientloop(
|
broker.register_childprocess_clientloop(
|
||||||
&mut broker,
|
|
||||||
llmp_test_clientloop,
|
llmp_test_clientloop,
|
||||||
ptr::null_mut(),
|
ptr::null_mut(),
|
||||||
)
|
)
|
||||||
.expect("could not add child clientloop");
|
.expect("could not add child clientloop");
|
||||||
}
|
}
|
||||||
|
|
||||||
llmp_broker_register_childprocess_clientloop(
|
broker.register_childprocess_clientloop(
|
||||||
&mut broker,
|
|
||||||
test_adder_clientloop,
|
test_adder_clientloop,
|
||||||
ptr::null_mut(),
|
ptr::null_mut(),
|
||||||
)
|
)
|
||||||
@ -148,8 +148,8 @@ fn main() {
|
|||||||
|
|
||||||
println!("Spawning broker");
|
println!("Spawning broker");
|
||||||
|
|
||||||
llmp_broker_add_message_hook(&mut broker, broker_message_hook, ptr::null_mut());
|
broker.add_message_hook(broker_message_hook, ptr::null_mut());
|
||||||
|
|
||||||
llmp_broker_run(&mut broker);
|
broker.run();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,112 @@
|
|||||||
// use super::EventManager;
|
use core::marker::PhantomData;
|
||||||
|
use std::ptr;
|
||||||
|
|
||||||
pub struct LLMP {}
|
use crate::{
|
||||||
|
corpus::Corpus, engines::State, executors::Executor, inputs::Input, utils::Rand, AflError,
|
||||||
|
};
|
||||||
|
|
||||||
//pub impl EventManager for LLMP {}
|
use super::{
|
||||||
|
llmp_translated::{LlmpBroker, LlmpClientloopFn, LlmpMessageHookFn},
|
||||||
|
Event, EventManager,
|
||||||
|
};
|
||||||
|
|
||||||
|
/// Eventmanager for multi-processed application
|
||||||
|
#[cfg(feature = "std")]
|
||||||
|
pub struct LLMPEventManager<S, C, E, I, R>
|
||||||
|
where
|
||||||
|
S: State<C, E, I, R>,
|
||||||
|
C: Corpus<I, R>,
|
||||||
|
I: Input,
|
||||||
|
E: Executor<I>,
|
||||||
|
R: Rand,
|
||||||
|
//CE: CustomEvent<S, C, E, I, R>,
|
||||||
|
{
|
||||||
|
// TODO...
|
||||||
|
_marker: PhantomData<(S, C, E, I, R)>,
|
||||||
|
is_broker: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "std")]
|
||||||
|
impl<S, C, E, I, R> EventManager<S, C, E, I, R> for LLMPEventManager<S, C, E, I, R>
|
||||||
|
where
|
||||||
|
S: State<C, E, I, R>,
|
||||||
|
C: Corpus<I, R>,
|
||||||
|
E: Executor<I>,
|
||||||
|
I: Input,
|
||||||
|
R: Rand,
|
||||||
|
//CE: CustomEvent<S, C, E, I, R>,
|
||||||
|
{
|
||||||
|
fn enabled(&self) -> bool {
|
||||||
|
true
|
||||||
|
}
|
||||||
|
|
||||||
|
fn fire(&mut self, event: Event<S, C, E, I, R>) -> Result<(), AflError> {
|
||||||
|
//self.events.push(event);
|
||||||
|
|
||||||
|
// TODO: Serde serialize, llmp send
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn process(&mut self, state: &mut S, corpus: &mut C) -> Result<usize, AflError> {
|
||||||
|
// TODO: iterators
|
||||||
|
/*
|
||||||
|
let mut handled = vec![];
|
||||||
|
for x in self.events.iter() {
|
||||||
|
handled.push(x.handle_in_broker(state, corpus)?);
|
||||||
|
}
|
||||||
|
handled
|
||||||
|
.iter()
|
||||||
|
.zip(self.events.iter())
|
||||||
|
.map(|(x, event)| match x {
|
||||||
|
BrokerEventResult::Forward => event.handle_in_client(state, corpus),
|
||||||
|
// Ignore broker-only events
|
||||||
|
BrokerEventResult::Handled => Ok(()),
|
||||||
|
})
|
||||||
|
.for_each(drop);
|
||||||
|
let count = self.events.len();
|
||||||
|
dbg!("Handled {} events", count);
|
||||||
|
self.events.clear();
|
||||||
|
|
||||||
|
let num = self.events.len();
|
||||||
|
for event in &self.events {}
|
||||||
|
|
||||||
|
self.events.clear();
|
||||||
|
*/
|
||||||
|
|
||||||
|
Ok(0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "std")]
|
||||||
|
impl<S, C, E, I, R> LLMPEventManager<S, C, E, I, R>
|
||||||
|
where
|
||||||
|
S: State<C, E, I, R>,
|
||||||
|
C: Corpus<I, R>,
|
||||||
|
I: Input,
|
||||||
|
E: Executor<I>,
|
||||||
|
R: Rand,
|
||||||
|
{
|
||||||
|
/// Forks n processes, calls broker handler and client handlers, never returns.
|
||||||
|
pub fn spawn(
|
||||||
|
process_count: usize,
|
||||||
|
broker_message_hook: LlmpMessageHookFn,
|
||||||
|
clientloops: LlmpClientloopFn,
|
||||||
|
) -> ! {
|
||||||
|
unsafe {
|
||||||
|
let mut broker = LlmpBroker::new().expect("Failed to create llmp");
|
||||||
|
|
||||||
|
for i in 0..process_count - 1 {
|
||||||
|
println!("Adding client {}", i);
|
||||||
|
broker
|
||||||
|
.register_childprocess_clientloop(clientloops, ptr::null_mut())
|
||||||
|
.expect("could not add child clientloop");
|
||||||
|
}
|
||||||
|
|
||||||
|
println!("Spawning broker");
|
||||||
|
broker.add_message_hook(broker_message_hook, ptr::null_mut());
|
||||||
|
|
||||||
|
broker.run();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -12,7 +12,7 @@ pub mod llmp_translated; // TODO: Abstract away.
|
|||||||
pub mod shmem_translated;
|
pub mod shmem_translated;
|
||||||
|
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
pub use crate::events::llmp::LLMP;
|
pub use crate::events::llmp::LLMPEventManager;
|
||||||
|
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
@ -347,84 +347,3 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Eventmanager for multi-processed application
|
|
||||||
#[cfg(feature = "std")]
|
|
||||||
pub struct LLMPEventManager<S, C, E, I, R>
|
|
||||||
where
|
|
||||||
S: State<C, E, I, R>,
|
|
||||||
C: Corpus<I, R>,
|
|
||||||
I: Input,
|
|
||||||
E: Executor<I>,
|
|
||||||
R: Rand,
|
|
||||||
//CE: CustomEvent<S, C, E, I, R>,
|
|
||||||
{
|
|
||||||
// TODO...
|
|
||||||
phantom: PhantomData<(S, C, E, I, R)>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(feature = "std")]
|
|
||||||
impl<S, C, E, I, R> EventManager<S, C, E, I, R> for LLMPEventManager<S, C, E, I, R>
|
|
||||||
where
|
|
||||||
S: State<C, E, I, R>,
|
|
||||||
C: Corpus<I, R>,
|
|
||||||
E: Executor<I>,
|
|
||||||
I: Input,
|
|
||||||
R: Rand,
|
|
||||||
//CE: CustomEvent<S, C, E, I, R>,
|
|
||||||
{
|
|
||||||
fn enabled(&self) -> bool {
|
|
||||||
true
|
|
||||||
}
|
|
||||||
|
|
||||||
fn fire(&mut self, event: Event<S, C, E, I, R>) -> Result<(), AflError> {
|
|
||||||
//self.events.push(event);
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
fn process(&mut self, state: &mut S, corpus: &mut C) -> Result<usize, AflError> {
|
|
||||||
// TODO: iterators
|
|
||||||
/*
|
|
||||||
let mut handled = vec![];
|
|
||||||
for x in self.events.iter() {
|
|
||||||
handled.push(x.handle_in_broker(state, corpus)?);
|
|
||||||
}
|
|
||||||
handled
|
|
||||||
.iter()
|
|
||||||
.zip(self.events.iter())
|
|
||||||
.map(|(x, event)| match x {
|
|
||||||
BrokerEventResult::Forward => event.handle_in_client(state, corpus),
|
|
||||||
// Ignore broker-only events
|
|
||||||
BrokerEventResult::Handled => Ok(()),
|
|
||||||
})
|
|
||||||
.for_each(drop);
|
|
||||||
let count = self.events.len();
|
|
||||||
dbg!("Handled {} events", count);
|
|
||||||
self.events.clear();
|
|
||||||
|
|
||||||
let num = self.events.len();
|
|
||||||
for event in &self.events {}
|
|
||||||
|
|
||||||
self.events.clear();
|
|
||||||
*/
|
|
||||||
|
|
||||||
Ok(0)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(feature = "std")]
|
|
||||||
impl<S, C, E, I, R> LLMPEventManager<S, C, E, I, R>
|
|
||||||
where
|
|
||||||
S: State<C, E, I, R>,
|
|
||||||
C: Corpus<I, R>,
|
|
||||||
I: Input,
|
|
||||||
E: Executor<I>,
|
|
||||||
R: Rand,
|
|
||||||
//TODO CE: CustomEvent,
|
|
||||||
{
|
|
||||||
pub fn new() -> Self {
|
|
||||||
Self {
|
|
||||||
phantom: PhantomData,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user