Skip to content

Instantly share code, notes, and snippets.

View rotty's full-sized avatar

Andreas Rottmann rotty

View GitHub Profile
@rotty
rotty / test-nonblocking.c
Last active January 29, 2019 22:57
Test non-blocking I/O behavior
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <stdbool.h>
static void check_nonblocking(const char *name, int fd)
{
printf("%s O_NONBLOCK is: %d\n", name, fcntl(fd, F_GETFL) & O_NONBLOCK);
}
@rotty
rotty / valgrind.log
Created January 24, 2019 18:09
valgrind errors in a diesel application using an sqlite3 backend
==25755== Memcheck, a memory error detector
==25755== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==25755== Using Valgrind-3.14.0 and LibVEX; rerun with -h for copyright info
==25755== Command: target/debug/r3ss
==25755== Parent PID: 2321
==25755==
==25755== Invalid read of size 8
==25755== at 0x488E2A5: sqlite3_db_handle (sqlite3.c:82311)
==25755== by 0x50C666: diesel::sqlite::connection::stmt::Statement::raw_connection (stmt.rs:86)
==25755== by 0x50C910: <diesel::sqlite::connection::stmt::Statement as core::ops::drop::Drop>::drop (stmt.rs:125)
impl<A, M> MessageResponse<A, M> for SubscriptionList
where
A: Actor,
M: Message<Result = Self>,
{
fn handle<R: ResponseChannel<M>>(self, _ctx: &mut A::Context, tx: Option<R>) {
if let Some(tx) = tx {
tx.send(self);
}
}
@rotty
rotty / example.rs
Created January 15, 2017 16:17
tokio-uds incoming stream
extern crate tokio_core;
extern crate tokio_uds;
use tokio_core::reactor::Core;
use tokio_uds::{UnixListener, UnixStream};
fn main() {
let mut core = Core::new().unwrap();
let handle = core.handle();
@rotty
rotty / ghci-stdout.txt
Created July 20, 2016 22:52
Haskell typeclass issue
GHCi, version 7.10.3: http://www.haskell.org/ghc/ :? for help
Prelude> :load test.hs
[1 of 1] Compiling Main ( test.hs, interpreted )
test.hs:8:22:
Couldn't match expected type ‘a’ with actual type ‘IPv4’
‘a’ is a rigid type variable bound by
the type signature for ipMap :: Addr a => (a -> b) -> IP -> b
at test.hs:7:10
Relevant bindings include