Skip to content

Instantly share code, notes, and snippets.

@smfreegard
Forked from baudehlo/plugins.patch
Created April 16, 2012 17:11
Show Gist options
  • Save smfreegard/2400011 to your computer and use it in GitHub Desktop.
Save smfreegard/2400011 to your computer and use it in GitHub Desktop.
[root@mail1-ec2 Haraka]# diff -uNr plugins.js.orig plugins.js
--- plugins.js.orig 2012-04-14 15:22:47.575558052 +0000
+++ plugins.js 2012-04-16 17:56:01.915136250 +0000
@@ -30,6 +30,7 @@
this.full_paths = full_paths;
this.config = config;
this.hooks = {};
+ this.server = {}; // set by server.js
};
Plugin.prototype.register_hook = function(hook_name, method_name) {
@@ -94,8 +95,13 @@
return plugin;
}
+// Set in server.js; initialized to empty object
+// to prevent it from blowing up any unit tests.
+plugins.server = {};
+
plugins._load_and_compile_plugin = function(name) {
var plugin = new Plugin(name);
+ plugin.server = this.server;
var fp = plugin.full_paths,
rf, last_err;
for (var i=0, j=fp.length; i<j; i++) {
[root@mail1-ec2 Haraka]# diff -uNr server.js.orig server.js
--- server.js.orig 2012-04-14 15:22:37.078187562 +0000
+++ server.js 2012-04-16 17:56:30.344148892 +0000
@@ -57,14 +57,16 @@
// config_data defaults
apply_defaults(config_data.main);
-
- plugins.load_plugins();
-
+
var server = net.createServer(function (client) {
client.setTimeout((config_data.main.inactivity_timeout || 300) * 1000);
conn.createConnection(client, server);
});
server.notes = {};
+ plugins.server = server;
+ plugins.load_plugins();
+
if (cluster && config_data.main.nodes) {
var c = cluster(server);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment