Skip to content

Instantly share code, notes, and snippets.

View Neopallium's full-sized avatar

Robert Gabriel Jakabosky Neopallium

View GitHub Profile
@Neopallium
Neopallium / Cargo.toml
Last active September 17, 2018 17:58
actix-web channel linked list corruption
[package]
name = "hello-world"
version = "0.1.0"
authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
workspace = "../"
[dependencies]
env_logger = "0.5"
futures = "0.1"
[pid 21158] 20:03:34.948728 epoll_wait(7, [{EPOLLIN, {u32=4294967295, u64=18446744073709551615}}], 1024, 0) = 1
[pid 21158] 20:03:34.948814 epoll_wait(7, [], 1024, 0) = 0
[pid 21158] 20:03:34.948844 epoll_wait(7, <unfinished ...>
[pid 21159] 20:03:35.501746 <... epoll_wait resumed> [{EPOLLIN, {u32=100, u64=100}}], 128, -1) = 1
[pid 21159] 20:03:35.501891 epoll_wait(10, <unfinished ...>
[pid 21158] 20:03:35.501903 <... epoll_wait resumed> [{EPOLLIN, {u32=4294967295, u64=18446744073709551615}}], 1024, 940) = 1
[pid 21158] 20:03:35.502103 epoll_wait(7, [], 1024, 0) = 0
read_available start: buf.len=0, buf.remain=8192
read_available: self.read buf.len=0, buf.remain=8192
[pid 21158] 20:03:35.502179 epoll_ctl(7, EPOLL_CTL_ADD, 20, {EPOLLIN|EPOLLOUT|EPOLLRDHUP|EPOLLET, {u32=0, u64=0}}) = 0
@Neopallium
Neopallium / test_half_closed.rs
Created August 31, 2018 14:51
test to show connection leaking in actix-web
use std::io;
use std::io::prelude::*;
use std::net::{Shutdown, TcpStream};
fn main() -> io::Result<()> {
let mut stream = TcpStream::connect("127.0.0.1:8080").expect("Couldn't connect to the server...");
stream.write(b"GET / HTTP/1.1\r\nHost: localhost:8080\r\n\r\n").expect("write");
@Neopallium
Neopallium / keybase.md
Created July 28, 2016 22:34
keybase.io

Keybase proof

I hereby claim:

  • I am Neopallium on github.
  • I am neopallium (https://keybase.io/neopallium) on keybase.
  • I have a public key whose fingerprint is 566A 9B8A 6C1F FC37 B5AB A491 0C38 AF43 3FE0 B1C0

To claim this, I am signing this object:

@Neopallium
Neopallium / assert_fmt.lua
Last active December 11, 2015 03:18
Assertion function with formatting support.
-- Release as Public Domain.
local function fmt_error(fmt, ...)
local f_type = type(fmt)
if f_type == 'string' then
if select('#', ...) > 0 then
return string.format(fmt, ...)
else
-- only a single string, no formating needed.
return fmt
end
@Neopallium
Neopallium / zero-relay.c
Created March 12, 2012 01:43
Fixed-up zero-relay. Correctly handles multi-part messages.
#include <stdint.h>
#include <stdio.h>
#include <zmq.h>
int main(int argc, char *argv[])
{
void *context = zmq_init(1);
zmq_msg_t msg;
int rc = 0;
int64_t more;
@Neopallium
Neopallium / gist:878205
Created March 20, 2011 08:42
mongrel2 yajl with print callback.
#include <yajl/yajl_gen.h>
//#define bassert(bcode) if((bcode) != BSTR_OK) abort()
#define bassert(bcode) (bcode)
#define B(K, V) if((V) != NULL) { \
yajl_gen_string(json_gen, (unsigned char *)bdata(K), blength(K)); \
yajl_gen_string(json_gen, (unsigned char *)bdata(V), blength(V)); \
}
@Neopallium
Neopallium / gist:878195
Created March 20, 2011 08:23
mongrel2 using yajl.
#include <yajl/yajl_gen.h>
#define B(K, V) if((V) != NULL) { \
yajl_gen_string(json_gen, (unsigned char *)bdata(K), blength(K)); \
yajl_gen_string(json_gen, (unsigned char *)bdata(V), blength(V)); \
}
bstring Request_to_payload(Request *req, bstring uuid, int fd, const char *buf, size_t len)
{
static const yajl_gen_config gen_config = { .beautify = 0, .indentString = "" };
@Neopallium
Neopallium / gist:878156
Created March 20, 2011 06:21
mongrel2 json gen speed-up.
#if 1
#define B(K, V) if((V) != NULL) { \
vstr = json_escape(V); \
bcatcstr(headers, ",\""); \
bcatcstr(headers, bdata(K)); \
bcatcstr(headers, "\":\""); \
bcatcstr(headers, bdata(vstr)); \
bcatcstr(headers, "\""); \
bdestroy(vstr); \
}
@Neopallium
Neopallium / gist:878063
Created March 20, 2011 04:04
mongrel2-lua luajit2 trace
[TRACE --- connection.lua:101 -- NYI: FastFunc string.format at connection.lua:103]
[TRACE --- connection.lua:112 -- NYI: FastFunc string.format at connection.lua:103]
[TRACE --- connection.lua:128 -- NYI: FastFunc pairs at connection.lua:50]
[TRACE --- connection.lua:46 -- NYI: FastFunc pairs at connection.lua:50]
[TRACE --- decode.lua:123 -- NYI: C function 0x4089b5f8 at decode.lua:90]
[TRACE --- decode.lua:123 -- NYI: C function 0x41220aa0 at decode.lua:90]
[TRACE --- decode.lua:123 -- NYI: C function 0x41221e40 at decode.lua:90]
[TRACE --- decode.lua:123 -- NYI: C function 0x412238f0 at decode.lua:90]
[TRACE --- decode.lua:123 -- NYI: C function 0x41a39570 at decode.lua:90]
[TRACE --- decode.lua:123 -- NYI: C function 0x41a50ba8 at decode.lua:90]