Skip to content

Instantly share code, notes, and snippets.

View capflam's full-sized avatar

Christopher Faulet capflam

  • HAProxy Technologies
  • Paris, France
View GitHub Profile
From 12456b597dbfe231ba5ea33457676ea59b505ed5 Mon Sep 17 00:00:00 2001
From: Christopher Faulet <cfaulet@haproxy.com>
Date: Fri, 6 Apr 2018 15:33:30 +0200
Subject: [PATCH] BUG/MEDIUM: threads: Fix the max/min calculation because of
name clashes
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
With gcc < 4.7, when HAProxy is built with threads, the macros
@capflam
capflam / gist:5491516faa7024435d8200e068f505d2
Created October 24, 2016 19:50
Yaws :: Read the config file using unicode encoding
diff --git a/src/yaws_config.erl b/src/yaws_config.erl
index a61d2a1..7f645a1 100644
--- a/src/yaws_config.erl
+++ b/src/yaws_config.erl
@@ -60,7 +60,7 @@ load(E = #env{conf = false}) ->
load(E) ->
{file, File} = E#env.conf,
error_logger:info_msg("Yaws: Using config file ~s~n", [File]),
- case file:open(File, [read]) of
+ case file:open(File, [read, {encoding, unicode}]) of
@capflam
capflam / gist:ef330cb3f09f032c0645
Last active August 29, 2015 14:15
Appmod skeleton
out(Arg) ->
case Arg#arg.clidata of
undefined ->
%% No body
do_something_without_clidata(Arg);
{partial, Bin} when Arg#arg.state == undefined ->
%% chunked request: first chunk received
{get_more, Arg#arg.cont, [Bin]};
{partial, Bin} ->
diff --git a/src/mime_type_c.erl b/src/mime_type_c.erl
index 400aace..e40a708 100644
--- a/src/mime_type_c.erl
+++ b/src/mime_type_c.erl
@@ -60,11 +60,10 @@ generate(ModFile, GInfo, SInfoMap) ->
%% "The pattern 'false' can never match the type 'true'"
Inc = case yaws_generated:is_local_install() of
true ->
- Info = ?MODULE:module_info(compile),
- SrcDir = filename:dirname(
@capflam
capflam / gist:5887571
Created June 28, 2013 19:55
Yaws :: patch to create log directory if it doesn't exist
diff --git a/src/yaws_config.erl b/src/yaws_config.erl
index ed013c3..3b624dd 100644
--- a/src/yaws_config.erl
+++ b/src/yaws_config.erl
@@ -739,7 +739,15 @@ fload(FD, globals, GC, C, Cs, Lno, Chars) ->
["logdir", '=', Logdir] ->
- Dir = filename:absname(Logdir),
+ Dir = case Logdir of
@capflam
capflam / yaws_lager_log.erl
Created April 27, 2012 14:38
simple logging module for yaws that uses lager
-module(yaws_lager_log).
-compile([{parse_transform, lager_transform}]).
-behaviour(yaws_logger).
-include_lib("yaws/include/yaws.hrl").
-include_lib("yaws/include/yaws_api.hrl").
-export([open_log/3, close_log/3, wrap_log/4, write_log/4]).
@capflam
capflam / yaws.conf
Created February 27, 2012 21:17
config file for yaws (double revproxy)
logdir = /home/christopher/test/yaws/var/log/yaws
ebin_dir = /home/christopher/test/yaws/lib/yaws/examples/ebin
ebin_dir = /home/christopher/test/yaws/var/yaws/ebin
include_dir = /home/christopher/test/yaws/lib/yaws/examples/include
max_connections = nolimit
keepalive_maxuses = nolimit
process_options = "[]"
trace = false
use_old_ssl = false
copy_error_log = true
@capflam
capflam / gist:1853891
Created February 17, 2012 14:48
Fix bug in yaws_revproxy (issue #82)
diff --git a/src/yaws_revproxy.erl b/src/yaws_revproxy.erl
index d44f24f..9859793 100644
--- a/src/yaws_revproxy.erl
+++ b/src/yaws_revproxy.erl
@@ -310,23 +310,37 @@ ploop(From0, To, Pid) ->
%% Before reentering the ploop in expect_header mode (new request/reply),
%% We must check the if we need to keep the connection alive
%% or if we must close it.
-ploop_keepalive(_From = #psock{httpconnection="close"}, _To, _Pid) ->
+ploop_keepalive(From = #psock{httpconnection="close"}, _To, _Pid) ->